Hello ros-users,
Ever wish your catkin package could painlessly depend on any python library under the sun?
Presenting catkin_virtualenv, a tool to define and bundle python dependencies with your catkin python packages.
We’ve been running an internal ros_buildfarm instance at Locus Robotics for almost 2 years (thanks OSRF!). One ongoing pain point was managing python package dependencies that aren’t in the Debian/Ubuntu apt repositories.
The workflow for catkin_virtualenv fits fairly well on top of the existing ROS Python-via-CMake pattern:
-
declare a set of python requirements in
requirements.txt
-
generate a virtualenv at build time by calling CMake macro
catkin_generate_virtualenv
. -
install your python scripts via
catkin_install_python
as usual. - add a dependency to your nosetests and rostests.
More detail is provided in the README, or see the provided test packages for toy usage examples. Behind the scenes:
- the generated virtualenv will work transparently in devel- and install-space, and be bundled in any released debian packages.
- package requirements will be propagated to any dependent catkin packages.
- your python scripts will be wrapped in a loader that will work transparently with
rosrun
,roslaunch
, androstest
. - adding the
PYTHON3
flag tocatkin_generate_virtualenv
will enable your python scripts to run in python3. This mostly ‘just works’ with a lot of existing ROS components, but does have a few caveats at the moment.
One important thing to note is that the catkin_virtualenv approach does make your package artifacts noticeably ‘fatter’ due to the dependency bundling, so be wary of pulling in large dependency trees, and please continue to use rosdep+apt dependencies when possible.
Please enjoy, and I’m looking forward to feedback from anyone who finds this package useful!
Paul