Pure CMake package: what is needed to append a path to PYTHONPATH?

asked 2023-05-02 12:52:02 -0500

Context: Working on a pure cmake package (mrpt/package.xml), which can be built standalone, in ROS 1 and in ROS 2. Building in ROS 1/2 with colcon correctly compiles the pure C++ libraries into .so files and their Python3 wrappers (based on pybind11), which are installed via colcon under:

install/mrpt2/lib/python3
install/mrpt2/lib/python3/dist-packages
install/mrpt2/lib/python3/dist-packages/pymrpt.so

The problem: Sourcing . install/setup.bash does NOT populate PYTHONPATH with install/<PKG>/lib/python3/dist-packages/ as would be needed.

What should be added to package.xml or CMakeLists.txt to make colcon to realize there is a Python library out there? Solutions that would work in general with colcon and catkin (for those still using it in ROS 1) would be great! :-)

The current method already generates the python libraries in the correct place when building ROS .deb packages, the unique remaining issue is adding PYTHONPATH when in local builds.

edit retag flag offensive close merge delete