Skip to content

Improve reporting of managed interpreter symlinks in uv python list#18459

Merged
zanieb merged 9 commits intoastral-sh:mainfrom
zaniebot:claude/fix-uv-17959-hj6Pq
Mar 19, 2026
Merged

Improve reporting of managed interpreter symlinks in uv python list#18459
zanieb merged 9 commits intoastral-sh:mainfrom
zaniebot:claude/fix-uv-17959-hj6Pq

Conversation

@zanieb
Copy link
Copy Markdown
Member

@zanieb zanieb commented Mar 13, 2026

Closes #17959

Expands discovery to always include a system scan even if --managed-python is used to find links to managed interpreters on the PATH. Then filters reported interpreters by whether or not they are managed after discovery, so --no-managed-python will never report those symlinks.

claude added 4 commits March 13, 2026 02:59
When `--managed-python` is used, widen discovery to include search path
sources so that symlinks pointing to managed installations are found,
then post-filter to keep only managed interpreters. Previously,
`OnlyManaged` only searched the `Managed` source, missing symlinks in
`~/.local/bin/` and similar PATH directories that point to uv-managed
Python installations.

Fixes astral-sh#17959

https://claude.ai/code/session_01Q6Uo1r3YhrdCWyKPXB5X5R
Extend the post-filter to handle both directions: `--managed-python`
keeps only managed interpreters, and `--no-managed-python` excludes
managed interpreters (e.g., symlinks on the search path that point to
uv-managed installations).

https://claude.ai/code/session_01Q6Uo1r3YhrdCWyKPXB5X5R
The previous test used `with_versions_as_managed` which changes the
discovery source to `Managed` — bypassing the search path symlink
scenario. The new test uses `python install` to create real symlinks
in `bin_dir`, then adds `bin_dir` to `UV_TEST_PYTHON_PATH` to verify
that `--no-managed-python` correctly excludes symlinks pointing to
managed installations, and `--managed-python` includes them.

https://claude.ai/code/session_01Q6Uo1r3YhrdCWyKPXB5X5R
@zanieb zanieb added the bug Something isn't working label Mar 13, 2026
@zanieb zanieb marked this pull request as ready for review March 13, 2026 19:47
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 15, 2026

Merging this PR will degrade performance by 5.49%

❌ 1 regressed benchmark
✅ 4 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation resolve_warm_jupyter 74.1 ms 78.4 ms -5.49%

Comparing zaniebot:claude/fix-uv-17959-hj6Pq (91a33c2) with main (1375fdb)

Open in CodSpeed

1 similar comment
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 15, 2026

Merging this PR will degrade performance by 5.49%

❌ 1 regressed benchmark
✅ 4 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation resolve_warm_jupyter 74.1 ms 78.4 ms -5.49%

Comparing zaniebot:claude/fix-uv-17959-hj6Pq (91a33c2) with main (1375fdb)

Open in CodSpeed

@zanieb zanieb requested a review from Gankra March 17, 2026 22:22
Comment on lines +173 to +176
.filter(|installation| match python_preference {
PythonPreference::OnlyManaged => installation.interpreter().is_managed(),
PythonPreference::OnlySystem => !installation.interpreter().is_managed(),
PythonPreference::Managed | PythonPreference::System => true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this just be python_preference.allows(installation.source)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, here we want to check if the installation is managed regardless of the source, so we need to actually check where interpreter's base prefix is. It does seem like PythonPreference::allows_interpreter would be useful though.

@zanieb zanieb merged commit c276064 into astral-sh:main Mar 19, 2026
102 of 103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv python list --managed-python doesn't show symlinks

3 participants