diff --git a/core/python/src/moveit/python_tools/__init__.py b/core/python/src/moveit/python_tools/__init__.py index c8118af5..c6b08468 100644 --- a/core/python/src/moveit/python_tools/__init__.py +++ b/core/python/src/moveit/python_tools/__init__.py @@ -1 +1 @@ -from ._python_tools import * +from pymoveit_python_tools import * diff --git a/core/python/src/moveit/task_constructor/__init__.py b/core/python/src/moveit/task_constructor/__init__.py index e69de29b..bad5da2f 100644 --- a/core/python/src/moveit/task_constructor/__init__.py +++ b/core/python/src/moveit/task_constructor/__init__.py @@ -0,0 +1 @@ +from . import core, stages diff --git a/core/python/src/moveit/task_constructor/core.py b/core/python/src/moveit/task_constructor/core.py index 6eb86461..64262dd3 100644 --- a/core/python/src/moveit/task_constructor/core.py +++ b/core/python/src/moveit/task_constructor/core.py @@ -1 +1 @@ -from ._core import * +from pymoveit_mtc.core import * diff --git a/core/python/src/moveit/task_constructor/stages.py b/core/python/src/moveit/task_constructor/stages.py index 5e1bf68f..1406371d 100644 --- a/core/python/src/moveit/task_constructor/stages.py +++ b/core/python/src/moveit/task_constructor/stages.py @@ -1,2 +1 @@ -from ._core import Stage -from ._stages import * +from pymoveit_mtc.stages import * diff --git a/core/python/wrapper/CMakeLists.txt b/core/python/wrapper/CMakeLists.txt index d6fbddca..d193578a 100644 --- a/core/python/wrapper/CMakeLists.txt +++ b/core/python/wrapper/CMakeLists.txt @@ -19,62 +19,27 @@ install(TARGETS ${TOOLS_LIB_NAME} ) -# python_tools -set(TOOLS_LIB_NAME _python_tools) -configure_file(src/python_tools.cpp.in python_tools.cpp @ONLY) -pybind11_add_module(${TOOLS_LIB_NAME} MODULE ${CMAKE_CURRENT_BINARY_DIR}/python_tools.cpp) -target_link_libraries(${TOOLS_LIB_NAME} PRIVATE moveit_python_tools) +# moveit.python_tools +pybind11_add_module(pymoveit_python_tools src/python_tools.cpp) +target_link_libraries(pymoveit_python_tools PRIVATE ${TOOLS_LIB_NAME}) +set_target_properties(pymoveit_python_tools PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_PYTHON_DESTINATION}) -# python tools: configure install directory and create symlink in source space -set(MOVEIT_PYTHON_MODULE_PATH moveit/python_tools) -install(TARGETS ${TOOLS_LIB_NAME} - LIBRARY DESTINATION ${CATKIN_GLOBAL_PYTHON_DESTINATION}/${MOVEIT_PYTHON_MODULE_PATH} -) -add_custom_command(TARGET ${TOOLS_LIB_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E create_symlink "$" "${CMAKE_CURRENT_SOURCE_DIR}/../src/${MOVEIT_PYTHON_MODULE_PATH}/$" - COMMENT "Creating symlink to ${TOOLS_LIB_NAME} in source space" -) - - -# core -set(CORE_LIB_NAME _core) +# moveit.task_constructor set(INCLUDES ${PROJECT_SOURCE_DIR}/include/moveit/python/task_constructor) -configure_file(src/core.cpp.in core.cpp @ONLY) -pybind11_add_module(${CORE_LIB_NAME} SHARED +pybind11_add_module(pymoveit_mtc ${INCLUDES}/properties.h src/properties.cpp src/solvers.cpp src/core.cpp - ${CMAKE_CURRENT_BINARY_DIR}/core.cpp -) -target_include_directories(${CORE_LIB_NAME} - PUBLIC $ -) -target_link_libraries(${CORE_LIB_NAME} PUBLIC ${PROJECT_NAME} moveit_python_tools) - - -# stages -set(STAGES_LIB_NAME _stages) -configure_file(src/stages.cpp.in stages.cpp @ONLY) -pybind11_add_module(${STAGES_LIB_NAME} MODULE src/stages.cpp - ${CMAKE_CURRENT_BINARY_DIR}/stages.cpp + src/module.cpp ) -target_link_libraries(${STAGES_LIB_NAME} PUBLIC ${PROJECT_NAME}_stages ${CORE_LIB_NAME} moveit_python_tools) +target_include_directories(pymoveit_mtc PUBLIC $) +target_link_libraries(pymoveit_mtc PUBLIC ${PROJECT_NAME} ${PROJECT_NAME}_stages ${TOOLS_LIB_NAME}) +set_target_properties(pymoveit_mtc PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_PYTHON_DESTINATION}) - - -# core, stages: configure install directory -set(MOVEIT_PYTHON_MODULE_PATH moveit/task_constructor) -install(TARGETS ${CORE_LIB_NAME} ${STAGES_LIB_NAME} - LIBRARY DESTINATION ${CATKIN_GLOBAL_PYTHON_DESTINATION}/${MOVEIT_PYTHON_MODULE_PATH} +# install python libs +install(TARGETS pymoveit_python_tools pymoveit_mtc + LIBRARY DESTINATION ${CATKIN_GLOBAL_PYTHON_DESTINATION} ) -# Add symlinks from source space to devel-space libs -# This is necessary to find them from devel-space too -foreach(tgt ${CORE_LIB_NAME} ${STAGES_LIB_NAME}) -add_custom_command(TARGET ${tgt} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E create_symlink "$" "${CMAKE_CURRENT_SOURCE_DIR}/../src/${MOVEIT_PYTHON_MODULE_PATH}/$" - COMMENT "Creating symlink to ${tgt} in source space" -) -endforeach() diff --git a/core/python/wrapper/src/core.cpp.in b/core/python/wrapper/src/core.cpp.in deleted file mode 100644 index 01586056..00000000 --- a/core/python/wrapper/src/core.cpp.in +++ /dev/null @@ -1,19 +0,0 @@ -#include - -namespace moveit { -namespace python { - -void export_properties(pybind11::module& m); -void export_solvers(pybind11::module& m); -void export_core(pybind11::module& m); - -} -} - -PYBIND11_MODULE(@CORE_LIB_NAME@, m) { - m.doc() = "MoveIt Task Constructor"; - - moveit::python::export_properties(m); - moveit::python::export_solvers(m); - moveit::python::export_core(m); -} diff --git a/core/python/wrapper/src/module.cpp b/core/python/wrapper/src/module.cpp new file mode 100644 index 00000000..d35ab5f8 --- /dev/null +++ b/core/python/wrapper/src/module.cpp @@ -0,0 +1,26 @@ +#include + +namespace moveit { +namespace python { + +void export_properties(pybind11::module& m); +void export_solvers(pybind11::module& m); +void export_core(pybind11::module& m); +void export_stages(pybind11::module& m); + +} // namespace python +} // namespace moveit + +PYBIND11_MODULE(pymoveit_mtc, m) { + m.doc() = "MoveIt Task Constructor"; + + auto msub = m.def_submodule("core"); + msub.doc() = "MTC core components"; + moveit::python::export_properties(msub); + moveit::python::export_solvers(msub); + moveit::python::export_core(msub); + + msub = m.def_submodule("stages"); + msub.doc() = "MTC stages"; + moveit::python::export_stages(msub); +} diff --git a/core/python/wrapper/src/python_tools.cpp.in b/core/python/wrapper/src/python_tools.cpp similarity index 93% rename from core/python/wrapper/src/python_tools.cpp.in rename to core/python/wrapper/src/python_tools.cpp index f0575e10..d649775b 100644 --- a/core/python/wrapper/src/python_tools.cpp.in +++ b/core/python/wrapper/src/python_tools.cpp @@ -6,7 +6,7 @@ namespace py = pybind11; using namespace moveit::python; -PYBIND11_MODULE(@TOOLS_LIB_NAME@, m) { +PYBIND11_MODULE(pymoveit_python_tools, m) { m.doc() = "MoveIt python tools"; m.def("roscpp_init", &InitProxy::init, "Initialize C++ ROS", py::arg("node_name") = "moveit_python_wrapper", diff --git a/core/python/wrapper/src/stages.cpp.in b/core/python/wrapper/src/stages.cpp.in deleted file mode 100644 index 2cb4da73..00000000 --- a/core/python/wrapper/src/stages.cpp.in +++ /dev/null @@ -1,14 +0,0 @@ -#include - -namespace moveit { -namespace python { - -void export_stages(pybind11::module& m); - -} } - -PYBIND11_MODULE(@STAGES_LIB_NAME@, m) { - m.doc() = "MoveIt Task Constructor Stages"; - - moveit::python::export_stages(m); -} diff --git a/core/setup.py b/core/setup.py index 2545e437..9d20d30e 100644 --- a/core/setup.py +++ b/core/setup.py @@ -1,11 +1,11 @@ #!/usr/bin/env python -from setuptools import setup +from setuptools import find_packages, setup from catkin_pkg.python_setup import generate_distutils_setup d = generate_distutils_setup( # list of packages to setup - packages=["moveit", "moveit.python_tools", "moveit.task_constructor"], + packages=find_packages("python/src"), # specify location of root ("") package dir package_dir={"": "python/src"}, )