From 7e1f40d4d043811ea12ac1f620dae431d1338df1 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 31 Aug 2020 20:03:43 +0200 Subject: [PATCH] Remove python_orocos_kdl env-hooks, support devel-space build of python_orocos_kdl and invoke catkin_package() Macro catkin_package() takes care of installing package.xml and setup scripts. Usually it also installs cmake and pkg-config configuration files, but we skip this because orocos_kdl already provides its own configuration and the Python bindings do not require it. If the Python module is built in the correct path inside the devel-space, pointed to by PYTHON_INSTALL_DIR and CATKIN_GLOBAL_PYTHON_DESTINATION, and also installed to this directory, no env-hooks are required to update the PYTHONPATH and python_orocos_kdl even works in devel-space. This patch also allows to build orocos_kinematics_dynamics with colcon and colcon-ros (for ROS 1), because python_orocos_kdl is correctly detected as a catkin package and colcon will add the necessary hooks to update the PYTHONPATH, too. --- orocos_kdl/CMakeLists.txt | 11 +++++++--- orocos_kdl/package.xml | 2 +- python_orocos_kdl/CMakeLists.txt | 20 +++++++++++-------- .../python_orocos_kdl_site_packages.bash.in | 1 - .../python_orocos_kdl_site_packages.sh.in | 1 - .../python_orocos_kdl_site_packages.tcsh.in | 1 - .../python_orocos_kdl_site_packages.zsh.in | 1 - python_orocos_kdl/package.xml | 3 +-- 8 files changed, 22 insertions(+), 18 deletions(-) delete mode 120000 python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.bash.in delete mode 100644 python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.sh.in delete mode 120000 python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.tcsh.in delete mode 120000 python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.zsh.in diff --git a/orocos_kdl/CMakeLists.txt b/orocos_kdl/CMakeLists.txt index a29da279f..a21460ddd 100644 --- a/orocos_kdl/CMakeLists.txt +++ b/orocos_kdl/CMakeLists.txt @@ -27,6 +27,14 @@ MESSAGE( STATUS "Orocos KDL version ${VERSION} (${KDL_VERSION_MAJOR}.${KDL_VERSI SET( PROJ_SOURCE_DIR ${orocos_kdl_SOURCE_DIR} ) SET( PROJ_BINARY_DIR ${orocos_kdl_BINARY_DIR} ) +# catkin-specific configuration (optional) +find_package(catkin QUIET) +if(catkin_FOUND) + catkin_package( + SKIP_CMAKE_CONFIG_GENERATION + SKIP_PKG_CONFIG_GENERATION + ) +endif() IF(NOT CMAKE_INSTALL_PREFIX) SET( CMAKE_INSTALL_PREFIX /usr/local/ CACHE PATH "Installation directory" FORCE) @@ -125,6 +133,3 @@ CONFIGURE_FILE(orocos_kdl.pc.in ${CMAKE_CURRENT_BINARY_DIR}/orocos_kdl.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/orocos-kdl.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/orocos_kdl.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig) - -# Install package manifest (for catkin compatibility) -INSTALL(FILES package.xml DESTINATION share/orocos_kdl) diff --git a/orocos_kdl/package.xml b/orocos_kdl/package.xml index 9bae1cd15..f9d204ed4 100644 --- a/orocos_kdl/package.xml +++ b/orocos_kdl/package.xml @@ -13,7 +13,7 @@ http://wiki.ros.org/orocos_kdl LGPL - cmake + catkin eigen catkin diff --git a/python_orocos_kdl/CMakeLists.txt b/python_orocos_kdl/CMakeLists.txt index 9c5ae92dd..aea381fae 100644 --- a/python_orocos_kdl/CMakeLists.txt +++ b/python_orocos_kdl/CMakeLists.txt @@ -19,9 +19,20 @@ find_package(PythonInterp ${PYTHON_VERSION} REQUIRED) find_package(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} REQUIRED) # get_python_lib in python3 produces path which isn't in sys.path: https://bugs.launchpad.net/ubuntu/+source/python3-stdlib-extensions/+bug/1832215 # execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True, prefix=''))" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE) -set(PYTHON_SITE_PACKAGES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/dist-packages") +set(PYTHON_SITE_PACKAGES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/dist-packages") # This might be overridden below if built with catkin. set(LIBRARY_NAME "PyKDL") +# catkin-specific configuration (optional) +find_package(catkin QUIET) +if(catkin_FOUND) + catkin_package( + SKIP_CMAKE_CONFIG_GENERATION + SKIP_PKG_CONFIG_GENERATION + ) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${PYTHON_INSTALL_DIR}) + set(PYTHON_SITE_PACKAGES_INSTALL_DIR "${PYTHON_INSTALL_DIR}") +endif() + message(DEPRECATION "PyKDL has been moved to PyBind11. PyKDL based on SIP might become depracted in the (near) future. To keep using the SIP based version set 'BUILD_PYKDL_PYBIND11' to OFF.") option(BUILD_PYKDL_PYBIND11 "Use PyBind11 instead of SIP" ON) @@ -53,10 +64,3 @@ else (BUILD_PYKDL_PYBIND11) endif() add_sip_python_module(${LIBRARY_NAME} ${LIBRARY_NAME}/sip/${LIBRARY_NAME}.sip ${orocos_kdl_LIBRARIES}) endif(BUILD_PYKDL_PYBIND11) - -install(FILES package.xml DESTINATION share/python_orocos_kdl) - -find_package(catkin QUIET) -if(catkin_FOUND) - catkin_add_env_hooks(python_orocos_kdl_site_packages SHELLS bash tcsh zsh DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks) -endif() diff --git a/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.bash.in b/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.bash.in deleted file mode 120000 index 47a63df22..000000000 --- a/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.bash.in +++ /dev/null @@ -1 +0,0 @@ -python_orocos_kdl_site_packages.sh.in \ No newline at end of file diff --git a/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.sh.in b/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.sh.in deleted file mode 100644 index 13d938d3c..000000000 --- a/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.sh.in +++ /dev/null @@ -1 +0,0 @@ -export PYTHONPATH=@PYTHON_SITE_PACKAGES_INSTALL_DIR@:$PYTHONPATH diff --git a/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.tcsh.in b/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.tcsh.in deleted file mode 120000 index 47a63df22..000000000 --- a/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.tcsh.in +++ /dev/null @@ -1 +0,0 @@ -python_orocos_kdl_site_packages.sh.in \ No newline at end of file diff --git a/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.zsh.in b/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.zsh.in deleted file mode 120000 index 47a63df22..000000000 --- a/python_orocos_kdl/env-hooks/python_orocos_kdl_site_packages.zsh.in +++ /dev/null @@ -1 +0,0 @@ -python_orocos_kdl_site_packages.sh.in \ No newline at end of file diff --git a/python_orocos_kdl/package.xml b/python_orocos_kdl/package.xml index b97c20c4f..aae26a71f 100644 --- a/python_orocos_kdl/package.xml +++ b/python_orocos_kdl/package.xml @@ -13,7 +13,7 @@ http://wiki.ros.org/python_orocos_kdl LGPL - cmake + catkin orocos_kdl python-sip @@ -32,7 +32,6 @@ python-sphinx - cmake