-
Notifications
You must be signed in to change notification settings - Fork 771
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 finds PyPy when looking for Python #2316
Comments
Is this "wrong"? We have two |
Does it work as expected if you install Python 3.7 in the |
python3.7 should not find pypy3.7. Some installs of PyPy (like GitHub Actions) include a "compatibility" python3.7 executable so that if it is "activated", then "python" works, but it shouldn't be discovered if you ask for I believe we are making Maybe the rule could be if Might be worth checking how virtualenv does this, as it handles it correctly. |
Correction: Yes, we are activating everything: https://github.com/wntrblm/nox/blob/08813c3c6b0d2171c280bbfcf219d089a16d1ac2/.github/workflows/action.yml#L44 It's just the default that was pypy3.9 and pypy3.10, but we override it for our tests. Note that that field gets transformed before it is fed to setup-python, since we supported activating multiple Pythons before the official action supported it, and our syntax was slightly different. |
Ok, this makes sense. I wasn’t really familiar with how PyPy is typically used / executed. Shouldn’t be too hard to fix. |
What about when a user does “—python 3.7”? In that case, we probably do need to allow PyPy? |
Generally PyPy is a special case and you should be explicitly asking for it. It isn’t a drop in replacement for CPython due to the fact many libraries don’t support it. |
I think virtualenv, tox, nox all require PyPy in the search to include PyPy. Setup-Python too. |
Sounds good, this is helpful, thanks Henry. I’ll change it. |
I can think of two approaches:
Neither of these would apply when in a PyPy virtual environment, since in that case, we do want to find the |
The questions would be:
I would probably start by only matching PyPy if the user is explicit, e.g., the |
I’d say no. PyPy should only match if you ask for PyPy. But @gaborbernat would have more experience and good advice here. |
Yes.
Yes, if no other python is present. The way I interpret it, python or the lack of the implementation basically translates to any implementation. However for historical reasons if multiple implementations are available cpython wins. This is what virtualenv does. |
Is
I've never had pypy without cpython I guess. Matching virtualenv is fine. So |
Yes.
Yes. |
Wow, thanks! Okay, so I think just matching virtualenv's CPython preference would be fine here. And I might start using "cpython". Need to check and see if that's supported everywhere in nox. :) |
I still believe cpython should be chosen over pypy if there's a tie. It is very, very unlikely that PyPy is expected unless a user asked for PyPy, or if there is no matching CPython version. PyPy is not a drop in replacement for Python when it comes to packages; packages that provide wheels for CPython often have to build on PyPy if they are supported at all. This is also true for other implementations, I assume you'd at least be adding support for GraalPy soon, and again I think it should be opt-in unless it's the only matching interpreter. |
@henryiii What does a tie mean? One has to come before the other in the PATH, right? |
I'm pretty hesitant to do the approach where we search for any CPython interpreter then fall back to other implementations like PyPy in a second search. |
My issue is that setting up multiple versions of Python: - uses: actions/setup-python@v5
with:
python-version: |
3.10
3.11
3.12
pypy3.10 Then running nox, build, or whatever requesting "3.10" may run pypy twice, getting pypy when requesting @nox.session(
python=[
"3.10",
"3.11",
"3.12",
"pypy3.10",
]
)
... This also affects PEP 723, if you write: # /// script
# requires-python = "3.10.*"
# requires = ["numpy"]
# /// This will either take several minutes to build or more likely fail if PyPy is selected, since numpy doesn't provide PyPy 3.10 wheels. (I'm not sure if they ever plan to, they claim PyPy is going away in the coming months) |
If you have both CPython and PyPy installed, it seems like
uv
can find the wrong one when you ask for-p python3.7
(up to 3.10, since that's the highest version of PyPy):Virutalenv finds the correct one. This happens on GitHub Actions in https://github.com/wntrblm/nox/actions/runs/8209739709/job/22455867659?pr=799, only tried Windows - wntrblm/nox#799.
The text was updated successfully, but these errors were encountered: