mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-14 00:35:00 +00:00
Allow discovering virtual environments from the first interpreter found on the PATH
(#11218)
Closes https://github.com/astral-sh/uv/issues/11214 Special-cases the first Python executable we find on the `PATH`, allowing it to be considered during searches for virtual environments. For some context, there are two stages to Python interpreter discovery 1. We find possible Python executables in various sources 2. We query the executables to determine canonical metadata about the interpreter We can't really be "sure" if an executable is a complaint virtual environment during (1), we need to query the interpreter first. This means that if you're only allowed to installed into virtual environments, we'll query every interpreter on your PATH. This is not performant, and causes confusion for users. Notably, I recently improved error messaging when we can't find any valid interpreters, by showing the error message we encounter while querying an interpreter (if any). However, this is problematic when there's an error for an interpreter that is not relevant to your search. In https://github.com/astral-sh/uv/pull/11143, I added filtering to avoid querying additional interpreters, but that regressed some user experiences where they were relying on us finding implicitly active virtual environments via the PATH.
This commit is contained in:
parent
04374b03cc
commit
ec480bd3ee
4 changed files with 124 additions and 11 deletions
|
@ -507,7 +507,7 @@ mod tests {
|
|||
matches!(
|
||||
interpreter,
|
||||
PythonInstallation {
|
||||
source: PythonSource::SearchPath,
|
||||
source: PythonSource::SearchPathFirst,
|
||||
interpreter: _
|
||||
}
|
||||
),
|
||||
|
@ -936,7 +936,7 @@ mod tests {
|
|||
matches!(
|
||||
python,
|
||||
PythonInstallation {
|
||||
source: PythonSource::SearchPath,
|
||||
source: PythonSource::SearchPathFirst,
|
||||
interpreter: _
|
||||
}
|
||||
),
|
||||
|
@ -2427,7 +2427,7 @@ mod tests {
|
|||
matches!(
|
||||
python,
|
||||
PythonInstallation {
|
||||
source: PythonSource::SearchPath,
|
||||
source: PythonSource::SearchPathFirst,
|
||||
interpreter: _
|
||||
}
|
||||
),
|
||||
|
@ -2479,7 +2479,7 @@ mod tests {
|
|||
matches!(
|
||||
python,
|
||||
PythonInstallation {
|
||||
source: PythonSource::SearchPath,
|
||||
source: PythonSource::SearchPathFirst,
|
||||
interpreter: _
|
||||
}
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue