From 8da8b0d039fe53b19e504697782dedd006721c8f Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 8 Aug 2024 16:29:33 -0500 Subject: [PATCH] Update the interface for declaring Python download preferences --- crates/uv-cli/src/lib.rs | 16 +- crates/uv-python/src/discovery.rs | 21 +- crates/uv-python/src/installation.rs | 8 +- crates/uv-python/src/lib.rs | 2 +- crates/uv-settings/src/combine.rs | 4 +- crates/uv-settings/src/settings.rs | 8 +- crates/uv/src/commands/project/add.rs | 6 +- crates/uv/src/commands/project/init.rs | 16 +- crates/uv/src/commands/project/lock.rs | 6 +- crates/uv/src/commands/project/mod.rs | 14 +- crates/uv/src/commands/project/remove.rs | 6 +- crates/uv/src/commands/project/run.rs | 24 +- crates/uv/src/commands/project/sync.rs | 6 +- crates/uv/src/commands/project/tree.rs | 6 +- crates/uv/src/commands/python/install.rs | 12 +- crates/uv/src/commands/python/list.rs | 6 +- crates/uv/src/commands/tool/install.rs | 8 +- crates/uv/src/commands/tool/run.rs | 14 +- crates/uv/src/commands/venv.rs | 12 +- crates/uv/src/lib.rs | 23 +- crates/uv/src/settings.rs | 10 +- crates/uv/tests/help.rs | 55 ++-- crates/uv/tests/lock.rs | 2 +- crates/uv/tests/show_settings.rs | 44 +-- docs/concepts/python-versions.md | 4 +- docs/reference/cli.md | 389 +++++------------------ docs/reference/settings.md | 13 +- uv.schema.json | 19 +- 28 files changed, 266 insertions(+), 488 deletions(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index 142ff4bea933..c874c7f39c4b 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -15,7 +15,7 @@ use uv_configuration::{ ConfigSettingEntry, IndexStrategy, KeyringProviderType, PackageNameSpecifier, TargetTriple, }; use uv_normalize::{ExtraName, PackageName}; -use uv_python::{PythonFetch, PythonPreference, PythonVersion}; +use uv_python::{PythonDownloads, PythonPreference, PythonVersion}; use uv_resolver::{AnnotationStyle, ExcludeNewer, PrereleaseMode, ResolutionMode}; pub mod compat; @@ -119,9 +119,17 @@ pub struct GlobalArgs { )] pub python_preference: Option, - /// Whether to automatically download Python when required. + /// Allow automatically downloading Python when required. + #[arg(global = true, long, help_heading = "Python options", hide = true)] + pub allow_python_downloads: bool, + + /// Disable automatic downloads of Python. #[arg(global = true, long, help_heading = "Python options")] - pub python_fetch: Option, + pub no_python_downloads: bool, + + /// Deprecated version of [`Self::python_downloads`]. + #[arg(global = true, long, hide = true)] + pub python_fetch: Option, /// Do not print any output. #[arg(global = true, long, short, conflicts_with = "verbose")] @@ -258,7 +266,7 @@ pub enum Commands { /// /// When preview is enabled, i.e., via `--preview` or by using a preview /// command, uv will download Python if a version cannot be found. This - /// behavior can be disabled with the `--python-fetch` option. + /// behavior can be disabled with the `--python-downloads` option. /// /// The `--python` option allows requesting a different interpreter. /// diff --git a/crates/uv-python/src/discovery.rs b/crates/uv-python/src/discovery.rs index b2ace2f59e6e..ae4e414cb8b3 100644 --- a/crates/uv-python/src/discovery.rs +++ b/crates/uv-python/src/discovery.rs @@ -79,12 +79,25 @@ pub enum PythonPreference { #[serde(deny_unknown_fields, rename_all = "kebab-case")] #[cfg_attr(feature = "clap", derive(clap::ValueEnum))] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -pub enum PythonFetch { - /// Automatically fetch managed Python installations when needed. +pub enum PythonDownloads { + /// Automatically download managed Python installations when needed. #[default] + #[serde(alias = "auto")] Automatic, - /// Do not automatically fetch managed Python installations; require explicit installation. + /// Do not automatically download managed Python installations; require explicit installation. Manual, + /// Do not ever allow Python downloads. + Never, +} + +impl From for PythonDownloads { + fn from(value: bool) -> Self { + if value { + PythonDownloads::Automatic + } else { + PythonDownloads::Never + } + } } #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] @@ -1298,7 +1311,7 @@ impl PythonPreference { } } -impl PythonFetch { +impl PythonDownloads { pub fn is_automatic(self) -> bool { matches!(self, Self::Automatic) } diff --git a/crates/uv-python/src/installation.rs b/crates/uv-python/src/installation.rs index 5885c06c0532..3d4ffb3dcee1 100644 --- a/crates/uv-python/src/installation.rs +++ b/crates/uv-python/src/installation.rs @@ -15,7 +15,7 @@ use crate::implementation::LenientImplementationName; use crate::managed::{ManagedPythonInstallation, ManagedPythonInstallations}; use crate::platform::{Arch, Libc, Os}; use crate::{ - downloads, Error, Interpreter, PythonFetch, PythonPreference, PythonSource, PythonVersion, + downloads, Error, Interpreter, PythonDownloads, PythonPreference, PythonSource, PythonVersion, }; /// A Python interpreter and accompanying tools. @@ -77,11 +77,11 @@ impl PythonInstallation { /// Find or fetch a [`PythonInstallation`]. /// /// Unlike [`PythonInstallation::find`], if the required Python is not installed it will be installed automatically. - pub async fn find_or_fetch<'a>( + pub async fn find_or_download<'a>( request: Option, environments: EnvironmentPreference, preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, client_builder: &BaseClientBuilder<'a>, cache: &Cache, reporter: Option<&dyn Reporter>, @@ -94,7 +94,7 @@ impl PythonInstallation { // If missing and allowed, perform a fetch Err(Error::MissingPython(err)) if preference.allows_managed() - && python_fetch.is_automatic() + && python_downloads.is_automatic() && client_builder.connectivity.is_online() => { if let Some(request) = PythonDownloadRequest::from_request(&request) { diff --git a/crates/uv-python/src/lib.rs b/crates/uv-python/src/lib.rs index dba4de22ee7a..3f687552c0d7 100644 --- a/crates/uv-python/src/lib.rs +++ b/crates/uv-python/src/lib.rs @@ -2,7 +2,7 @@ use thiserror::Error; pub use crate::discovery::{ - find_python_installations, EnvironmentPreference, Error as DiscoveryError, PythonFetch, + find_python_installations, EnvironmentPreference, Error as DiscoveryError, PythonDownloads, PythonNotFound, PythonPreference, PythonRequest, PythonSource, VersionRequest, }; pub use crate::environment::PythonEnvironment; diff --git a/crates/uv-settings/src/combine.rs b/crates/uv-settings/src/combine.rs index 4690684b5c27..32ed63befb52 100644 --- a/crates/uv-settings/src/combine.rs +++ b/crates/uv-settings/src/combine.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use distribution_types::IndexUrl; use install_wheel_rs::linker::LinkMode; use uv_configuration::{ConfigSettings, IndexStrategy, KeyringProviderType, TargetTriple}; -use uv_python::{PythonFetch, PythonPreference, PythonVersion}; +use uv_python::{PythonDownloads, PythonPreference, PythonVersion}; use uv_resolver::{AnnotationStyle, ExcludeNewer, PrereleaseMode, ResolutionMode}; use crate::{FilesystemOptions, PipOptions}; @@ -70,7 +70,7 @@ impl_combine_or!(ResolutionMode); impl_combine_or!(String); impl_combine_or!(TargetTriple); impl_combine_or!(PythonPreference); -impl_combine_or!(PythonFetch); +impl_combine_or!(PythonDownloads); impl_combine_or!(bool); impl Combine for Option> { diff --git a/crates/uv-settings/src/settings.rs b/crates/uv-settings/src/settings.rs index e5b29ae27d90..8332ff3c975f 100644 --- a/crates/uv-settings/src/settings.rs +++ b/crates/uv-settings/src/settings.rs @@ -11,7 +11,7 @@ use uv_configuration::{ }; use uv_macros::{CombineOptions, OptionsMetadata}; use uv_normalize::{ExtraName, PackageName}; -use uv_python::{PythonFetch, PythonPreference, PythonVersion}; +use uv_python::{PythonDownloads, PythonPreference, PythonVersion}; use uv_resolver::{AnnotationStyle, ExcludeNewer, PrereleaseMode, ResolutionMode}; /// A `pyproject.toml` with an (optional) `[tool.uv]` section. @@ -143,16 +143,16 @@ pub struct GlobalOptions { possible_values = true )] pub python_preference: Option, - /// Whether to automatically download Python when required. + /// Whether to allow Python downloads. #[option( default = "\"automatic\"", value_type = "str", example = r#" - python-fetch = "manual" + python-downloads = "manual" "#, possible_values = true )] - pub python_fetch: Option, + pub python_downloads: Option, } /// Settings relevant to all installer operations. diff --git a/crates/uv/src/commands/project/add.rs b/crates/uv/src/commands/project/add.rs index 176f98adeadd..727d61f70b08 100644 --- a/crates/uv/src/commands/project/add.rs +++ b/crates/uv/src/commands/project/add.rs @@ -15,7 +15,7 @@ use uv_dispatch::BuildDispatch; use uv_distribution::DistributionDatabase; use uv_fs::CWD; use uv_normalize::PackageName; -use uv_python::{PythonFetch, PythonPreference, PythonRequest}; +use uv_python::{PythonDownloads, PythonPreference, PythonRequest}; use uv_requirements::{NamedRequirementsResolver, RequirementsSource, RequirementsSpecification}; use uv_resolver::FlatIndex; use uv_types::{BuildIsolation, HashStrategy}; @@ -51,7 +51,7 @@ pub(crate) async fn add( python: Option, settings: ResolverInstallerSettings, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, preview: PreviewMode, connectivity: Connectivity, concurrency: Concurrency, @@ -93,7 +93,7 @@ pub(crate) async fn add( project.workspace(), python.as_deref().map(PythonRequest::parse), python_preference, - python_fetch, + python_downloads, connectivity, native_tls, cache, diff --git a/crates/uv/src/commands/project/init.rs b/crates/uv/src/commands/project/init.rs index c5d896b384b1..1bd4099950ad 100644 --- a/crates/uv/src/commands/project/init.rs +++ b/crates/uv/src/commands/project/init.rs @@ -11,7 +11,7 @@ use uv_client::{BaseClientBuilder, Connectivity}; use uv_configuration::PreviewMode; use uv_fs::{absolutize_path, Simplified, CWD}; use uv_python::{ - EnvironmentPreference, PythonFetch, PythonInstallation, PythonPreference, PythonRequest, + EnvironmentPreference, PythonDownloads, PythonInstallation, PythonPreference, PythonRequest, VersionRequest, }; use uv_resolver::RequiresPython; @@ -35,7 +35,7 @@ pub(crate) async fn init( no_workspace: bool, preview: PreviewMode, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, connectivity: Connectivity, native_tls: bool, cache: &Cache, @@ -86,7 +86,7 @@ pub(crate) async fn init( python, no_workspace, python_preference, - python_fetch, + python_downloads, connectivity, native_tls, cache, @@ -160,7 +160,7 @@ async fn init_project( python: Option, no_workspace: bool, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, connectivity: Connectivity, native_tls: bool, cache: &Cache, @@ -213,11 +213,11 @@ async fn init_project( let client_builder = BaseClientBuilder::new() .connectivity(connectivity) .native_tls(native_tls); - let interpreter = PythonInstallation::find_or_fetch( + let interpreter = PythonInstallation::find_or_download( Some(request), EnvironmentPreference::Any, python_preference, - python_fetch, + python_downloads, &client_builder, cache, Some(&reporter), @@ -240,11 +240,11 @@ async fn init_project( let client_builder = BaseClientBuilder::new() .connectivity(connectivity) .native_tls(native_tls); - let interpreter = PythonInstallation::find_or_fetch( + let interpreter = PythonInstallation::find_or_download( Some(request), EnvironmentPreference::Any, python_preference, - python_fetch, + python_downloads, &client_builder, cache, Some(&reporter), diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index 9efcde1809be..aae3f5e09851 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -18,7 +18,7 @@ use uv_dispatch::BuildDispatch; use uv_fs::CWD; use uv_git::ResolvedRepositoryReference; use uv_normalize::{PackageName, DEV_DEPENDENCIES}; -use uv_python::{Interpreter, PythonEnvironment, PythonFetch, PythonPreference, PythonRequest}; +use uv_python::{Interpreter, PythonDownloads, PythonEnvironment, PythonPreference, PythonRequest}; use uv_requirements::upgrade::{read_lock_requirements, LockedRequirements}; use uv_resolver::{ FlatIndex, Lock, OptionsBuilder, PythonRequirement, RequiresPython, ResolverMarkers, @@ -50,7 +50,7 @@ pub(crate) async fn lock( settings: ResolverSettings, preview: PreviewMode, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, connectivity: Connectivity, concurrency: Concurrency, native_tls: bool, @@ -69,7 +69,7 @@ pub(crate) async fn lock( &workspace, python.as_deref().map(PythonRequest::parse), python_preference, - python_fetch, + python_downloads, connectivity, native_tls, cache, diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index 3abf6acf4f20..dd2c1c2929bc 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -20,8 +20,8 @@ use uv_fs::Simplified; use uv_installer::{SatisfiesResult, SitePackages}; use uv_normalize::PackageName; use uv_python::{ - request_from_version_file, EnvironmentPreference, Interpreter, PythonEnvironment, PythonFetch, - PythonInstallation, PythonPreference, PythonRequest, VersionRequest, + request_from_version_file, EnvironmentPreference, Interpreter, PythonDownloads, + PythonEnvironment, PythonInstallation, PythonPreference, PythonRequest, VersionRequest, }; use uv_requirements::{NamedRequirementsResolver, RequirementsSpecification}; use uv_resolver::{ @@ -202,7 +202,7 @@ impl FoundInterpreter { workspace: &Workspace, python_request: Option, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, connectivity: Connectivity, native_tls: bool, cache: &Cache, @@ -251,11 +251,11 @@ impl FoundInterpreter { let reporter = PythonDownloadReporter::single(printer); // Locate the Python interpreter to use in the environment - let python = PythonInstallation::find_or_fetch( + let python = PythonInstallation::find_or_download( python_request, EnvironmentPreference::OnlySystem, python_preference, - python_fetch, + python_downloads, &client_builder, cache, Some(&reporter), @@ -329,7 +329,7 @@ pub(crate) async fn get_or_init_environment( workspace: &Workspace, python: Option, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, connectivity: Connectivity, native_tls: bool, cache: &Cache, @@ -339,7 +339,7 @@ pub(crate) async fn get_or_init_environment( workspace, python, python_preference, - python_fetch, + python_downloads, connectivity, native_tls, cache, diff --git a/crates/uv/src/commands/project/remove.rs b/crates/uv/src/commands/project/remove.rs index 7de655f1b09b..c0129ec6ec76 100644 --- a/crates/uv/src/commands/project/remove.rs +++ b/crates/uv/src/commands/project/remove.rs @@ -5,7 +5,7 @@ use uv_cache::Cache; use uv_client::Connectivity; use uv_configuration::{Concurrency, ExtrasSpecification, PreviewMode}; use uv_fs::CWD; -use uv_python::{PythonFetch, PythonPreference, PythonRequest}; +use uv_python::{PythonDownloads, PythonPreference, PythonRequest}; use uv_warnings::{warn_user, warn_user_once}; use uv_workspace::pyproject::DependencyType; use uv_workspace::pyproject_mut::PyProjectTomlMut; @@ -29,7 +29,7 @@ pub(crate) async fn remove( python: Option, settings: ResolverInstallerSettings, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, preview: PreviewMode, connectivity: Connectivity, concurrency: Concurrency, @@ -101,7 +101,7 @@ pub(crate) async fn remove( project.workspace(), python.as_deref().map(PythonRequest::parse), python_preference, - python_fetch, + python_downloads, connectivity, native_tls, cache, diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index ed7fd1bccae3..96208d7517b7 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -18,8 +18,8 @@ use uv_fs::{PythonExt, Simplified, CWD}; use uv_installer::{SatisfiesResult, SitePackages}; use uv_normalize::PackageName; use uv_python::{ - request_from_version_file, EnvironmentPreference, Interpreter, PythonEnvironment, PythonFetch, - PythonInstallation, PythonPreference, PythonRequest, VersionRequest, + request_from_version_file, EnvironmentPreference, Interpreter, PythonDownloads, + PythonEnvironment, PythonInstallation, PythonPreference, PythonRequest, VersionRequest, }; use uv_requirements::{RequirementsSource, RequirementsSpecification}; use uv_warnings::warn_user_once; @@ -53,7 +53,7 @@ pub(crate) async fn run( settings: ResolverInstallerSettings, preview: PreviewMode, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, connectivity: Connectivity, concurrency: Concurrency, native_tls: bool, @@ -122,11 +122,11 @@ pub(crate) async fn run( .connectivity(connectivity) .native_tls(native_tls); - let interpreter = PythonInstallation::find_or_fetch( + let interpreter = PythonInstallation::find_or_download( python_request, EnvironmentPreference::Any, python_preference, - python_fetch, + python_downloads, &client_builder, cache, Some(&download_reporter), @@ -240,11 +240,11 @@ pub(crate) async fn run( .await?; // Note we force preview on during `uv run` for now since the entire interface is in preview. - PythonInstallation::find_or_fetch( + PythonInstallation::find_or_download( python_request, EnvironmentPreference::Any, python_preference, - python_fetch, + python_downloads, &client_builder, cache, Some(&download_reporter), @@ -270,7 +270,7 @@ pub(crate) async fn run( project.workspace(), python.as_deref().map(PythonRequest::parse), python_preference, - python_fetch, + python_downloads, connectivity, native_tls, cache, @@ -342,12 +342,12 @@ pub(crate) async fn run( .connectivity(connectivity) .native_tls(native_tls); - let python = PythonInstallation::find_or_fetch( + let python = PythonInstallation::find_or_download( python.as_deref().map(PythonRequest::parse), // No opt-in is required for system environments, since we are not mutating it. EnvironmentPreference::Any, python_preference, - python_fetch, + python_downloads, &client_builder, cache, Some(&download_reporter), @@ -460,11 +460,11 @@ pub(crate) async fn run( .native_tls(native_tls); // Note we force preview on during `uv run` for now since the entire interface is in preview - PythonInstallation::find_or_fetch( + PythonInstallation::find_or_download( python.as_deref().map(PythonRequest::parse), EnvironmentPreference::Any, python_preference, - python_fetch, + python_downloads, &client_builder, cache, Some(&download_reporter), diff --git a/crates/uv/src/commands/project/sync.rs b/crates/uv/src/commands/project/sync.rs index 0c35a29f8b8d..4f92f92d89c0 100644 --- a/crates/uv/src/commands/project/sync.rs +++ b/crates/uv/src/commands/project/sync.rs @@ -10,7 +10,7 @@ use uv_dispatch::BuildDispatch; use uv_fs::CWD; use uv_installer::SitePackages; use uv_normalize::{PackageName, DEV_DEPENDENCIES}; -use uv_python::{PythonEnvironment, PythonFetch, PythonPreference, PythonRequest}; +use uv_python::{PythonDownloads, PythonEnvironment, PythonPreference, PythonRequest}; use uv_resolver::{FlatIndex, Lock}; use uv_types::{BuildIsolation, HashStrategy}; use uv_warnings::warn_user_once; @@ -35,7 +35,7 @@ pub(crate) async fn sync( modifications: Modifications, python: Option, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, settings: ResolverInstallerSettings, preview: PreviewMode, connectivity: Connectivity, @@ -65,7 +65,7 @@ pub(crate) async fn sync( project.workspace(), python.as_deref().map(PythonRequest::parse), python_preference, - python_fetch, + python_downloads, connectivity, native_tls, cache, diff --git a/crates/uv/src/commands/project/tree.rs b/crates/uv/src/commands/project/tree.rs index 9fcf892b0be1..61b54d8b98e7 100644 --- a/crates/uv/src/commands/project/tree.rs +++ b/crates/uv/src/commands/project/tree.rs @@ -8,7 +8,7 @@ use uv_cache::Cache; use uv_client::Connectivity; use uv_configuration::{Concurrency, PreviewMode, TargetTriple}; use uv_fs::CWD; -use uv_python::{PythonFetch, PythonPreference, PythonRequest, PythonVersion}; +use uv_python::{PythonDownloads, PythonPreference, PythonRequest, PythonVersion}; use uv_resolver::TreeDisplay; use uv_warnings::warn_user_once; use uv_workspace::{DiscoveryOptions, Workspace}; @@ -35,7 +35,7 @@ pub(crate) async fn tree( python: Option, settings: ResolverSettings, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, preview: PreviewMode, connectivity: Connectivity, concurrency: Concurrency, @@ -55,7 +55,7 @@ pub(crate) async fn tree( &workspace, python.as_deref().map(PythonRequest::parse), python_preference, - python_fetch, + python_downloads, connectivity, native_tls, cache, diff --git a/crates/uv/src/commands/python/install.rs b/crates/uv/src/commands/python/install.rs index 7d71a22458ec..d7f2b7db22b3 100644 --- a/crates/uv/src/commands/python/install.rs +++ b/crates/uv/src/commands/python/install.rs @@ -15,7 +15,8 @@ use uv_fs::CWD; use uv_python::downloads::{DownloadResult, ManagedPythonDownload, PythonDownloadRequest}; use uv_python::managed::{ManagedPythonInstallation, ManagedPythonInstallations}; use uv_python::{ - requests_from_version_file, PythonRequest, PYTHON_VERSIONS_FILENAME, PYTHON_VERSION_FILENAME, + requests_from_version_file, PythonDownloads, PythonRequest, PYTHON_VERSIONS_FILENAME, + PYTHON_VERSION_FILENAME, }; use uv_warnings::warn_user_once; @@ -28,6 +29,7 @@ use crate::printer::Printer; pub(crate) async fn install( targets: Vec, reinstall: bool, + python_downloads: PythonDownloads, native_tls: bool, connectivity: Connectivity, preview: PreviewMode, @@ -124,6 +126,14 @@ pub(crate) async fn install( return Ok(ExitStatus::Success); } + if matches!(python_downloads, PythonDownloads::Never) { + writeln!( + printer.stderr(), + "Python downloads are not allowed (`python-downloads = \"never\"`). Change to `python-downloads = \"manual\"` to allow explicit installs.", + )?; + return Ok(ExitStatus::Failure); + } + let downloads = unfilled_requests .into_iter() // Populate the download requests with defaults diff --git a/crates/uv/src/commands/python/list.rs b/crates/uv/src/commands/python/list.rs index 7decad091e18..f65b91bced31 100644 --- a/crates/uv/src/commands/python/list.rs +++ b/crates/uv/src/commands/python/list.rs @@ -9,7 +9,7 @@ use uv_configuration::PreviewMode; use uv_fs::Simplified; use uv_python::downloads::PythonDownloadRequest; use uv_python::{ - find_python_installations, DiscoveryError, EnvironmentPreference, PythonFetch, + find_python_installations, DiscoveryError, EnvironmentPreference, PythonDownloads, PythonInstallation, PythonNotFound, PythonPreference, PythonRequest, PythonSource, }; use uv_warnings::warn_user_once; @@ -32,7 +32,7 @@ pub(crate) async fn list( all_versions: bool, all_platforms: bool, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, preview: PreviewMode, cache: &Cache, printer: Printer, @@ -46,7 +46,7 @@ pub(crate) async fn list( let download_request = match kinds { PythonListKinds::Installed => None, PythonListKinds::Default => { - if python_fetch.is_automatic() { + if python_downloads.is_automatic() { Some(if all_platforms { PythonDownloadRequest::default() } else { diff --git a/crates/uv/src/commands/tool/install.rs b/crates/uv/src/commands/tool/install.rs index ffe9634286ce..d389e291a08c 100644 --- a/crates/uv/src/commands/tool/install.rs +++ b/crates/uv/src/commands/tool/install.rs @@ -11,7 +11,7 @@ use uv_client::{BaseClientBuilder, Connectivity}; use uv_configuration::{Concurrency, PreviewMode}; use uv_normalize::PackageName; use uv_python::{ - EnvironmentPreference, PythonFetch, PythonInstallation, PythonPreference, PythonRequest, + EnvironmentPreference, PythonDownloads, PythonInstallation, PythonPreference, PythonRequest, }; use uv_requirements::{RequirementsSource, RequirementsSpecification}; use uv_tool::InstalledTools; @@ -40,7 +40,7 @@ pub(crate) async fn install( settings: ResolverInstallerSettings, preview: PreviewMode, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, connectivity: Connectivity, concurrency: Concurrency, native_tls: bool, @@ -61,11 +61,11 @@ 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_fetch( + let interpreter = PythonInstallation::find_or_download( python_request.clone(), EnvironmentPreference::OnlySystem, python_preference, - python_fetch, + python_downloads, &client_builder, cache, Some(&reporter), diff --git a/crates/uv/src/commands/tool/run.rs b/crates/uv/src/commands/tool/run.rs index a44f8d1b808f..1ad01a94ec0c 100644 --- a/crates/uv/src/commands/tool/run.rs +++ b/crates/uv/src/commands/tool/run.rs @@ -20,8 +20,8 @@ use uv_configuration::{Concurrency, PreviewMode}; use uv_installer::{SatisfiesResult, SitePackages}; use uv_normalize::PackageName; use uv_python::{ - EnvironmentPreference, PythonEnvironment, PythonFetch, PythonInstallation, PythonPreference, - PythonRequest, + EnvironmentPreference, PythonDownloads, PythonEnvironment, PythonInstallation, + PythonPreference, PythonRequest, }; use uv_requirements::{RequirementsSource, RequirementsSpecification}; use uv_tool::{entrypoint_paths, InstalledTools}; @@ -70,7 +70,7 @@ pub(crate) async fn run( isolated: bool, preview: PreviewMode, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, connectivity: Connectivity, concurrency: Concurrency, native_tls: bool, @@ -107,7 +107,7 @@ pub(crate) async fn run( isolated, preview, python_preference, - python_fetch, + python_downloads, connectivity, concurrency, native_tls, @@ -293,7 +293,7 @@ async fn get_or_create_environment( isolated: bool, preview: PreviewMode, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, connectivity: Connectivity, concurrency: Concurrency, native_tls: bool, @@ -309,11 +309,11 @@ async fn get_or_create_environment( let python_request = python.map(PythonRequest::parse); // Discover an interpreter. - let interpreter = PythonInstallation::find_or_fetch( + let interpreter = PythonInstallation::find_or_download( python_request.clone(), EnvironmentPreference::OnlySystem, python_preference, - python_fetch, + python_downloads, &client_builder, cache, Some(&reporter), diff --git a/crates/uv/src/commands/venv.rs b/crates/uv/src/commands/venv.rs index 23397ef24743..df2a7f77b6e7 100644 --- a/crates/uv/src/commands/venv.rs +++ b/crates/uv/src/commands/venv.rs @@ -22,7 +22,7 @@ use uv_configuration::{ use uv_dispatch::BuildDispatch; use uv_fs::{Simplified, CWD}; use uv_python::{ - request_from_version_file, EnvironmentPreference, PythonFetch, PythonInstallation, + request_from_version_file, EnvironmentPreference, PythonDownloads, PythonInstallation, PythonPreference, PythonRequest, VersionRequest, }; use uv_resolver::{ExcludeNewer, FlatIndex, RequiresPython}; @@ -42,7 +42,7 @@ pub(crate) async fn venv( path: &Path, python_request: Option<&str>, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, link_mode: LinkMode, index_locations: &IndexLocations, index_strategy: IndexStrategy, @@ -72,7 +72,7 @@ pub(crate) async fn venv( seed, preview, python_preference, - python_fetch, + python_downloads, allow_existing, exclude_newer, native_tls, @@ -124,7 +124,7 @@ async fn venv_impl( seed: bool, preview: PreviewMode, python_preference: PythonPreference, - python_fetch: PythonFetch, + python_downloads: PythonDownloads, allow_existing: bool, exclude_newer: Option, native_tls: bool, @@ -174,11 +174,11 @@ async fn venv_impl( } // Locate the Python interpreter to use in the environment - let python = PythonInstallation::find_or_fetch( + let python = PythonInstallation::find_or_download( interpreter_request, EnvironmentPreference::OnlySystem, python_preference, - python_fetch, + python_downloads, &client_builder, cache, Some(&reporter), diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index e5f863cf9735..f512a890ad84 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -656,7 +656,7 @@ async fn run(cli: Cli) -> Result { &args.name, args.settings.python.as_deref(), globals.python_preference, - globals.python_fetch, + globals.python_downloads, args.settings.link_mode, &args.settings.index_locations, args.settings.index_strategy, @@ -731,7 +731,7 @@ async fn run(cli: Cli) -> Result { args.isolated, globals.preview, globals.python_preference, - globals.python_fetch, + globals.python_downloads, globals.connectivity, Concurrency::default(), globals.native_tls, @@ -773,7 +773,7 @@ async fn run(cli: Cli) -> Result { args.settings, globals.preview, globals.python_preference, - globals.python_fetch, + globals.python_downloads, globals.connectivity, Concurrency::default(), globals.native_tls, @@ -856,7 +856,7 @@ async fn run(cli: Cli) -> Result { args.all_versions, args.all_platforms, globals.python_preference, - globals.python_fetch, + globals.python_downloads, globals.preview, &cache, printer, @@ -876,6 +876,7 @@ async fn run(cli: Cli) -> Result { commands::python_install( args.targets, args.reinstall, + globals.python_downloads, globals.native_tls, globals.connectivity, globals.preview, @@ -982,7 +983,7 @@ async fn run_project( args.no_workspace, globals.preview, globals.python_preference, - globals.python_fetch, + globals.python_downloads, globals.connectivity, globals.native_tls, &cache, @@ -1026,7 +1027,7 @@ async fn run_project( args.settings, globals.preview, globals.python_preference, - globals.python_fetch, + globals.python_downloads, globals.connectivity, Concurrency::default(), globals.native_tls, @@ -1054,7 +1055,7 @@ async fn run_project( args.modifications, args.python, globals.python_preference, - globals.python_fetch, + globals.python_downloads, args.settings, globals.preview, globals.connectivity, @@ -1080,7 +1081,7 @@ async fn run_project( args.settings, globals.preview, globals.python_preference, - globals.python_fetch, + globals.python_downloads, globals.connectivity, Concurrency::default(), globals.native_tls, @@ -1115,7 +1116,7 @@ async fn run_project( args.python, args.settings, globals.python_preference, - globals.python_fetch, + globals.python_downloads, globals.preview, globals.connectivity, Concurrency::default(), @@ -1145,7 +1146,7 @@ async fn run_project( args.python, args.settings, globals.python_preference, - globals.python_fetch, + globals.python_downloads, globals.preview, globals.connectivity, Concurrency::default(), @@ -1177,7 +1178,7 @@ async fn run_project( args.python, args.resolver, globals.python_preference, - globals.python_fetch, + globals.python_downloads, globals.preview, globals.connectivity, Concurrency::default(), diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index ddc4538a5eef..fde20958ad8f 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -27,7 +27,7 @@ use uv_configuration::{ SourceStrategy, TargetTriple, Upgrade, }; use uv_normalize::PackageName; -use uv_python::{Prefix, PythonFetch, PythonPreference, PythonVersion, Target}; +use uv_python::{Prefix, PythonDownloads, PythonPreference, PythonVersion, Target}; use uv_requirements::RequirementsSource; use uv_resolver::{AnnotationStyle, DependencyMode, ExcludeNewer, PrereleaseMode, ResolutionMode}; use uv_settings::{ @@ -49,7 +49,7 @@ pub(crate) struct GlobalSettings { pub(crate) show_settings: bool, pub(crate) preview: PreviewMode, pub(crate) python_preference: PythonPreference, - pub(crate) python_fetch: PythonFetch, + pub(crate) python_downloads: PythonDownloads, pub(crate) no_progress: bool, } @@ -116,9 +116,9 @@ impl GlobalSettings { .python_preference .combine(workspace.and_then(|workspace| workspace.globals.python_preference)) .unwrap_or(default_python_preference), - python_fetch: args - .python_fetch - .combine(workspace.and_then(|workspace| workspace.globals.python_fetch)) + python_downloads: flag(args.allow_python_downloads, args.no_python_downloads) + .map(PythonDownloads::from) + .combine(workspace.and_then(|workspace| workspace.globals.python_downloads)) .unwrap_or_default(), no_progress: args.no_progress, } diff --git a/crates/uv/tests/help.rs b/crates/uv/tests/help.rs index dd7a6c34b7b5..91976512eaf1 100644 --- a/crates/uv/tests/help.rs +++ b/crates/uv/tests/help.rs @@ -40,9 +40,8 @@ fn help() { --python-preference Whether to prefer uv-managed or system Python installations [possible values: only-managed, managed, system, only-system] - --python-fetch - Whether to automatically download Python when required [possible values: automatic, - manual] + --no-python-downloads + Disable automatic downloads of Python Global options: -q, --quiet Do not print any output @@ -103,9 +102,8 @@ fn help_flag() { --python-preference Whether to prefer uv-managed or system Python installations [possible values: only-managed, managed, system, only-system] - --python-fetch - Whether to automatically download Python when required [possible values: automatic, - manual] + --no-python-downloads + Disable automatic downloads of Python Global options: -q, --quiet Do not print any output @@ -165,9 +163,8 @@ fn help_short_flag() { --python-preference Whether to prefer uv-managed or system Python installations [possible values: only-managed, managed, system, only-system] - --python-fetch - Whether to automatically download Python when required [possible values: automatic, - manual] + --no-python-downloads + Disable automatic downloads of Python Global options: -q, --quiet Do not print any output @@ -212,7 +209,7 @@ fn help_subcommand() { When preview is enabled, i.e., via `--preview` or by using a preview command, uv will download Python if a version cannot be found. This - behavior can be disabled with the `--python-fetch` option. + behavior can be disabled with the `--python-downloads` option. The `--python` option allows requesting a different interpreter. @@ -281,13 +278,8 @@ fn help_subcommand() { - only-system: Only use system Python installations; never use managed Python installations - --python-fetch - Whether to automatically download Python when required - - Possible values: - - automatic: Automatically fetch managed Python installations when needed - - manual: Do not automatically fetch managed Python installations; require explicit - installation + --no-python-downloads + Disable automatic downloads of Python Global options: -q, --quiet @@ -419,13 +411,8 @@ fn help_subsubcommand() { - only-system: Only use system Python installations; never use managed Python installations - --python-fetch - Whether to automatically download Python when required - - Possible values: - - automatic: Automatically fetch managed Python installations when needed - - manual: Do not automatically fetch managed Python installations; require explicit - installation + --no-python-downloads + Disable automatic downloads of Python Global options: -q, --quiet @@ -527,9 +514,8 @@ fn help_flag_subcommand() { --python-preference Whether to prefer uv-managed or system Python installations [possible values: only-managed, managed, system, only-system] - --python-fetch - Whether to automatically download Python when required [possible values: automatic, - manual] + --no-python-downloads + Disable automatic downloads of Python Global options: -q, --quiet Do not print any output @@ -580,9 +566,8 @@ fn help_flag_subsubcommand() { --python-preference Whether to prefer uv-managed or system Python installations [possible values: only-managed, managed, system, only-system] - --python-fetch - Whether to automatically download Python when required [possible values: automatic, - manual] + --no-python-downloads + Disable automatic downloads of Python Global options: -q, --quiet Do not print any output @@ -710,9 +695,8 @@ fn help_with_global_option() { --python-preference Whether to prefer uv-managed or system Python installations [possible values: only-managed, managed, system, only-system] - --python-fetch - Whether to automatically download Python when required [possible values: automatic, - manual] + --no-python-downloads + Disable automatic downloads of Python Global options: -q, --quiet Do not print any output @@ -809,9 +793,8 @@ fn help_with_no_pager() { --python-preference Whether to prefer uv-managed or system Python installations [possible values: only-managed, managed, system, only-system] - --python-fetch - Whether to automatically download Python when required [possible values: automatic, - manual] + --no-python-downloads + Disable automatic downloads of Python Global options: -q, --quiet Do not print any output diff --git a/crates/uv/tests/lock.rs b/crates/uv/tests/lock.rs index 6b78db96757f..d5abd97aa189 100644 --- a/crates/uv/tests/lock.rs +++ b/crates/uv/tests/lock.rs @@ -2977,7 +2977,7 @@ fn lock_requires_python() -> Result<()> { // Install from the lockfile. // Note we need to disable Python fetches or we'll just download 3.12 - uv_snapshot!(filters, context38.sync().arg("--frozen").arg("--python-fetch").arg("manual"), @r###" + uv_snapshot!(filters, context38.sync().arg("--frozen").arg("--no-python-downloads"), @r###" success: false exit_code: 2 ----- stdout ----- diff --git a/crates/uv/tests/show_settings.rs b/crates/uv/tests/show_settings.rs index d7f48fb98feb..e65c01d36d8b 100644 --- a/crates/uv/tests/show_settings.rs +++ b/crates/uv/tests/show_settings.rs @@ -56,7 +56,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -192,7 +192,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -329,7 +329,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -498,7 +498,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -636,7 +636,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -760,7 +760,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -921,7 +921,7 @@ fn resolve_index_url() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -1082,7 +1082,7 @@ fn resolve_index_url() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -1288,7 +1288,7 @@ fn resolve_find_links() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -1448,7 +1448,7 @@ fn resolve_top_level() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -1578,7 +1578,7 @@ fn resolve_top_level() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -1736,7 +1736,7 @@ fn resolve_top_level() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -1918,7 +1918,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -2038,7 +2038,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -2158,7 +2158,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -2280,7 +2280,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -2421,7 +2421,7 @@ fn resolve_tool() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -2534,7 +2534,7 @@ fn resolve_poetry_toml() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -2682,7 +2682,7 @@ fn resolve_both() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -2845,7 +2845,7 @@ fn resolve_config_file() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -3083,7 +3083,7 @@ fn resolve_skip_empty() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { @@ -3206,7 +3206,7 @@ fn resolve_skip_empty() -> anyhow::Result<()> { show_settings: true, preview: Disabled, python_preference: OnlySystem, - python_fetch: Automatic, + python_downloads: Automatic, no_progress: false, } CacheSettings { diff --git a/docs/concepts/python-versions.md b/docs/concepts/python-versions.md index a2dc21ed4fd7..ad92edad3c85 100644 --- a/docs/concepts/python-versions.md +++ b/docs/concepts/python-versions.md @@ -47,7 +47,7 @@ Additionally, a specific system Python interpreter can be requested with: By default, uv will automatically download Python versions if they cannot be found on the system. This behavior can be -[disabled with the `python-fetch` option](#disabling-automatic-python-downloads). +[disabled with the `python-downloads` option](#disabling-automatic-python-downloads). ## Installing a Python version @@ -155,7 +155,7 @@ version download. By default, uv will automatically download Python versions when needed. -The `python-fetch` option can be used to disable this behavior. By default, it is set to +The `python-downloads` option can be used to disable this behavior. By default, it is set to `automatic`; set to `manual` to only allow Python downloads during `uv python install`. ## Adjusting Python version preferences diff --git a/docs/reference/cli.md b/docs/reference/cli.md index ce7dde9b1dfb..b15f0b7d71ec 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -235,6 +235,8 @@ uv run [OPTIONS]

If a virtual environment is active or found in a current or parent directory, it will be used as if there was no project or workspace.

+
--no-python-downloads

Disable automatic downloads of Python

+
--no-sources

Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

--offline

Disable network access.

@@ -268,15 +270,6 @@ uv run [OPTIONS]

See uv python to view supported request formats.

-
--python-fetch python-fetch

Whether to automatically download Python when required

- -

Possible values:

- -
    -
  • automatic: Automatically fetch managed Python installations when needed
  • - -
  • manual: Do not automatically fetch managed Python installations; require explicit installation
  • -
--python-preference python-preference

Whether to prefer uv-managed or system Python installations.

By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

@@ -409,6 +402,8 @@ uv init [OPTIONS] [PATH]

For example, spinners or progress bars.

+
--no-python-downloads

Disable automatic downloads of Python

+
--no-readme

Do not create a README.md file

--no-workspace

Avoid discovering a workspace.

@@ -425,15 +420,6 @@ uv init [OPTIONS] [PATH]

See uv python to view supported request formats.

-
--python-fetch python-fetch

Whether to automatically download Python when required

- -

Possible values:

- -
    -
  • automatic: Automatically fetch managed Python installations when needed
  • - -
  • manual: Do not automatically fetch managed Python installations; require explicit installation
  • -
--python-preference python-preference

Whether to prefer uv-managed or system Python installations.

By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

@@ -642,6 +628,8 @@ uv add [OPTIONS] ...

For example, spinners or progress bars.

+
--no-python-downloads

Disable automatic downloads of Python

+
--no-sources

Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

--no-sync

Avoid syncing the virtual environment after re-locking the project

@@ -679,15 +667,6 @@ uv add [OPTIONS] ...

See uv python for details on Python discovery and supported request formats.

-
--python-fetch python-fetch

Whether to automatically download Python when required

- -

Possible values:

- -
    -
  • automatic: Automatically fetch managed Python installations when needed
  • - -
  • manual: Do not automatically fetch managed Python installations; require explicit installation
  • -
--python-preference python-preference

Whether to prefer uv-managed or system Python installations.

By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

@@ -915,6 +894,8 @@ uv remove [OPTIONS] ...

For example, spinners or progress bars.

+
--no-python-downloads

Disable automatic downloads of Python

+
--no-sources

Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

--no-sync

Avoid syncing the virtual environment after re-locking the project

@@ -948,15 +929,6 @@ uv remove [OPTIONS] ...

See uv python for details on Python discovery and supported request formats.

-
--python-fetch python-fetch

Whether to automatically download Python when required

- -

Possible values:

- -
    -
  • automatic: Automatically fetch managed Python installations when needed
  • - -
  • manual: Do not automatically fetch managed Python installations; require explicit installation
  • -
--python-preference python-preference

Whether to prefer uv-managed or system Python installations.

By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

@@ -1168,6 +1140,8 @@ uv sync [OPTIONS]

For example, spinners or progress bars.

+
--no-python-downloads

Disable automatic downloads of Python

+
--no-sources

Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

--offline

Disable network access.

@@ -1201,15 +1175,6 @@ uv sync [OPTIONS]

See uv python for details on Python discovery and supported request formats.

-
--python-fetch python-fetch

Whether to automatically download Python when required

- -

Possible values:

- -
    -
  • automatic: Automatically fetch managed Python installations when needed
  • - -
  • manual: Do not automatically fetch managed Python installations; require explicit installation
  • -
--python-preference python-preference

Whether to prefer uv-managed or system Python installations.

By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

@@ -1403,6 +1368,8 @@ uv lock [OPTIONS]

For example, spinners or progress bars.

+
--no-python-downloads

Disable automatic downloads of Python

+
--no-sources

Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

--offline

Disable network access.

@@ -1434,15 +1401,6 @@ uv lock [OPTIONS]

See uv python for details on Python discovery and supported request formats.

-
--python-fetch python-fetch

Whether to automatically download Python when required

- -

Possible values:

- -
    -
  • automatic: Automatically fetch managed Python installations when needed
  • - -
  • manual: Do not automatically fetch managed Python installations; require explicit installation
  • -
--python-preference python-preference

Whether to prefer uv-managed or system Python installations.

By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

@@ -1643,6 +1601,8 @@ uv tree [OPTIONS]

For example, spinners or progress bars.

+
--no-python-downloads

Disable automatic downloads of Python

+
--no-sources

Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

--offline

Disable network access.

@@ -1676,15 +1636,6 @@ uv tree [OPTIONS]

See uv python for details on Python discovery and supported request formats.

-
--python-fetch python-fetch

Whether to automatically download Python when required

- -

Possible values:

- -
    -
  • automatic: Automatically fetch managed Python installations when needed
  • - -
  • manual: Do not automatically fetch managed Python installations; require explicit installation
  • -
--python-platform python-platform

The platform to use when filtering the tree.

For example, pass --platform windows to display the dependencies that would be included when installing on Windows.

@@ -1957,6 +1908,8 @@ uv tool run [OPTIONS] [COMMAND]

For example, spinners or progress bars.

+
--no-python-downloads

Disable automatic downloads of Python

+
--no-sources

Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

--offline

Disable network access.

@@ -1984,15 +1937,6 @@ uv tool run [OPTIONS] [COMMAND]

See uv python for details on Python discovery and supported request formats.

-
--python-fetch python-fetch

Whether to automatically download Python when required

- -

Possible values:

- -
    -
  • automatic: Automatically fetch managed Python installations when needed
  • - -
  • manual: Do not automatically fetch managed Python installations; require explicit installation
  • -
--python-preference python-preference

Whether to prefer uv-managed or system Python installations.

By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

@@ -2200,6 +2144,8 @@ uv tool install [OPTIONS]

For example, spinners or progress bars.

+
--no-python-downloads

Disable automatic downloads of Python

+
--no-sources

Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

--offline

Disable network access.

@@ -2227,15 +2173,6 @@ uv tool install [OPTIONS]

See uv python for details on Python discovery and supported request formats.

-
--python-fetch python-fetch

Whether to automatically download Python when required

- -

Possible values:

- -
    -
  • automatic: Automatically fetch managed Python installations when needed
  • - -
  • manual: Do not automatically fetch managed Python installations; require explicit installation
  • -
--python-preference python-preference

Whether to prefer uv-managed or system Python installations.

By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

@@ -2441,6 +2378,8 @@ uv tool upgrade [OPTIONS]

