Stop the pipx virtualenvs depending on the system Python #1

Merged
mgbruin merged 1 commit from uv-managed-python into main 2026-09-22 18:02:58 +00:00
Owner

Same one-line fix as ansible_role_container_metrics PR #2, for DWA-71.

What broke

ansible-core, ansible-lint and yamllint all failed on river with ModuleNotFoundError, so mise run lint could not pass in any repository. The tools are uv virtualenvs that had been built against /usr/bin/python3; river went 3.12 → 3.14, the packages stayed in lib/python3.12/site-packages, and the binaries sat there intact while importing nothing.

The fix

UV_PYTHON_PREFERENCE = "only-managed" — uv downloads and owns the interpreter, so an OS upgrade cannot orphan it.

Verified both directions: with only-system the same install lands on /usr/bin (3.14.4), with only-managed on uv's own cpython-3.13. mise does pass the variable through to tool installs, which was the part worth checking.

Pinning python in [tools] does not work — uv ignores mise's interpreter and picks its own.

Note

The tools were already reinstalled by hand, so nothing is broken while this sits unmerged; this prevents the next occurrence.

Same one-line fix as `ansible_role_container_metrics` PR #2, for DWA-71. ## What broke `ansible-core`, `ansible-lint` and `yamllint` all failed on river with `ModuleNotFoundError`, so `mise run lint` could not pass in any repository. The tools are uv virtualenvs that had been built against `/usr/bin/python3`; river went 3.12 → 3.14, the packages stayed in `lib/python3.12/site-packages`, and the binaries sat there intact while importing nothing. ## The fix `UV_PYTHON_PREFERENCE = "only-managed"` — uv downloads and owns the interpreter, so an OS upgrade cannot orphan it. Verified both directions: with `only-system` the same install lands on `/usr/bin` (3.14.4), with `only-managed` on uv's own `cpython-3.13`. mise does pass the variable through to tool installs, which was the part worth checking. Pinning `python` in `[tools]` does **not** work — uv ignores mise's interpreter and picks its own. ## Note The tools were already reinstalled by hand, so nothing is broken while this sits unmerged; this prevents the next occurrence.
uv builds these venvs against /usr/bin/python3 when it is compatible,
and the OS then replaces it: river went 3.12 -> 3.14, the packages
stayed in lib/python3.12/site-packages, and every tool died with
ModuleNotFoundError while its binaries sat there intact (DWA-71).

only-managed makes uv own the interpreter. Verified both ways: with
only-system the same install lands on /usr/bin and 3.14.4.

Pinning python in [tools] does not work -- uv ignores mise's interpreter.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mgbruin/ansible_role_courier_imap!1
No description provided.