Display alternative Python implementations in uv python list#7508
Closed
Display alternative Python implementations in uv python list#7508
uv python list#7508Conversation
zanieb
commented
Sep 18, 2024
crates/uv-python/src/discovery.rs
Outdated
Comment on lines
918
to
920
| // If found on the search path with the default executable name we should not skip it | ||
| && !(installation.uses_default_executable_name() | ||
| && installation.source == PythonSource::SearchPath) |
Member
Author
There was a problem hiding this comment.
This is a bit annoying, but necessary to prevent a regression when you have an alternative implementation on your PATH as python. We might want to track executable names in PythonSource::SearchPath directly; then we couple implement this in PythonSource::allows_alternative_implementations
zanieb
commented
Sep 18, 2024
crates/uv-python/src/discovery.rs
Outdated
Comment on lines
1528
to
1579
| let implementation_names: Vec<&'static str> = implementation.map_or_else( | ||
| || ImplementationName::possible_names().to_vec(), | ||
| |name| { | ||
| let name: &'static str = name.into(); | ||
| vec![name] | ||
| }, | ||
| ); |
Member
Author
There was a problem hiding this comment.
cc @BurntSushi
This is the result of our failure to use an iterator here.
65b41b4 to
522b7a5
Compare
Member
Author
|
Moving some of this into #7649 |
zanieb
added a commit
that referenced
this pull request
Sep 23, 2024
…mentations (#7649) There are two parts to this. The first is a restructuring and refactoring. We had some debt around expected executable name generation, which we address here by consolidating into a single function that generates a combination of names. This includes a bit of extra code around free-threaded variants because this was written on top of #7431 — I'll rebase that on top of this. The second addresses some bugs around alternative implementations. Notably, `uv python list` does not discovery executables with alternative implementation names. Now, we properly generate all of the executable names for `VersionRequest::Any` (originally implemented in #7508) to properly show all the implementations we can find: ``` ❯ cargo run -q -- python list --no-python-downloads cpython-3.12.6-macos-aarch64-none /opt/homebrew/opt/[email protected]/bin/python3.12 -> ../Frameworks/Python.framework/Versions/3.12/bin/python3.12 cpython-3.11.10-macos-aarch64-none /opt/homebrew/opt/[email protected]/bin/python3.11 -> ../Frameworks/Python.framework/Versions/3.11/bin/python3.11 cpython-3.9.6-macos-aarch64-none /Library/Developer/CommandLineTools/usr/bin/python3 -> ../../Library/Frameworks/Python3.framework/Versions/3.9/bin/python3 pypy-3.10.14-macos-aarch64-none /opt/homebrew/bin/pypy3 -> ../Cellar/pypy3.10/7.3.17/bin/pypy3 ``` While doing both of these changes, I ended up changing the priority of interpreter discovery slightly. For example, given that the executables are in the same directory, do we query `python` or `python3.10` first when you request `--python 3.10`? Previously, we'd check `python3.10` but I think that was an incorrect optimization. I think we should always prefer the bare name (i.e. `python`) first. Similarly, this applies to `python` and an executable for an alternative implementation like `pypy`. If it's not compatible with the request, we'll skip it anyway. We might have to query more interpreters with this approach but it seems rare. Closes #7286 superseding #7508
…ult executable name
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7286
We now show externally-managed alternative Python implementations
Previously, this required the implementation to use the
pythonexecutable name. The problem here is that we weren't looking at these executables at all unless the alternative implementation was requested.