-
Notifications
You must be signed in to change notification settings - Fork 760
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
Rewrite Python interpreter discovery #3266
Conversation
0972b45
to
ea73ecf
Compare
eb65979
to
3d0f4a6
Compare
f233559
to
8b7967b
Compare
3d0f4a6
to
e1a351e
Compare
8b7967b
to
13d6d75
Compare
CodSpeed Performance ReportMerging #3266 will not alter performanceComparing Summary
|
8a8207b
to
78d207d
Compare
78d207d
to
92dd014
Compare
Split out of #3266 If `UV_BOOTSTRAP_DIR` and `CARGO_MANIFEST_DIR` are both unset, we currently panic. This isn't good once we start to use managed toolchains in production. We'll need to change this more later once the toolchain directory is more user-facing.
Example test setup
I'll do some local QA and share helpful commands here |
8bbccd3
to
3a33668
Compare
Not sure if intentional, but I have
Should it resolve to the
|
Otherwise, my own smoke-testing works as expected. |
I would personally expect this to work -- I copied a Python to
I think we fixed this in the prior implementation and that it was considered a bug. |
3a33668
to
8c181d6
Compare
I think your |
6e53083
to
c797422
Compare
c797422
to
d7bee96
Compare
d7bee96
to
4a2679c
Compare
# Conflicts: # crates/uv/src/commands/project/run.rs
4a2679c
to
1b212ab
Compare
Closes #3784 The cache did not use an absolute path. I'm not sure this is actually a new bug, as this code wasn't touched in #3266 but perhaps there was a slight difference in the paths we were passing around. Note, just canonicalizing the path as soon as we see it doesn't work because then we jump out of the virtual environmnent into the system interpreter. ## Test plan ``` ❯ uv venv Using Python 3.12.3 interpreter at: /opt/homebrew/opt/python@3.12/bin/python3.12 Creating virtualenv at: .venv Activate with: source .venv/bin/activate ❯ uv pip install anyio Resolved 3 packages in 81ms Installed 3 packages in 4ms + anyio==4.3.0 + idna==3.7 + sniffio==1.3.1 ❯ mkdir uv-issue-3784 && cd uv-issue-3784 ❯ uv venv Using Python 3.12.3 interpreter at: /opt/homebrew/opt/python@3.12/bin/python3.12 Creating virtualenv at: .venv Activate with: source .venv/bin/activate ❯ gcm Switched to branch 'main' Your branch is up to date with 'origin/main'. ❯ cargo run -q -- pip list -v -p .venv DEBUG Checking for Python interpreter in directory `.venv` TRACE Cached interpreter info for Python 3.12.3, skipping probing: .venv/bin/python3 DEBUG Using Python 3.12.3 environment at .venv/bin/python3 Package Version ------- ------- anyio 4.3.0 idna 3.7 sniffio 1.3.1 ❯ cd uv-issue-3784 ❯ cargo run -q -- pip list -v -p .venv DEBUG Checking for Python interpreter in directory `.venv` TRACE Cached interpreter info for Python 3.12.3, skipping probing: .venv/bin/python3 DEBUG Using Python 3.12.3 environment at /Users/zb/workspace/uv/.venv/bin/python3 Package Version ------- ------- anyio 4.3.0 idna 3.7 sniffio 1.3.1 ❯ cd .. ❯ gco zb/fix-relative-venv Switched to branch 'zb/fix-relative-venv' ❯ cargo run -q -- pip list -v -p .venv DEBUG Checking for Python interpreter in directory `.venv` TRACE Cached interpreter info for Python 3.12.3, skipping probing: .venv/bin/python3 DEBUG Using Python 3.12.3 environment at .venv/bin/python3 Package Version ------- ------- anyio 4.3.0 idna 3.7 sniffio 1.3.1 ❯ cd uv-issue-3784 ❯ cargo run -q -- pip list -v -p .venv DEBUG Checking for Python interpreter in directory `.venv` TRACE Cached interpreter info for Python 3.12.3, skipping probing: .venv/bin/python3 DEBUG Using Python 3.12.3 environment at .venv/bin/python3 ```
Updates our Python interpreter discovery to conform to the rules described in #2386, please see that issue for a full description of the behavior. Briefly, we now will search for interpreters that satisfy a requested version without stopping at the first Python executable. Additionally, if retrieving information about an interpreter fails we will continue to search for a working interpreter. We also add the plumbing necessary to request Python implementations other than CPython, though we do not add support for other implementations at this time.
A major internal goal of this work is to prepare for user-facing managed toolchains i.e. fetching a requested version during
uv run
. These APIs are not introduced, but there is some managed toolchain handling as required for our test suite.Some noteworthy implementation changes:
uv_interpreter::find_python
module has been removed in favor of auv_interpreter::discovery
module.uv_interpreter::Error
variants were split into scoped types in each moduleRemaining work:
PythonVersion
andVersionRequest
ManagedToolchain
into local and remote variantsRefactors split into:
py
launcher handling into separate module #3329implementation
andplatform
modules #3332Closes #2386