mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Avoid debug error for uv run
with unknown Python version (#4913)
## Summary Closes https://github.com/astral-sh/uv/issues/4848. ## Test Plan ``` > cargo run -- run -vv --preview --isolated --python 3.12.4 python -V error: No interpreter found for Python 3.12.4 in virtual environments or managed installations or system path ```
This commit is contained in:
parent
ed4234d52e
commit
f862457f05
1 changed files with 12 additions and 4 deletions
|
@ -14,7 +14,9 @@ use crate::downloads::{DownloadResult, ManagedPythonDownload, PythonDownloadRequ
|
|||
use crate::implementation::LenientImplementationName;
|
||||
use crate::managed::{ManagedPythonInstallation, ManagedPythonInstallations};
|
||||
use crate::platform::{Arch, Libc, Os};
|
||||
use crate::{Error, Interpreter, PythonFetch, PythonPreference, PythonSource, PythonVersion};
|
||||
use crate::{
|
||||
downloads, Error, Interpreter, PythonFetch, PythonPreference, PythonSource, PythonVersion,
|
||||
};
|
||||
|
||||
/// A Python interpreter and accompanying tools.
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -97,16 +99,22 @@ impl PythonInstallation {
|
|||
match Self::find(&request, environments, preference, cache) {
|
||||
Ok(venv) => Ok(venv),
|
||||
// If missing and allowed, perform a fetch
|
||||
err @ Err(Error::MissingPython(_))
|
||||
Err(Error::MissingPython(err))
|
||||
if preference.allows_managed()
|
||||
&& python_fetch.is_automatic()
|
||||
&& client_builder.connectivity.is_online() =>
|
||||
{
|
||||
if let Some(request) = PythonDownloadRequest::try_from_request(&request) {
|
||||
debug!("Requested Python not found, checking for available download...");
|
||||
Self::fetch(request.fill(), client_builder, cache, reporter).await
|
||||
match Self::fetch(request.fill(), client_builder, cache, reporter).await {
|
||||
Ok(installation) => Ok(installation),
|
||||
Err(Error::Download(downloads::Error::NoDownloadFound(_))) => {
|
||||
Err(Error::MissingPython(err))
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
} else {
|
||||
err
|
||||
Err(Error::MissingPython(err))
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue