-
Notifications
You must be signed in to change notification settings - Fork 808
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
Search PATH
when python
can't be found with py
#1711
Conversation
0b1c7e7
to
2275997
Compare
17d8b2e
to
e580f5a
Compare
cache: &Cache, | ||
) -> Result<Option<Interpreter>, Error> { | ||
#[allow(non_snake_case)] | ||
let UV_TEST_PYTHON_PATH = env::var_os("UV_TEST_PYTHON_PATH"); |
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.
I intentionally removed the TEST early return. We want that as much code as possible in this function is run during tests.
e580f5a
to
65418f8
Compare
200263d
to
3bd2d59
Compare
cache, | ||
), | ||
// SAFETY: Guaranteed by the Ok(versions) guard | ||
_ => unreachable!(), |
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.
Can request
be empty? I just realized then we could hit this path
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.
pub fn main() {
let versions = ""
.splitn(3, '.')
.map(str::parse::<u8>)
.collect::<Result<Vec<_>, _>>();
dbg!(versions);
}
gives me
[src/main.rs:8:9] versions = Err(
ParseIntError {
kind: Empty,
},
)
So we're good
for name in possible_names.iter().flatten() { | ||
if let Ok(paths) = which::which_in_global(&**name, Some(&path)) { | ||
for path in paths { | ||
if checked_installs.contains(&path) { |
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.
When do we see a path multiple times?
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.
I copied that over from virtualenv
but I'm not sure. Let's remove it for now.
6031209
to
8ef394b
Compare
8ef394b
to
6cd76fd
Compare
6cd76fd
to
55b0bd8
Compare
Summary
This PR improves uv's compatibility with PIP when discovering python installations.
PIP runs the following step
-p
is a path, resolve that specific instancesys.executable
matches the requested version (or if no version was requested, always use it)python{major}.{minor}.{patch}
,python{major}.{minor}
,python{major}
,python
Our existing implementation already did some of that but not all. We now
python3.9
python3.9.3
for Windows and Unixpy
)pyenv
shims (that's a hack)I merged most of the implementation between windows and unix because they are the same in
venv
too. The only real difference is that Windows must supportpy
(PEP514) and shims are awkward.Fixes #1310
Fixes #1660
Fixes #1168
Test Plan
uv venv
on Windows with no Python installed but the Windows shims activate fails with an error that Python wasn't found rather than invoking the shimuv venv
with a local pyenv environment activate selects that Python version (because it is the first in the path)python.exe
on path and thepython.bat
shim, then the installation takes thepython.exe
(avoid indirection) except if thepython.exe
doesn't satisfy the requested version.uv venv
picks up the different python versions (including pyenv)