Resolving rosdep pip keys on Jazzy (PEP 668): use a venv for rosdep-installed Python dependencies #7376
hakuturu583
started this conversation in
Design
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
On Jazzy (Ubuntu 24.04),
rosdep installfails for any package that declares a pip-based rosdep key (*-pip), because the system Python is marked externally managed (PEP 668). Autoware has no pip keys today, so this has not come up yet, but the first one (autowarefoundation/autoware_universe#13557,python3-typesafe-carla-pip) had to be limited to Humble withcondition="$ROS_DISTRO == humble".I'd like to agree on how Autoware should resolve pip keys on Jazzy and later. This post proposes a shared virtual environment that rosdep installs into as the first step toward per-package virtual environments with colcon-uv (#7117), and lists
PIP_BREAK_SYSTEM_PACKAGES=1as the simpler alternative. I'd like to avoid the status quo, which keeps pip-only libraries out of rosdep on Jazzy (option C below), for the reasons given there.Background
/usr/lib/python3.12/EXTERNALLY-MANAGED, sosudo pip installinto the system Python is refused.sudo -H pip3 install -U <pkg>. On Python >= 3.11, rosdep refuses to run it unless one of these is true (seerosdep2/platforms/pip.py):sys.prefix != sys.base_prefix), orPIP_BREAK_SYSTEM_PACKAGES=1is set, orbreak-system-packages = trueis set in pip.conf.Observed in autowarefoundation/autoware_universe#13557,
rosdep-check (jazzy):Where Autoware runs rosdep
exec_depend?.github/workflows/rosdep-check-pr.yamlcolcon-buildaction used bybuild-and-test-*remove-exec-dependruns first)docker/universe.Dockerfile(universe-develanduniversestages,--dependency-types=exec).webauto-ci/main/autoware-build/run.shrosdep installwith the apt-installed rosdep (set up by theros2_dev_toolsansible role)None of these set
PIP_BREAK_SYSTEM_PACKAGESor use a venv today. The only existing venv in the setup is acados'/opt/acados/.venv(ansible roleacados), which is installed with pip directly, not through rosdep.Verified: rosdep can install pip keys into a venv
On Ubuntu 24.04, this installs a pip key into the venv with no PEP 668 error:
Notes:
/usr/bin/rosdepruns on the system Python, so its venv check fails.--as-root pip:falseis needed. Otherwise rosdep runssudo -H pip3, and sudo resetsPATHto the system pip. apt keys are still installed with sudo.--system-site-packageskeeps the apt-installed ROS Python packages (rclpy, cv_bridge, ...) visible.Options
A. Shared venv for rosdep (proposal)
--system-site-packages(e.g./opt/autoware/venvin Docker images, a user-level path via ansible for source builds), and install rosdep into it.rosdep install ... --as-root pip:falsefrom that venv in the Dockerfiles,rosdep-check-pr.yaml,colcon-build, and webauto CI.binfirst onPATHat build time and at run time (ENV PATH=...in the images, an activation step in the docs and setup script).Pros: the system Python stays untouched, in line with PEP 668 and the Ubuntu/ROS guidance, and pip keys work on every distro.
Cons and open points:
#!/usr/bin/env python3followPATH.B.
PIP_BREAK_SYSTEM_PACKAGES=1Set it in the same places (or
break-system-packages = truein/etc/pip.confin the images and the ansible role).Pros: a small change, with nothing to change at run time.
Cons: it installs into the system Python, which is the conflict PEP 668 exists to prevent.
C. Avoid pip keys (not recommended)
Allow only apt or ROS-buildfarm (bloom) packages, and keep pip-only libraries out of rosdep (Humble-only conditions, manual install docs). This is the current de facto state, and I'd like to move away from it:
rosdep-checkcannot verify them and the Docker images do not include them, so environments drift apart.Relation to colcon-uv (#7117) and the proposed steps
colcon-uv (#7117) goes further than option A: it gives each package its own virtual environment, so dependencies are isolated per package and can be pinned with a lockfile. In the long run, this is the ideal setup.
Moving there in one go, however, changes how every Python package is built, installed, and launched. I propose getting there in steps:
package.xmland resolving them with rosdep, but install pip keys into a shared venv instead of the system Python. Confirm that Autoware builds, tests, and runs reliably with the venv in Docker, CI, and source builds.The first step also prepares for the second: once every build and launch path already runs inside a venv, moving to per-package venvs is a smaller change.
Questions
/opt/autoware/venv, a workspace-local venv, ...), and who owns the changes in autoware (Docker, ansible), autoware-github-actions, and autoware_universe CI?Related
python3-typesafe-carla-pip), currently limited to Humble.--break-system-packages", which is the same concern as option B here.All reactions