Commit 9a607113 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

[CMake] Review python module structure

Previously, we only had curves.so, which could be installed in
PYTHON_SITELIB.

Now, we also want to ship plot.py, so we need the following final
structure:
${PYTHON_SITELIB}/
└── curves/
    ├── __init__.py
    ├── curves.so
    └── plot.py

Then we can keep the same structure in the build dir, to be able to
run tests before any installation:

build/
└── python/
    └── curves/
        ├── __init__.pyc
        ├── curves.so
        └── plot.pyc

And for this, we can once again keep the same structure in the source
dir:

python/
└── curves/
    ├── __init__.py
    ├── curves_python.cpp
    └── plot.py
parent d48f3418
Pipeline #7847 passed with stage
in 14 minutes and 17 seconds
SET(${PY_NAME}_BINDINGS_SOURCES
curves_python.cpp
optimization_python.cpp
optimization_python.h
python_variables.cpp
python_variables.h
namespace.cpp
namespace.h
)
ADD_SUBDIRECTORY(${PY_NAME})
ADD_LIBRARY(${PY_NAME} SHARED ${${PY_NAME}_BINDINGS_SOURCES})
SET_TARGET_PROPERTIES(${PY_NAME} PROPERTIES PREFIX "")
TARGET_COMPILE_OPTIONS(${PY_NAME} PRIVATE "-Wno-conversion")
PKG_CONFIG_USE_DEPENDENCY(${PY_NAME} eigenpy)
IF(CURVES_WITH_PINOCCHIO_SUPPORT)
PKG_CONFIG_USE_DEPENDENCY(${PY_NAME} pinocchio)
ENDIF(CURVES_WITH_PINOCCHIO_SUPPORT)
TARGET_LINK_LIBRARIES(${PY_NAME} ${Boost_LIBRARIES})
# MESSAGE(WARNING "Boost libraries are : ${Boost_LIBRARIES}")
IF(APPLE)
# We need to change the extension for python bindings
SET_TARGET_PROPERTIES(${PY_NAME} PROPERTIES SUFFIX ".so")
ENDIF(APPLE)
INSTALL(TARGETS ${PY_NAME} DESTINATION ${PYTHON_SITELIB}/${PY_NAME})
install (FILES plot/plot.py
deploy/__init__.py
DESTINATION ${PYTHON_SITELIB}/${PY_NAME})
install (FILES deploy/optimization/__init__.py
DESTINATION ${PYTHON_SITELIB}/${PY_NAME}/optimization)
PYTHON_INSTALL_ON_SITE(${PY_NAME} __init__.py)
PYTHON_INSTALL_ON_SITE(${PY_NAME} plot.py)
PYTHON_INSTALL_ON_SITE(${PY_NAME} optimization.py)
ADD_PYTHON_UNIT_TEST("python-curves" "python/test/test.py" "python")
ADD_PYTHON_UNIT_TEST("python-optimization" "python/test/optimization.py" "python")
......
SET(${PY_NAME}_BINDINGS_SOURCES
curves_python.cpp
optimization_python.cpp
optimization_python.h
python_variables.cpp
python_variables.h
namespace.cpp
namespace.h
)
ADD_LIBRARY(${PY_NAME} SHARED ${${PY_NAME}_BINDINGS_SOURCES})
SET_TARGET_PROPERTIES(${PY_NAME} PROPERTIES PREFIX "")
TARGET_COMPILE_OPTIONS(${PY_NAME} PRIVATE "-Wno-conversion")
PKG_CONFIG_USE_DEPENDENCY(${PY_NAME} eigenpy)
IF(CURVES_WITH_PINOCCHIO_SUPPORT)
PKG_CONFIG_USE_DEPENDENCY(${PY_NAME} pinocchio)
ENDIF(CURVES_WITH_PINOCCHIO_SUPPORT)
TARGET_LINK_LIBRARIES(${PY_NAME} ${Boost_LIBRARIES})
# MESSAGE(WARNING "Boost libraries are : ${Boost_LIBRARIES}")
IF(APPLE)
# We need to change the extension for python bindings
SET_TARGET_PROPERTIES(${PY_NAME} PROPERTIES SUFFIX ".so")
ENDIF(APPLE)
INSTALL(TARGETS ${PY_NAME} DESTINATION ${PYTHON_SITELIB}/${PY_NAME})
......@@ -2,6 +2,4 @@
# Copyright (c) 2019 CNRS
# Author : Steve Tonneau
from curves import *
import plot
from .curves import *
......@@ -2,4 +2,4 @@
# Copyright (c) 2019 CNRS
# Author : Steve Tonneau
from curves.curves.optimization import *
from .curves.optimization import *
import eigenpy
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from numpy import array
from curves import bezier
from .curves import bezier
eigenpy.switchToNumpyArray()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment