Skip to content

Remove venv from the Python preamble and adjust pip usage - #36

Merged
mmmarinho merged 1 commit into
mainfrom
remove-venv-from-preamble
Sep 15, 2026
Merged

mmmarinho merged 1 commit into
mainfrom
remove-venv-from-preamble

Conversation

@mmmarinho

Copy link
Copy Markdown
Owner

This PR removes all references to venv from the tutorial while keeping the Python preamble steps working.

Why

The preamble currently creates/activates a ros2tutorial_venv and routes user-level pip installs through it. This PR drops the venv entirely. Without it, user-level pip installs run against the system Python with --break-system-packages — which is consistent with the dqrobotics example already used in the same section and works on the target Ubuntu 24.04 (PEP 668).

What changed (6 files, docs only)

  • installing_python.rst — removed the "When you want to isolate your environment, use venv" section (create/activate/deactivate) and the python3-venv apt install; adjusted the dqrobotics example to drop the activate step.
  • python_best_practices.rst, python_asyncio.rst, python_packaging.rst — removed the "Use a venv" sections and the source ros2tutorial_venv/bin/activate commands.
  • python_packaging.rst — added --break-system-packages to the pip install/uninstall commands that previously relied on the venv, and updated the sample output paths to the user site-packages location.
  • the_canonical_build_command.rst — removed the "colcon will not work with an active venv" warning. (This snippet is .. include::d by ~14 pages, so the warning disappears from all of them.)
  • source_after_build.rst — rewrote the "dirty state" fix to drop the venv framing while keeping the useful build/ install/ log/ cleanup advice.

Verification

  • Full Sphinx build still succeeds — warning count is unchanged vs. main (no new warnings, no removed warnings; the only diff is a line-number shift on a pre-existing, unrelated warning).
  • Grep sweep confirms zero remaining venv / virtual environment / ros2tutorial_venv / activate / deactivate mentions in the docs.
  • No dangling cross-references (the removed Isolate your environment with a venv anchor was only referenced by the three sections that were also removed).

Note to maintainer: the only behavioral change is that the sample packages (wheel, minimalist_package) now install to the user's real site-packages instead of a throwaway venv — same trade-off the tutorial already makes with dqrobotics.

The tutorial no longer uses a Python venv. User-level pip installs
now run against the system Python with --break-system-packages, which
is consistent with the dqrobotics example already used in the same
section and works on the target Ubuntu 24.04 (PEP 668).

- installing_python.rst: drop the 'Isolate your environment with a
  venv' section (create/activate/deactivate) and the python3-venv apt
  install; adjust the dqrobotics install to drop the activate step.
- python_best_practices / python_asyncio / python_packaging: remove the
  'Use a venv' sections and the ros2tutorial_venv activate commands.
- python_packaging: add --break-system-packages to the pip install/
  uninstall commands that previously relied on the venv, and update the
  sample output paths to the user site-packages location.
- the_canonical_build_command.rst: remove the 'active venv breaks
  colcon' warning (this snippet is included by many pages).
- source_after_build.rst: rewrite the 'dirty state' fix to drop the
  venv framing while keeping the build/install/log cleanup advice.

Verified: full Sphinx build still succeeds with no new warnings, and no
venv/virtual-environment references remain in the rendered docs.

@mmmarinho mmmarinho left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying out this year without venv as it was a constant source of confusion.

@mmmarinho
mmmarinho merged commit d430652 into main Sep 15, 2026
4 checks passed
@mmmarinho
mmmarinho deleted the remove-venv-from-preamble branch September 15, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant