diff --git a/crates/uv-python/src/installation.rs b/crates/uv-python/src/installation.rs index c30334983..096c1f679 100644 --- a/crates/uv-python/src/installation.rs +++ b/crates/uv-python/src/installation.rs @@ -78,7 +78,7 @@ impl PythonInstallation { /// /// Unlike [`PythonInstallation::find`], if the required Python is not installed it will be installed automatically. pub async fn find_or_download<'a>( - request: Option, + request: Option<&PythonRequest>, environments: EnvironmentPreference, preference: PythonPreference, python_downloads: PythonDownloads, @@ -86,10 +86,10 @@ impl PythonInstallation { cache: &Cache, reporter: Option<&dyn Reporter>, ) -> Result { - let request = request.unwrap_or_default(); + let request = request.unwrap_or_else(|| &PythonRequest::Any); // Search for the installation - match Self::find(&request, environments, preference, cache) { + match Self::find(request, environments, preference, cache) { Ok(venv) => Ok(venv), // If missing and allowed, perform a fetch Err(Error::MissingPython(err)) @@ -97,7 +97,7 @@ impl PythonInstallation { && python_downloads.is_automatic() && client_builder.connectivity.is_online() => { - if let Some(request) = PythonDownloadRequest::from_request(&request) { + if let Some(request) = PythonDownloadRequest::from_request(request) { debug!("Requested Python not found, checking for available download..."); match Self::fetch(request.fill()?, client_builder, cache, reporter).await { Ok(installation) => Ok(installation), diff --git a/crates/uv/src/commands/project/add.rs b/crates/uv/src/commands/project/add.rs index 984714295..180f2dd48 100644 --- a/crates/uv/src/commands/project/add.rs +++ b/crates/uv/src/commands/project/add.rs @@ -138,7 +138,7 @@ pub(crate) async fn add( }; let interpreter = PythonInstallation::find_or_download( - Some(python_request), + Some(&python_request), EnvironmentPreference::Any, python_preference, python_downloads, @@ -175,7 +175,7 @@ pub(crate) async fn add( }; let interpreter = PythonInstallation::find_or_download( - python_request, + python_request.as_ref(), EnvironmentPreference::Any, python_preference, python_downloads, diff --git a/crates/uv/src/commands/project/init.rs b/crates/uv/src/commands/project/init.rs index 659049248..f8fe7f8de 100644 --- a/crates/uv/src/commands/project/init.rs +++ b/crates/uv/src/commands/project/init.rs @@ -204,7 +204,7 @@ async fn init_project( .connectivity(connectivity) .native_tls(native_tls); let interpreter = PythonInstallation::find_or_download( - Some(request), + Some(&request), EnvironmentPreference::Any, python_preference, python_downloads, @@ -231,7 +231,7 @@ async fn init_project( .connectivity(connectivity) .native_tls(native_tls); let interpreter = PythonInstallation::find_or_download( - Some(request), + Some(&request), EnvironmentPreference::Any, python_preference, python_downloads, diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index 15285063f..8e92b18f2 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -268,7 +268,7 @@ impl FoundInterpreter { // Locate the Python interpreter to use in the environment let python = PythonInstallation::find_or_download( - python_request, + python_request.as_ref(), EnvironmentPreference::OnlySystem, python_preference, python_downloads, diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index 790cce6af..8f8cb7185 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -123,7 +123,7 @@ pub(crate) async fn run( .native_tls(native_tls); let interpreter = PythonInstallation::find_or_download( - python_request, + python_request.as_ref(), EnvironmentPreference::Any, python_preference, python_downloads, @@ -351,7 +351,7 @@ pub(crate) async fn run( .await?; PythonInstallation::find_or_download( - python_request, + python_request.as_ref(), EnvironmentPreference::Any, python_preference, python_downloads, @@ -464,7 +464,7 @@ pub(crate) async fn run( }; let python = PythonInstallation::find_or_download( - python_request, + python_request.as_ref(), // No opt-in is required for system environments, since we are not mutating it. EnvironmentPreference::Any, python_preference, diff --git a/crates/uv/src/commands/tool/install.rs b/crates/uv/src/commands/tool/install.rs index ace541728..eef29cea3 100644 --- a/crates/uv/src/commands/tool/install.rs +++ b/crates/uv/src/commands/tool/install.rs @@ -61,7 +61,7 @@ pub(crate) async fn install( // Pre-emptively identify a Python interpreter. We need an interpreter to resolve any unnamed // requirements, even if we end up using a different interpreter for the tool install itself. let interpreter = PythonInstallation::find_or_download( - python_request.clone(), + python_request.as_ref(), EnvironmentPreference::OnlySystem, python_preference, python_downloads, diff --git a/crates/uv/src/commands/tool/run.rs b/crates/uv/src/commands/tool/run.rs index 4500f0412..55d904238 100644 --- a/crates/uv/src/commands/tool/run.rs +++ b/crates/uv/src/commands/tool/run.rs @@ -324,7 +324,7 @@ async fn get_or_create_environment( // Discover an interpreter. let interpreter = PythonInstallation::find_or_download( - python_request.clone(), + python_request.as_ref(), EnvironmentPreference::OnlySystem, python_preference, python_downloads, diff --git a/crates/uv/src/commands/venv.rs b/crates/uv/src/commands/venv.rs index eb4d57341..e5024d7ea 100644 --- a/crates/uv/src/commands/venv.rs +++ b/crates/uv/src/commands/venv.rs @@ -183,7 +183,7 @@ async fn venv_impl( // Locate the Python interpreter to use in the environment let python = PythonInstallation::find_or_download( - interpreter_request, + interpreter_request.as_ref(), EnvironmentPreference::OnlySystem, python_preference, python_downloads,