For example, spinners or progress bars.

+
--no-python-downloads

Disable automatic downloads of Python

+
--no-sources

Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

--offline

Disable network access.

@@ -2464,15 +2403,6 @@ uv tool upgrade [OPTIONS]
  • if-necessary-or-explicit: Allow pre-release versions if all versions of a package are pre-release, or if the package has an explicit pre-release marker in its version requirements
  • -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -2573,19 +2503,12 @@ uv tool list [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -2671,19 +2594,12 @@ uv tool uninstall [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -2759,19 +2675,12 @@ uv tool update-shell [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -2851,19 +2760,12 @@ uv tool dir [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -2904,7 +2806,7 @@ executables. When preview is enabled, i.e., via `--preview` or by using a preview command, uv will download Python if a version cannot be found. This -behavior can be disabled with the `--python-fetch` option. +behavior can be disabled with the `--python-downloads` option. The `--python` option allows requesting a different interpreter. @@ -3008,21 +2910,14 @@ uv python list [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    --only-installed

    Only show installed Python versions, exclude available downloads

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -3108,19 +3003,12 @@ uv python install [OPTIONS] [TARGETS]...

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -3206,19 +3094,12 @@ uv python find [OPTIONS] [REQUEST]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -3304,21 +3185,14 @@ uv python pin [OPTIONS] [REQUEST]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --no-workspace

    Avoid validating the Python pin against the workspace in the current directory or any parent directory

    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -3398,19 +3272,12 @@ uv python dir [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -3496,19 +3363,12 @@ uv python uninstall [OPTIONS] ...

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -3764,6 +3624,8 @@ uv pip compile [OPTIONS] ...

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --no-sources

    Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

    --no-strip-extras

    Include extras in the output file.

    @@ -3819,15 +3681,6 @@ uv pip compile [OPTIONS] ...

    See uv python for details on Python discovery and supported request formats.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-platform python-platform

    The platform for which requirements should be resolved.

    Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aaarch64-apple-darwin.

    @@ -4098,6 +3951,8 @@ uv pip sync [OPTIONS] ...

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --no-sources

    Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

    --offline

    Disable network access.

    @@ -4120,15 +3975,6 @@ uv pip sync [OPTIONS] ...

    See uv python for details on Python discovery and supported request formats.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-platform python-platform

    The platform for which requirements should be installed.

    Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aaarch64-apple-darwin.

    @@ -4410,6 +4256,8 @@ uv pip install [OPTIONS] |--editable For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --no-sources

    Ignore the tool.uv.sources table when resolving dependencies. Used to lock against the standards-compliant, publishable package metadata, as opposed to using any local or Git sources

    --offline

    Disable network access.

    @@ -4455,15 +4303,6 @@ uv pip install [OPTIONS] |--editable See uv python for details on Python discovery and supported request formats.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-platform python-platform

    The platform for which requirements should be installed.

    Represented as a "target triple", a string that describes the target platform in terms of its CPU, vendor, and operating system name, like x86_64-unknown-linux-gnu or aaarch64-apple-darwin.

    @@ -4662,6 +4501,8 @@ uv pip uninstall [OPTIONS] >

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    @@ -4674,15 +4515,6 @@ uv pip uninstall [OPTIONS] >

    See uv python for details on Python discovery and supported request formats.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -4770,6 +4602,8 @@ uv pip freeze [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    @@ -4780,15 +4614,6 @@ uv pip freeze [OPTIONS]

    See uv python for details on Python discovery and supported request formats.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -4890,6 +4715,8 @@ uv pip list [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    @@ -4900,15 +4727,6 @@ uv pip list [OPTIONS]

    See uv python for details on Python discovery and supported request formats.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -4998,6 +4816,8 @@ uv pip show [OPTIONS] [PACKAGE]...

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    @@ -5008,15 +4828,6 @@ uv pip show [OPTIONS] [PACKAGE]...

    See uv python for details on Python discovery and supported request formats.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -5107,6 +4918,8 @@ uv pip tree [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --no-system
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    @@ -5121,15 +4934,6 @@ uv pip tree [OPTIONS]

    See uv python for details on Python discovery and supported request formats.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -5215,6 +5019,8 @@ uv pip check [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    @@ -5225,15 +5031,6 @@ uv pip check [OPTIONS]

    See uv python for details on Python discovery and supported request formats.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -5394,6 +5191,8 @@ uv venv [OPTIONS] [NAME]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    @@ -5422,15 +5221,6 @@ uv venv [OPTIONS] [NAME]

    See uv python help for details on Python discovery and supported request formats.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -5548,19 +5338,12 @@ uv cache clean [OPTIONS] [PACKAGE]...

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -5642,19 +5425,12 @@ uv cache prune [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -5730,19 +5506,12 @@ uv cache dir [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -5818,20 +5587,13 @@ uv version [OPTIONS]

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --output-format output-format
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    +
    --output-format output-format
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    @@ -5912,19 +5674,12 @@ uv help [OPTIONS] [COMMAND]...

    For example, spinners or progress bars.

    +
    --no-python-downloads

    Disable automatic downloads of Python

    +
    --offline

    Disable network access.

    When disabled, uv will only use locally cached data and locally available files.

    -
    --python-fetch python-fetch

    Whether to automatically download Python when required

    - -

    Possible values:

    - -
      -
    • automatic: Automatically fetch managed Python installations when needed
    • - -
    • manual: Do not automatically fetch managed Python installations; require explicit installation
    • -
    --python-preference python-preference

    Whether to prefer uv-managed or system Python installations.

    By default, uv prefers using Python versions it manages. However, it will use system Python installations if a uv-managed Python is not installed. This option allows prioritizing or ignoring system Python installations.

    diff --git a/docs/reference/settings.md b/docs/reference/settings.md index bf5d2621a589..a62edbda875a 100644 --- a/docs/reference/settings.md +++ b/docs/reference/settings.md @@ -693,16 +693,17 @@ Whether to enable experimental, preview features. --- -#### [`python-fetch`](#python-fetch) {: #python-fetch } +#### [`python-downloads`](#python-downloads) {: #python-downloads } -Whether to automatically download Python when required. +Whether to allow Python downloads. **Default value**: `"automatic"` **Possible values**: -- `"automatic"`: Automatically fetch managed Python installations when needed -- `"manual"`: Do not automatically fetch managed Python installations; require explicit installation +- `"automatic"`: Automatically download managed Python installations when needed +- `"manual"`: Do not automatically download managed Python installations; require explicit installation +- `"never"`: Do not ever allow Python downloads **Example usage**: @@ -710,13 +711,13 @@ Whether to automatically download Python when required. ```toml [tool.uv] - python-fetch = "manual" + python-downloads = "manual" ``` === "uv.toml" ```toml - python-fetch = "manual" + python-downloads = "manual" ``` --- diff --git a/uv.schema.json b/uv.schema.json index 8b3e09f81058..2cc9bf7cc76a 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -254,11 +254,11 @@ "null" ] }, - "python-fetch": { - "description": "Whether to automatically download Python when required.", + "python-downloads": { + "description": "Whether to allow Python downloads.", "anyOf": [ { - "$ref": "#/definitions/PythonFetch" + "$ref": "#/definitions/PythonDownloads" }, { "type": "null" @@ -1015,21 +1015,28 @@ } ] }, - "PythonFetch": { + "PythonDownloads": { "oneOf": [ { - "description": "Automatically fetch managed Python installations when needed.", + "description": "Automatically download managed Python installations when needed.", "type": "string", "enum": [ "automatic" ] }, { - "description": "Do not automatically fetch managed Python installations; require explicit installation.", + "description": "Do not automatically download managed Python installations; require explicit installation.", "type": "string", "enum": [ "manual" ] + }, + { + "description": "Do not ever allow Python downloads.", + "type": "string", + "enum": [ + "never" + ] } ] },