Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uv python list doesn't find pypy #7286

Closed
hynek opened this issue Sep 11, 2024 · 7 comments · Fixed by #7649
Closed

uv python list doesn't find pypy #7286

hynek opened this issue Sep 11, 2024 · 7 comments · Fixed by #7649
Assignees
Labels
bug Something isn't working pypy Related to PyPy support uv python Related to the uv python interface

Comments

@hynek
Copy link
Contributor

hynek commented Sep 11, 2024

I find uv python list an amazing tool to debug Python Environment xkcd situations, even tho I don't use uv for downloads. But find my PyPy installation (I could've sworn it used to but I might be wrong).

Here's le output to demonstrate:

❯ uv python list
cpython-3.13.0rc2-macos-aarch64-none    /usr/local/bin/python3.13 -> ../../../Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13
cpython-3.13.0rc2-macos-aarch64-none    /Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13
cpython-3.13.0rc2-macos-aarch64-none    /Library/Frameworks/Python.framework/Versions/3.13/bin/python3 -> python3.13
cpython-3.12.6-macos-aarch64-none       /usr/local/bin/python3.12 -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12
cpython-3.12.6-macos-aarch64-none       /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/python3
cpython-3.12.6-macos-aarch64-none       /Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12
cpython-3.12.6-macos-aarch64-none       /Library/Frameworks/Python.framework/Versions/3.12/bin/python3 -> python3.12
cpython-3.12.6-macos-aarch64-none       .local/share/uv/python/cpython-3.12.6-macos-aarch64-none/bin/python3 -> python3.12
cpython-3.11.10-macos-aarch64-none      /opt/homebrew/opt/python@3.11/bin/python3.11 -> ../Frameworks/Python.framework/Versions/3.11/bin/python3.11
cpython-3.11.10-macos-aarch64-none      <download available>
cpython-3.11.9-macos-aarch64-none       /usr/local/bin/python3.11 -> ../../../Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11
cpython-3.11.9-macos-aarch64-none       /Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11
cpython-3.11.9-macos-aarch64-none       /Library/Frameworks/Python.framework/Versions/3.11/bin/python3 -> python3.11
cpython-3.10.15-macos-aarch64-none      /opt/homebrew/opt/python@3.10/bin/python3.10 -> ../Frameworks/Python.framework/Versions/3.10/bin/python3.10
cpython-3.10.15-macos-aarch64-none      <download available>
cpython-3.10.11-macos-aarch64-none      /usr/local/bin/python3.10 -> ../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
cpython-3.9.20-macos-aarch64-none       /opt/homebrew/opt/python@3.9/bin/python3.9 -> ../Frameworks/Python.framework/Versions/3.9/bin/python3.9
cpython-3.9.20-macos-aarch64-none       <download available>
cpython-3.9.6-macos-aarch64-none        /Applications/Xcode.app/Contents/Developer/usr/bin/python3 -> ../../Library/Frameworks/Python3.framework/Versions/3.9/bin/python3
cpython-3.8.20-macos-aarch64-none       /opt/homebrew/opt/python@3.8/bin/python3.8 -> ../Frameworks/Python.framework/Versions/3.8/bin/python3.8
cpython-3.8.20-macos-aarch64-none       <download available>
cpython-3.7.9-macos-x86_64-none         /usr/local/bin/python3.7 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
pypy-3.10.14-macos-aarch64-none         <download available>
pypy-3.9.19-macos-aarch64-none          <download available>
pypy-3.8.16-macos-aarch64-none          <download available>

~
❯ type pypy3.10
pypy3.10 is /opt/homebrew/bin/pypy3.10

~
❯ uv --version
uv 0.4.9 (77d278f68 2024-09-10)

I can use it to create venvs, though:

❯ uv venv --python pypy3.10 foo
Using Python 3.10.14 interpreter at: /opt/homebrew/bin/pypy3.10
Creating virtualenv at: foo
Activate with: source foo/bin/activate.fish
@hynek hynek changed the title uv python list doesn't find pypy anymore uv python list doesn't find pypy Sep 11, 2024
@AlexWaygood AlexWaygood added the pypy Related to PyPy support label Sep 11, 2024
@zanieb
Copy link
Member

zanieb commented Sep 11, 2024

That's surprising. I'll look into this.

@zanieb zanieb self-assigned this Sep 11, 2024
@zanieb zanieb added bug Something isn't working uv python Related to the uv python interface labels Sep 11, 2024
@zanieb
Copy link
Member

zanieb commented Sep 12, 2024

Btw if you don't want to see the downloads you can use uv python list --only-installed or set your python-preference to `only-system

@hynek
Copy link
Contributor Author

hynek commented Sep 12, 2024

Btw if you don't want to see the downloads you can use uv python list --only-installed or set your python-preference to `only-system

Ohhh loving it! I didn’t mind the download available but this is really cool.

@zanieb
Copy link
Member

zanieb commented Sep 12, 2024

I think this is because, generally, we don't look for pypy executables unless you request PyPy so we exclude them here. I'll need to do some refactors to fix this.

@hynek
Copy link
Contributor Author

hynek commented Sep 12, 2024

That’s kinda funny in combination with #7118 — sorry for running into all edge cases. 🙈

@zanieb
Copy link
Member

zanieb commented Sep 12, 2024

I appreciate it :)

@hynek
Copy link
Contributor Author

hynek commented Sep 12, 2024

image

zanieb added a commit that referenced this issue Sep 19, 2024
As we support more complex Python discovery behaviors such as:

- #7431 
- #7335 
- #7300 

`Any` is no longer accurate, we actually are looking for a reasonable
default Python version to use which may exclude the first one we find.
Separately, we need the idea of `Any` to improve behavior when listing
versions (e.g., #7286) where we do actually want to match _any_ Python
version. As a first step, we'll rename `Any` to `Default`. Then, we'll
introduce a new `Any` that actually behaves as we'd expect.
zanieb added a commit that referenced this issue 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/python@3.12/bin/python3.12 -> ../Frameworks/Python.framework/Versions/3.12/bin/python3.12
cpython-3.11.10-macos-aarch64-none    /opt/homebrew/opt/python@3.11/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pypy Related to PyPy support uv python Related to the uv python interface
Projects
None yet
3 participants