-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Allow builtin interpreter discovery to find specific Python versions given a general spec #2709
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests please 🥺
On it! It’s a draft so you can look at it if you want while I check those last boxes! |
Now I’m done! Seems like this change snuck into one of the tests: - pyvenv_cfg = Path(sys.executable).parents[1] / "pyvenv.cfg"
- if pyvenv_cfg.exists():
- (target / pyvenv_cfg.name).write_bytes(pyvenv_cfg.read_bytes()) that fragment doesn’t seem to be necessary to run the test locally? |
Seems you've upset the CI 😅 |
I guess I need to try this on macOS. No idea what to do if I can’t placate windows though … Seems like it works in practice though!
|
I cannot merge the pull request until the CI is green so it doesn't really matter that "it works on my machine" 😅. Sorry but the CI gods are absolute. 😭 |
Haha I’m a believer, don’t worry. It’s great that you test on windows and macOS too, as clearly with finnicky path stuff like this, that’s an issue. I’ll see what I can do. |
This reverts commit 468aa79.
Ah, the regex always needs to be case insensitive to get the intended effect. I tested locally on macOS and Linux now, so I hope windows doesn’t throw a wrench. |
db5ca7b
to
85b837d
Compare
OK, as feared everything passes except for on windows. I can only speculate that the If that’s not it, someone with a windows machine needs to help. /edit: e.g. @ofek, who just offered |
Looks good! I don’t think this timeout is caused by my code |
OK, pypy on windows fails with
I have absolutely no idea what “125280 failed to query …exe with code 3221225781” means, so I don’t think I can proceed here. |
Head branch was pushed to by a user without write access
Thanks for contributing, make sure you address all the checklists (for details on how see development documentation)
tox -e fix
)docs/changelog
folderFixes #2708, fixes pypa/hatch#1395
This PR fixes the discovery in
virtualenv.discovery.builtin
.It works by removing the method
PythonSpec.generate_names
and replacing it withgenerate_re
:A static name list can’t represent all Python executables that are compatible with a given spec, i.e.
PythonSpec.from_string_spec('3')
should match a executable called/usr/bin/python3.12
. I therefore inverted the way candidates are found. Instead of generating all possible candidates, we simply loop and use a regex to find candidates.Pro:
Con:
glob
just traverses directories in Python code as well, it wouldn‘t help here.How to review
The main commits are