Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions crates/uv-interpreter/src/virtualenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,19 @@ pub(crate) fn virtualenv_python_executable(venv: impl AsRef<Path>) -> PathBuf {
// If none of these exist, return the standard location
default_executable
} else {
// Search for `python` in the `bin` directory.
venv.join("bin").join("python")
// Check for both `python3` over `python`, preferring the more specific one
let default_executable = venv.join("bin").join("python3");
if default_executable.exists() {
return default_executable;
}

let executable = venv.join("bin").join("python");
if executable.exists() {
return executable;
}

// If none of these exist, return the standard location
default_executable
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn missing_venv() -> Result<()> {

----- stderr -----
warning: Requirements file requirements.in does not contain any dependencies
error: failed to canonicalize path `[VENV]/bin/python`
error: failed to canonicalize path `[VENV]/bin/python3`
Caused by: No such file or directory (os error 2)
"###
);
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/pip_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn missing_venv() -> Result<()> {
----- stdout -----

----- stderr -----
error: failed to canonicalize path `[VENV]/bin/python`
error: failed to canonicalize path `[VENV]/bin/python3`
Caused by: No such file or directory (os error 2)
"###);
}
Expand Down