diff --git a/crates/uv/src/commands/build_frontend.rs b/crates/uv/src/commands/build_frontend.rs index d7709f5fc..6aac93445 100644 --- a/crates/uv/src/commands/build_frontend.rs +++ b/crates/uv/src/commands/build_frontend.rs @@ -16,13 +16,13 @@ use crate::commands::project::{find_requires_python, ProjectError}; use crate::commands::reporters::PythonDownloadReporter; use crate::commands::ExitStatus; use crate::printer::Printer; -use crate::settings::{ResolverSettings, ResolverSettingsRef}; +use crate::settings::{NetworkSettings, ResolverSettings, ResolverSettingsRef}; use uv_build_backend::check_direct_build; use uv_cache::{Cache, CacheBucket}; -use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; +use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ BuildKind, BuildOptions, BuildOutput, Concurrency, ConfigSettings, Constraints, - HashCheckingMode, IndexStrategy, KeyringProviderType, PreviewMode, SourceStrategy, TrustedHost, + HashCheckingMode, IndexStrategy, KeyringProviderType, PreviewMode, SourceStrategy, }; use uv_dispatch::{BuildDispatch, SharedState}; use uv_distribution_filename::{ @@ -107,13 +107,11 @@ pub(crate) async fn build_frontend( python: Option, install_mirrors: PythonInstallMirrors, settings: ResolverSettings, + network_settings: &NetworkSettings, no_config: bool, python_preference: PythonPreference, python_downloads: PythonDownloads, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, preview: PreviewMode, @@ -134,13 +132,11 @@ pub(crate) async fn build_frontend( python.as_deref(), install_mirrors, settings.as_ref(), + network_settings, no_config, python_preference, python_downloads, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -179,13 +175,11 @@ async fn build_impl( python_request: Option<&str>, install_mirrors: PythonInstallMirrors, settings: ResolverSettingsRef<'_>, + network_settings: &NetworkSettings, no_config: bool, python_preference: PythonPreference, python_downloads: PythonDownloads, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, preview: PreviewMode, @@ -219,9 +213,9 @@ async fn build_impl( } = settings; let client_builder = BaseClientBuilder::default() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); // Determine the source to build. let src = if let Some(src) = src { @@ -339,11 +333,9 @@ async fn build_impl( build_constraints, no_build_isolation, no_build_isolation_package, - native_tls, - connectivity, + network_settings, index_strategy, keyring_provider, - allow_insecure_host, exclude_newer, sources, concurrency, @@ -419,11 +411,9 @@ async fn build_package( build_constraints: &[RequirementsSource], no_build_isolation: bool, no_build_isolation_package: &[PackageName], - native_tls: bool, - connectivity: Connectivity, + network_settings: &NetworkSettings, index_strategy: IndexStrategy, keyring_provider: KeyringProviderType, - allow_insecure_host: &[TrustedHost], exclude_newer: Option, sources: SourceStrategy, concurrency: Concurrency, @@ -528,12 +518,12 @@ async fn build_package( // Initialize the registry client. let client = RegistryClientBuilder::new(cache.clone()) - .native_tls(native_tls) - .connectivity(connectivity) + .native_tls(network_settings.native_tls) + .connectivity(network_settings.connectivity) .index_urls(index_locations.index_urls()) .index_strategy(index_strategy) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .markers(interpreter.markers()) .platform(interpreter.platform()) .build(); diff --git a/crates/uv/src/commands/pip/compile.rs b/crates/uv/src/commands/pip/compile.rs index 8fec7d991..b856e6b77 100644 --- a/crates/uv/src/commands/pip/compile.rs +++ b/crates/uv/src/commands/pip/compile.rs @@ -11,11 +11,11 @@ use rustc_hash::FxHashSet; use tracing::debug; use uv_cache::Cache; -use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; +use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ BuildOptions, Concurrency, ConfigSettings, Constraints, DevGroupsSpecification, ExtrasSpecification, IndexStrategy, NoBinary, NoBuild, PreviewMode, Reinstall, SourceStrategy, - TrustedHost, Upgrade, + Upgrade, }; use uv_configuration::{KeyringProviderType, TargetTriple}; use uv_dispatch::{BuildDispatch, SharedState}; @@ -46,6 +46,7 @@ use crate::commands::pip::loggers::DefaultResolveLogger; use crate::commands::pip::{operations, resolution_environment}; use crate::commands::{diagnostics, ExitStatus, OutputWriter}; use crate::printer::Printer; +use crate::settings::NetworkSettings; /// Resolve a set of requirements into a set of pinned versions. #[allow(clippy::fn_params_excessive_bools)] @@ -82,9 +83,8 @@ pub(crate) async fn pip_compile( index_strategy: IndexStrategy, dependency_metadata: DependencyMetadata, keyring_provider: KeyringProviderType, - allow_insecure_host: &[TrustedHost], + network_settings: &NetworkSettings, config_settings: ConfigSettings, - connectivity: Connectivity, no_build_isolation: bool, no_build_isolation_package: Vec, build_options: BuildOptions, @@ -99,7 +99,6 @@ pub(crate) async fn pip_compile( system: bool, python_preference: PythonPreference, concurrency: Concurrency, - native_tls: bool, quiet: bool, cache: Cache, printer: Printer, @@ -137,10 +136,10 @@ pub(crate) async fn pip_compile( } let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()); + .allow_insecure_host(network_settings.allow_insecure_host.clone()); // Read all requirements from the provided sources. let RequirementsSpecification { @@ -443,7 +442,7 @@ pub(crate) async fn pip_compile( { Ok(resolution) => resolution, Err(err) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } diff --git a/crates/uv/src/commands/pip/install.rs b/crates/uv/src/commands/pip/install.rs index b7160b33b..2aa78668f 100644 --- a/crates/uv/src/commands/pip/install.rs +++ b/crates/uv/src/commands/pip/install.rs @@ -7,11 +7,11 @@ use owo_colors::OwoColorize; use tracing::{debug, enabled, Level}; use uv_cache::Cache; -use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; +use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ BuildOptions, Concurrency, ConfigSettings, Constraints, DevGroupsSpecification, DryRun, ExtrasSpecification, HashCheckingMode, IndexStrategy, PreviewMode, Reinstall, SourceStrategy, - TrustedHost, Upgrade, + Upgrade, }; use uv_configuration::{KeyringProviderType, TargetTriple}; use uv_dispatch::{BuildDispatch, SharedState}; @@ -41,6 +41,7 @@ use crate::commands::pip::operations::{report_interpreter, report_target_environ use crate::commands::pip::{operations, resolution_markers, resolution_tags}; use crate::commands::{diagnostics, ExitStatus}; use crate::printer::Printer; +use crate::settings::NetworkSettings; /// Install packages into the current environment. #[allow(clippy::fn_params_excessive_bools)] @@ -62,12 +63,12 @@ pub(crate) async fn pip_install( index_strategy: IndexStrategy, dependency_metadata: DependencyMetadata, keyring_provider: KeyringProviderType, + network_settings: &NetworkSettings, reinstall: Reinstall, link_mode: LinkMode, compile: bool, hash_checking: Option, installer_metadata: bool, - connectivity: Connectivity, config_settings: &ConfigSettings, no_build_isolation: bool, no_build_isolation_package: Vec, @@ -85,8 +86,6 @@ pub(crate) async fn pip_install( prefix: Option, python_preference: PythonPreference, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: Cache, dry_run: DryRun, printer: Printer, @@ -95,10 +94,10 @@ pub(crate) async fn pip_install( let start = std::time::Instant::now(); let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()); + .allow_insecure_host(network_settings.allow_insecure_host.clone()); // Read all requirements from the provided sources. let RequirementsSpecification { @@ -447,7 +446,7 @@ pub(crate) async fn pip_install( { Ok(graph) => Resolution::from(graph), Err(err) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } @@ -481,7 +480,7 @@ pub(crate) async fn pip_install( { Ok(_) => {} Err(err) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } diff --git a/crates/uv/src/commands/pip/list.rs b/crates/uv/src/commands/pip/list.rs index d9127ecae..e87022d67 100644 --- a/crates/uv/src/commands/pip/list.rs +++ b/crates/uv/src/commands/pip/list.rs @@ -14,8 +14,8 @@ use unicode_width::UnicodeWidthStr; use uv_cache::{Cache, Refresh}; use uv_cache_info::Timestamp; use uv_cli::ListFormat; -use uv_client::{Connectivity, RegistryClientBuilder}; -use uv_configuration::{Concurrency, IndexStrategy, KeyringProviderType, TrustedHost}; +use uv_client::RegistryClientBuilder; +use uv_configuration::{Concurrency, IndexStrategy, KeyringProviderType}; use uv_distribution_filename::DistFilename; use uv_distribution_types::{Diagnostic, IndexCapabilities, IndexLocations, InstalledDist, Name}; use uv_fs::Simplified; @@ -31,6 +31,7 @@ use crate::commands::pip::operations::report_target_environment; use crate::commands::reporters::LatestVersionReporter; use crate::commands::ExitStatus; use crate::printer::Printer; +use crate::settings::NetworkSettings; /// Enumerate the installed packages in the current environment. #[allow(clippy::fn_params_excessive_bools)] @@ -43,14 +44,12 @@ pub(crate) async fn pip_list( index_locations: IndexLocations, index_strategy: IndexStrategy, keyring_provider: KeyringProviderType, - allow_insecure_host: Vec, - connectivity: Connectivity, + network_settings: &NetworkSettings, concurrency: Concurrency, strict: bool, exclude_newer: Option, python: Option<&str>, system: bool, - native_tls: bool, cache: &Cache, printer: Printer, ) -> Result { @@ -86,12 +85,12 @@ pub(crate) async fn pip_list( // Initialize the registry client. let client = RegistryClientBuilder::new(cache.clone().with_refresh(Refresh::All(Timestamp::now()))) - .native_tls(native_tls) - .connectivity(connectivity) + .native_tls(network_settings.native_tls) + .connectivity(network_settings.connectivity) .index_urls(index_locations.index_urls()) .index_strategy(index_strategy) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.clone()) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .markers(environment.interpreter().markers()) .platform(environment.interpreter().platform()) .build(); diff --git a/crates/uv/src/commands/pip/sync.rs b/crates/uv/src/commands/pip/sync.rs index e96ecdbae..5d518be92 100644 --- a/crates/uv/src/commands/pip/sync.rs +++ b/crates/uv/src/commands/pip/sync.rs @@ -7,11 +7,11 @@ use owo_colors::OwoColorize; use tracing::debug; use uv_cache::Cache; -use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; +use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ BuildOptions, Concurrency, ConfigSettings, Constraints, DevGroupsSpecification, DryRun, ExtrasSpecification, HashCheckingMode, IndexStrategy, PreviewMode, Reinstall, SourceStrategy, - TrustedHost, Upgrade, + Upgrade, }; use uv_configuration::{KeyringProviderType, TargetTriple}; use uv_dispatch::{BuildDispatch, SharedState}; @@ -38,6 +38,7 @@ use crate::commands::pip::operations::{report_interpreter, report_target_environ use crate::commands::pip::{operations, resolution_markers, resolution_tags}; use crate::commands::{diagnostics, ExitStatus}; use crate::printer::Printer; +use crate::settings::NetworkSettings; /// Install a set of locked requirements into the current Python environment. #[allow(clippy::fn_params_excessive_bools)] @@ -53,9 +54,9 @@ pub(crate) async fn pip_sync( index_strategy: IndexStrategy, dependency_metadata: DependencyMetadata, keyring_provider: KeyringProviderType, + network_settings: &NetworkSettings, allow_empty_requirements: bool, installer_metadata: bool, - connectivity: Connectivity, config_settings: &ConfigSettings, no_build_isolation: bool, no_build_isolation_package: Vec, @@ -72,18 +73,16 @@ pub(crate) async fn pip_sync( sources: SourceStrategy, python_preference: PythonPreference, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: Cache, dry_run: DryRun, printer: Printer, preview: PreviewMode, ) -> Result { let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()); + .allow_insecure_host(network_settings.allow_insecure_host.clone()); // Initialize a few defaults. let overrides = &[]; @@ -381,7 +380,7 @@ pub(crate) async fn pip_sync( { Ok(resolution) => Resolution::from(resolution), Err(err) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } @@ -415,7 +414,7 @@ pub(crate) async fn pip_sync( { Ok(_) => {} Err(err) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } diff --git a/crates/uv/src/commands/pip/tree.rs b/crates/uv/src/commands/pip/tree.rs index da0266719..16d376a4c 100644 --- a/crates/uv/src/commands/pip/tree.rs +++ b/crates/uv/src/commands/pip/tree.rs @@ -12,8 +12,8 @@ use tokio::sync::Semaphore; use uv_cache::{Cache, Refresh}; use uv_cache_info::Timestamp; -use uv_client::{Connectivity, RegistryClientBuilder}; -use uv_configuration::{Concurrency, IndexStrategy, KeyringProviderType, TrustedHost}; +use uv_client::RegistryClientBuilder; +use uv_configuration::{Concurrency, IndexStrategy, KeyringProviderType}; use uv_distribution_types::{Diagnostic, IndexCapabilities, IndexLocations, Name}; use uv_installer::SitePackages; use uv_normalize::PackageName; @@ -28,6 +28,7 @@ use crate::commands::pip::operations::report_target_environment; use crate::commands::reporters::LatestVersionReporter; use crate::commands::ExitStatus; use crate::printer::Printer; +use crate::settings::NetworkSettings; /// Display the installed packages in the current environment as a dependency tree. #[allow(clippy::fn_params_excessive_bools)] @@ -43,14 +44,12 @@ pub(crate) async fn pip_tree( index_locations: IndexLocations, index_strategy: IndexStrategy, keyring_provider: KeyringProviderType, - allow_insecure_host: Vec, - connectivity: Connectivity, + network_settings: NetworkSettings, concurrency: Concurrency, strict: bool, exclude_newer: Option, python: Option<&str>, system: bool, - native_tls: bool, cache: &Cache, printer: Printer, ) -> Result { @@ -87,12 +86,12 @@ pub(crate) async fn pip_tree( // Initialize the registry client. let client = RegistryClientBuilder::new(cache.clone().with_refresh(Refresh::All(Timestamp::now()))) - .native_tls(native_tls) - .connectivity(connectivity) + .native_tls(network_settings.native_tls) + .connectivity(network_settings.connectivity) .index_urls(index_locations.index_urls()) .index_strategy(index_strategy) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.clone()) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .markers(environment.interpreter().markers()) .platform(environment.interpreter().platform()) .build(); diff --git a/crates/uv/src/commands/pip/uninstall.rs b/crates/uv/src/commands/pip/uninstall.rs index effb0db54..28f85c659 100644 --- a/crates/uv/src/commands/pip/uninstall.rs +++ b/crates/uv/src/commands/pip/uninstall.rs @@ -6,8 +6,8 @@ use owo_colors::OwoColorize; use tracing::debug; use uv_cache::Cache; -use uv_client::{BaseClientBuilder, Connectivity}; -use uv_configuration::{DryRun, KeyringProviderType, TrustedHost}; +use uv_client::BaseClientBuilder; +use uv_configuration::{DryRun, KeyringProviderType}; use uv_distribution_types::{InstalledMetadata, Name, UnresolvedRequirement}; use uv_fs::Simplified; use uv_pep508::UnnamedRequirement; @@ -21,6 +21,7 @@ use uv_requirements::{RequirementsSource, RequirementsSpecification}; use crate::commands::pip::operations::report_target_environment; use crate::commands::{elapsed, ExitStatus}; use crate::printer::Printer; +use crate::settings::NetworkSettings; /// Uninstall packages from the current environment. #[allow(clippy::fn_params_excessive_bools)] @@ -32,20 +33,18 @@ pub(crate) async fn pip_uninstall( target: Option, prefix: Option, cache: Cache, - connectivity: Connectivity, - native_tls: bool, keyring_provider: KeyringProviderType, - allow_insecure_host: &[TrustedHost], + network_settings: &NetworkSettings, dry_run: DryRun, printer: Printer, ) -> Result { let start = std::time::Instant::now(); let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()); + .allow_insecure_host(network_settings.allow_insecure_host.clone()); // Read all requirements from the provided sources. let spec = RequirementsSpecification::from_simple_sources(sources, &client_builder).await?; diff --git a/crates/uv/src/commands/project/add.rs b/crates/uv/src/commands/project/add.rs index 703a30b45..cc353da25 100644 --- a/crates/uv/src/commands/project/add.rs +++ b/crates/uv/src/commands/project/add.rs @@ -14,10 +14,10 @@ use url::Url; use uv_cache::Cache; use uv_cache_key::RepositoryUrl; -use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; +use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ Concurrency, Constraints, DevGroupsSpecification, DevMode, DryRun, EditableMode, - ExtrasSpecification, InstallOptions, PreviewMode, SourceStrategy, TrustedHost, + ExtrasSpecification, InstallOptions, PreviewMode, SourceStrategy, }; use uv_dispatch::BuildDispatch; use uv_distribution::DistributionDatabase; @@ -53,7 +53,7 @@ use crate::commands::project::{ use crate::commands::reporters::{PythonDownloadReporter, ResolverReporter}; use crate::commands::{diagnostics, project, ExitStatus, ScriptPath}; use crate::printer::Printer; -use crate::settings::{ResolverInstallerSettings, ResolverInstallerSettingsRef}; +use crate::settings::{NetworkSettings, ResolverInstallerSettings, ResolverInstallerSettingsRef}; /// Add one or more packages to the project requirements. #[allow(clippy::fn_params_excessive_bools)] @@ -76,14 +76,12 @@ pub(crate) async fn add( python: Option, install_mirrors: PythonInstallMirrors, settings: ResolverInstallerSettings, + network_settings: NetworkSettings, script: Option, python_preference: PythonPreference, python_downloads: PythonDownloads, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], no_config: bool, cache: &Cache, printer: Printer, @@ -130,9 +128,9 @@ pub(crate) async fn add( } let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); // If we found a script, add to the existing metadata. Otherwise, create a new inline // metadata tag. @@ -160,11 +158,9 @@ pub(crate) async fn add( let interpreter = ScriptInterpreter::discover( Pep723ItemRef::Script(&script), python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, active, @@ -209,11 +205,9 @@ pub(crate) async fn add( project.workspace(), project_dir, python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, active, @@ -230,11 +224,9 @@ pub(crate) async fn add( project.workspace(), python.as_deref().map(PythonRequest::parse), &install_mirrors, + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, no_config, active, cache, @@ -249,10 +241,10 @@ pub(crate) async fn add( }; let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) .keyring(settings.keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()); + .allow_insecure_host(network_settings.allow_insecure_host.clone()); // Read the requirements. let RequirementsSpecification { requirements, .. } = @@ -632,11 +624,9 @@ pub(crate) async fn add( &dependency_type, raw_sources, settings.as_ref(), + &network_settings, installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -649,7 +639,7 @@ pub(crate) async fn add( let _ = snapshot.revert(); } match err { - ProjectError::Operation(err) => diagnostics::OperationDiagnostic::native_tls(native_tls).with_hint(format!("If you want to add the package regardless of the failed resolution, provide the `{}` flag to skip locking and syncing.", "--frozen".green())) + ProjectError::Operation(err) => diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls).with_hint(format!("If you want to add the package regardless of the failed resolution, provide the `{}` flag to skip locking and syncing.", "--frozen".green())) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())), err => Err(err.into()), @@ -670,11 +660,9 @@ async fn lock_and_sync( dependency_type: &DependencyType, raw_sources: bool, settings: ResolverInstallerSettingsRef<'_>, + network_settings: &NetworkSettings, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, preview: PreviewMode, @@ -687,12 +675,10 @@ async fn lock_and_sync( }, (&target).into(), settings.into(), + network_settings, &lock_state, Box::new(DefaultResolveLogger), - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -807,12 +793,10 @@ async fn lock_and_sync( }, (&target).into(), settings.into(), + network_settings, &lock_state, Box::new(SummaryResolveLogger), - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -878,13 +862,11 @@ async fn lock_and_sync( InstallOptions::default(), Modifications::Sufficient, settings.into(), + network_settings, &sync_state, Box::new(DefaultInstallLogger), installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, DryRun::Disabled, printer, diff --git a/crates/uv/src/commands/project/environment.rs b/crates/uv/src/commands/project/environment.rs index e979379c9..a8c4110f0 100644 --- a/crates/uv/src/commands/project/environment.rs +++ b/crates/uv/src/commands/project/environment.rs @@ -2,8 +2,7 @@ use tracing::debug; use uv_cache::{Cache, CacheBucket}; use uv_cache_key::{cache_digest, hash_digest}; -use uv_client::Connectivity; -use uv_configuration::{Concurrency, PreviewMode, TrustedHost}; +use uv_configuration::{Concurrency, PreviewMode}; use uv_distribution_types::{Name, Resolution}; use uv_python::{Interpreter, PythonEnvironment}; @@ -13,7 +12,7 @@ use crate::commands::project::{ resolve_environment, sync_environment, EnvironmentSpecification, PlatformState, ProjectError, }; use crate::printer::Printer; -use crate::settings::ResolverInstallerSettings; +use crate::settings::{NetworkSettings, ResolverInstallerSettings}; /// A [`PythonEnvironment`] stored in the cache. #[derive(Debug)] @@ -31,14 +30,12 @@ impl CachedEnvironment { spec: EnvironmentSpecification<'_>, interpreter: &Interpreter, settings: &ResolverInstallerSettings, + network_settings: &NetworkSettings, state: &PlatformState, resolve: Box, install: Box, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, preview: PreviewMode, @@ -51,12 +48,10 @@ impl CachedEnvironment { spec, &interpreter, settings.as_ref().into(), + network_settings, state, resolve, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -105,13 +100,11 @@ impl CachedEnvironment { &resolution, Modifications::Exact, settings.as_ref().into(), + network_settings, state, install, installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, diff --git a/crates/uv/src/commands/project/export.rs b/crates/uv/src/commands/project/export.rs index 1b64967bb..8792405a6 100644 --- a/crates/uv/src/commands/project/export.rs +++ b/crates/uv/src/commands/project/export.rs @@ -7,10 +7,9 @@ use std::path::{Path, PathBuf}; use uv_settings::PythonInstallMirrors; use uv_cache::Cache; -use uv_client::Connectivity; use uv_configuration::{ Concurrency, DevGroupsSpecification, EditableMode, ExportFormat, ExtrasSpecification, - InstallOptions, PreviewMode, TrustedHost, + InstallOptions, PreviewMode, }; use uv_normalize::PackageName; use uv_python::{PythonDownloads, PythonPreference, PythonRequest}; @@ -28,7 +27,7 @@ use crate::commands::project::{ }; use crate::commands::{diagnostics, ExitStatus, OutputWriter}; use crate::printer::Printer; -use crate::settings::ResolverSettings; +use crate::settings::{NetworkSettings, ResolverSettings}; #[derive(Debug, Clone)] enum ExportTarget { @@ -69,12 +68,10 @@ pub(crate) async fn export( python: Option, install_mirrors: PythonInstallMirrors, settings: ResolverSettings, + network_settings: NetworkSettings, python_preference: PythonPreference, python_downloads: PythonDownloads, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], no_config: bool, quiet: bool, cache: &Cache, @@ -122,11 +119,9 @@ pub(crate) async fn export( ExportTarget::Script(script) => ScriptInterpreter::discover( Pep723ItemRef::Script(script), python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, Some(false), @@ -139,11 +134,9 @@ pub(crate) async fn export( project.workspace(), project_dir, python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, Some(false), @@ -177,12 +170,10 @@ pub(crate) async fn export( mode, (&target).into(), settings.as_ref(), + &network_settings, &state, Box::new(DefaultResolveLogger), - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -191,7 +182,7 @@ pub(crate) async fn export( { Ok(result) => result.into_lock(), Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } diff --git a/crates/uv/src/commands/project/init.rs b/crates/uv/src/commands/project/init.rs index 5f41d8a8b..f115afd1a 100644 --- a/crates/uv/src/commands/project/init.rs +++ b/crates/uv/src/commands/project/init.rs @@ -8,9 +8,9 @@ use std::str::FromStr; use tracing::{debug, warn}; use uv_cache::Cache; use uv_cli::AuthorFrom; -use uv_client::{BaseClientBuilder, Connectivity}; +use uv_client::BaseClientBuilder; use uv_configuration::{ - PreviewMode, ProjectBuildBackend, TrustedHost, VersionControlError, VersionControlSystem, + PreviewMode, ProjectBuildBackend, VersionControlError, VersionControlSystem, }; use uv_fs::{Simplified, CWD}; use uv_git::GIT; @@ -32,6 +32,7 @@ use crate::commands::project::{find_requires_python, init_script_python_requirem use crate::commands::reporters::PythonDownloadReporter; use crate::commands::ExitStatus; use crate::printer::Printer; +use crate::settings::NetworkSettings; /// Add one or more packages to the project requirements. #[allow(clippy::single_match_else, clippy::fn_params_excessive_bools)] @@ -52,11 +53,9 @@ pub(crate) async fn init( python: Option, install_mirrors: PythonInstallMirrors, no_workspace: bool, + network_settings: &NetworkSettings, python_preference: PythonPreference, python_downloads: PythonDownloads, - connectivity: Connectivity, - native_tls: bool, - allow_insecure_host: &[TrustedHost], no_config: bool, cache: &Cache, printer: Printer, @@ -75,7 +74,7 @@ pub(crate) async fn init( path, python, install_mirrors, - connectivity, + network_settings, python_preference, python_downloads, cache, @@ -85,8 +84,6 @@ pub(crate) async fn init( author_from, pin_python, package, - native_tls, - allow_insecure_host, no_config, ) .await?; @@ -146,11 +143,9 @@ pub(crate) async fn init( python, install_mirrors, no_workspace, + network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, no_config, cache, printer, @@ -193,7 +188,7 @@ async fn init_script( script_path: &Path, python: Option, install_mirrors: PythonInstallMirrors, - connectivity: Connectivity, + network_settings: &NetworkSettings, python_preference: PythonPreference, python_downloads: PythonDownloads, cache: &Cache, @@ -203,8 +198,6 @@ async fn init_script( author_from: Option, pin_python: bool, package: bool, - native_tls: bool, - allow_insecure_host: &[TrustedHost], no_config: bool, ) -> Result<()> { if no_workspace { @@ -220,9 +213,9 @@ async fn init_script( warn_user_once!("`--package` is a no-op for Python scripts, which are standalone"); } let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); let reporter = PythonDownloadReporter::single(printer); @@ -290,11 +283,9 @@ async fn init_project( python: Option, install_mirrors: PythonInstallMirrors, no_workspace: bool, + network_settings: &NetworkSettings, python_preference: PythonPreference, python_downloads: PythonDownloads, - connectivity: Connectivity, - native_tls: bool, - allow_insecure_host: &[TrustedHost], no_config: bool, cache: &Cache, printer: Printer, @@ -344,9 +335,9 @@ async fn init_project( let reporter = PythonDownloadReporter::single(printer); let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); // First, determine if there is an request for Python let python_request = if let Some(request) = python { diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index d0d30e7eb..243e808f6 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -10,10 +10,10 @@ use rustc_hash::{FxBuildHasher, FxHashMap}; use tracing::debug; use uv_cache::Cache; -use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; +use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ Concurrency, Constraints, DevGroupsSpecification, DryRun, ExtrasSpecification, PreviewMode, - Reinstall, TrustedHost, Upgrade, + Reinstall, Upgrade, }; use uv_dispatch::BuildDispatch; use uv_distribution::DistributionDatabase; @@ -47,7 +47,7 @@ use crate::commands::project::{ use crate::commands::reporters::{PythonDownloadReporter, ResolverReporter}; use crate::commands::{diagnostics, pip, ExitStatus, ScriptPath}; use crate::printer::Printer; -use crate::settings::{ResolverSettings, ResolverSettingsRef}; +use crate::settings::{NetworkSettings, ResolverSettings, ResolverSettingsRef}; /// The result of running a lock operation. #[derive(Debug, Clone)] @@ -84,13 +84,11 @@ pub(crate) async fn lock( python: Option, install_mirrors: PythonInstallMirrors, settings: ResolverSettings, + network_settings: NetworkSettings, script: Option, python_preference: PythonPreference, python_downloads: PythonDownloads, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], no_config: bool, cache: &Cache, printer: Printer, @@ -100,9 +98,9 @@ pub(crate) async fn lock( let script = match script { Some(ScriptPath::Path(path)) => { let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); let reporter = PythonDownloadReporter::single(printer); let requires_python = init_script_python_requirement( python.as_deref(), @@ -142,11 +140,9 @@ pub(crate) async fn lock( workspace, project_dir, python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, Some(false), @@ -158,11 +154,9 @@ pub(crate) async fn lock( LockTarget::Script(script) => ScriptInterpreter::discover( Pep723ItemRef::Script(script), python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, Some(false), @@ -190,12 +184,10 @@ pub(crate) async fn lock( mode, target, settings.as_ref(), + &network_settings, &state, Box::new(DefaultResolveLogger), - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -230,7 +222,7 @@ pub(crate) async fn lock( Ok(ExitStatus::Success) } Err(ProjectError::Operation(err)) => { - diagnostics::OperationDiagnostic::native_tls(native_tls) + diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } @@ -256,12 +248,10 @@ pub(super) async fn do_safe_lock( mode: LockMode<'_>, target: LockTarget<'_>, settings: ResolverSettingsRef<'_>, + network_settings: &NetworkSettings, state: &UniversalState, logger: Box, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, preview: PreviewMode, @@ -288,12 +278,10 @@ pub(super) async fn do_safe_lock( interpreter, Some(existing), settings, + network_settings, state, logger, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -327,12 +315,10 @@ pub(super) async fn do_safe_lock( interpreter, existing, settings, + network_settings, state, logger, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -357,12 +343,10 @@ async fn do_lock( interpreter: &Interpreter, existing_lock: Option, settings: ResolverSettingsRef<'_>, + network_settings: &NetworkSettings, state: &UniversalState, logger: Box, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, preview: PreviewMode, @@ -553,12 +537,12 @@ async fn do_lock( // Initialize the registry client. let client = RegistryClientBuilder::new(cache.clone()) - .native_tls(native_tls) - .connectivity(connectivity) + .native_tls(network_settings.native_tls) + .connectivity(network_settings.connectivity) .index_urls(index_locations.index_urls()) .index_strategy(index_strategy) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .markers(interpreter.markers()) .platform(interpreter.platform()) .build(); diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index 2b84ab3de..42e02b180 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -10,10 +10,10 @@ use tracing::{debug, warn}; use uv_cache::{Cache, CacheBucket}; use uv_cache_key::cache_digest; -use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; +use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ Concurrency, Constraints, DevGroupsManifest, DevGroupsSpecification, DryRun, - ExtrasSpecification, PreviewMode, Reinstall, SourceStrategy, TrustedHost, Upgrade, + ExtrasSpecification, PreviewMode, Reinstall, SourceStrategy, Upgrade, }; use uv_dispatch::{BuildDispatch, SharedState}; use uv_distribution::{DistributionDatabase, LoweredRequirement}; @@ -52,7 +52,9 @@ use crate::commands::pip::operations::{Changelog, Modifications}; use crate::commands::reporters::{PythonDownloadReporter, ResolverReporter}; use crate::commands::{capitalize, conjunction, pip}; use crate::printer::Printer; -use crate::settings::{InstallerSettingsRef, ResolverInstallerSettings, ResolverSettingsRef}; +use crate::settings::{ + InstallerSettingsRef, NetworkSettings, ResolverInstallerSettings, ResolverSettingsRef, +}; pub(crate) mod add; pub(crate) mod environment; @@ -630,11 +632,9 @@ impl ScriptInterpreter { pub(crate) async fn discover( script: Pep723ItemRef<'_>, python_request: Option, + network_settings: &NetworkSettings, python_preference: PythonPreference, python_downloads: PythonDownloads, - connectivity: Connectivity, - native_tls: bool, - allow_insecure_host: &[TrustedHost], install_mirrors: &PythonInstallMirrors, no_config: bool, active: Option, @@ -686,9 +686,9 @@ impl ScriptInterpreter { }; let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); let reporter = PythonDownloadReporter::single(printer); @@ -773,11 +773,9 @@ impl ProjectInterpreter { workspace: &Workspace, project_dir: &Path, python_request: Option, + network_settings: &NetworkSettings, python_preference: PythonPreference, python_downloads: PythonDownloads, - connectivity: Connectivity, - native_tls: bool, - allow_insecure_host: &[TrustedHost], install_mirrors: &PythonInstallMirrors, no_config: bool, active: Option, @@ -861,9 +859,9 @@ impl ProjectInterpreter { }; let client_builder = BaseClientBuilder::default() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); let reporter = PythonDownloadReporter::single(printer); @@ -1137,11 +1135,9 @@ impl ProjectEnvironment { workspace: &Workspace, python: Option, install_mirrors: &PythonInstallMirrors, + network_settings: &NetworkSettings, python_preference: PythonPreference, python_downloads: PythonDownloads, - connectivity: Connectivity, - native_tls: bool, - allow_insecure_host: &[TrustedHost], no_config: bool, active: Option, cache: &Cache, @@ -1155,11 +1151,9 @@ impl ProjectEnvironment { workspace, workspace.install_path().as_ref(), python, + network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, install_mirrors, no_config, active, @@ -1342,11 +1336,9 @@ impl ScriptEnvironment { pub(crate) async fn get_or_init( script: Pep723ItemRef<'_>, python_request: Option, + network_settings: &NetworkSettings, python_preference: PythonPreference, python_downloads: PythonDownloads, - connectivity: Connectivity, - native_tls: bool, - allow_insecure_host: &[TrustedHost], install_mirrors: &PythonInstallMirrors, no_config: bool, active: Option, @@ -1360,11 +1352,9 @@ impl ScriptEnvironment { match ScriptInterpreter::discover( script, python_request, + network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, install_mirrors, no_config, active, @@ -1482,11 +1472,9 @@ pub(crate) async fn resolve_names( requirements: Vec, interpreter: &Interpreter, settings: &ResolverInstallerSettings, + network_settings: &NetworkSettings, state: &SharedState, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, preview: PreviewMode, @@ -1541,12 +1529,12 @@ pub(crate) async fn resolve_names( // Initialize the registry client. let client = RegistryClientBuilder::new(cache.clone()) - .native_tls(native_tls) - .connectivity(connectivity) + .native_tls(network_settings.native_tls) + .connectivity(network_settings.connectivity) .index_urls(index_locations.index_urls()) .index_strategy(*index_strategy) .keyring(*keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .markers(interpreter.markers()) .platform(interpreter.platform()) .build(); @@ -1636,12 +1624,10 @@ pub(crate) async fn resolve_environment( spec: EnvironmentSpecification<'_>, interpreter: &Interpreter, settings: ResolverSettingsRef<'_>, + network_settings: &NetworkSettings, state: &PlatformState, logger: Box, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, preview: PreviewMode, @@ -1694,12 +1680,12 @@ pub(crate) async fn resolve_environment( // Initialize the registry client. let client = RegistryClientBuilder::new(cache.clone()) - .native_tls(native_tls) - .connectivity(connectivity) + .native_tls(network_settings.native_tls) + .connectivity(network_settings.connectivity) .index_urls(index_locations.index_urls()) .index_strategy(index_strategy) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .markers(interpreter.markers()) .platform(interpreter.platform()) .build(); @@ -1819,13 +1805,11 @@ pub(crate) async fn sync_environment( resolution: &Resolution, modifications: Modifications, settings: InstallerSettingsRef<'_>, + network_settings: &NetworkSettings, state: &PlatformState, logger: Box, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, preview: PreviewMode, @@ -1865,12 +1849,12 @@ pub(crate) async fn sync_environment( // Initialize the registry client. let client = RegistryClientBuilder::new(cache.clone()) - .native_tls(native_tls) - .connectivity(connectivity) + .native_tls(network_settings.native_tls) + .connectivity(network_settings.connectivity) .index_urls(index_locations.index_urls()) .index_strategy(index_strategy) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .markers(interpreter.markers()) .platform(interpreter.platform()) .build(); @@ -1976,14 +1960,12 @@ pub(crate) async fn update_environment( spec: RequirementsSpecification, modifications: Modifications, settings: &ResolverInstallerSettings, + network_settings: &NetworkSettings, state: &SharedState, resolve: Box, install: Box, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, dry_run: DryRun, printer: Printer, @@ -2069,12 +2051,12 @@ pub(crate) async fn update_environment( // Initialize the registry client. let client = RegistryClientBuilder::new(cache.clone()) - .native_tls(native_tls) - .connectivity(connectivity) + .native_tls(network_settings.native_tls) + .connectivity(network_settings.connectivity) .index_urls(index_locations.index_urls()) .index_strategy(*index_strategy) .keyring(*keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .markers(interpreter.markers()) .platform(interpreter.platform()) .build(); diff --git a/crates/uv/src/commands/project/remove.rs b/crates/uv/src/commands/project/remove.rs index a7f17c7d5..39778333f 100644 --- a/crates/uv/src/commands/project/remove.rs +++ b/crates/uv/src/commands/project/remove.rs @@ -8,10 +8,9 @@ use owo_colors::OwoColorize; use tracing::debug; use uv_cache::Cache; -use uv_client::Connectivity; use uv_configuration::{ Concurrency, DevGroupsSpecification, DryRun, EditableMode, ExtrasSpecification, InstallOptions, - PreviewMode, TrustedHost, + PreviewMode, }; use uv_fs::Simplified; use uv_normalize::DEV_DEPENDENCIES; @@ -36,7 +35,7 @@ use crate::commands::project::{ }; use crate::commands::{diagnostics, project, ExitStatus}; use crate::printer::Printer; -use crate::settings::ResolverInstallerSettings; +use crate::settings::{NetworkSettings, ResolverInstallerSettings}; /// Remove one or more packages from the project requirements. #[allow(clippy::fn_params_excessive_bools)] @@ -52,14 +51,12 @@ pub(crate) async fn remove( python: Option, install_mirrors: PythonInstallMirrors, settings: ResolverInstallerSettings, + network_settings: NetworkSettings, script: Option, python_preference: PythonPreference, python_downloads: PythonDownloads, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], no_config: bool, cache: &Cache, printer: Printer, @@ -204,11 +201,9 @@ pub(crate) async fn remove( project.workspace(), project_dir, python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, active, @@ -225,11 +220,9 @@ pub(crate) async fn remove( project.workspace(), python.as_deref().map(PythonRequest::parse), &install_mirrors, + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, no_config, active, cache, @@ -246,11 +239,9 @@ pub(crate) async fn remove( let interpreter = ScriptInterpreter::discover( Pep723ItemRef::Script(&script), python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, active, @@ -279,12 +270,10 @@ pub(crate) async fn remove( mode, (&target).into(), settings.as_ref().into(), + &network_settings, &state, Box::new(DefaultResolveLogger), - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -293,7 +282,7 @@ pub(crate) async fn remove( { Ok(result) => result.into_lock(), Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } @@ -342,13 +331,11 @@ pub(crate) async fn remove( install_options, Modifications::Exact, settings.as_ref().into(), + &network_settings, &state, Box::new(DefaultInstallLogger), installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, DryRun::Disabled, printer, @@ -358,7 +345,7 @@ pub(crate) async fn remove( { Ok(()) => {} Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index 21ecb85f6..9b77bfe08 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -15,10 +15,10 @@ use url::Url; use uv_cache::Cache; use uv_cli::ExternalCommand; -use uv_client::{BaseClientBuilder, Connectivity}; +use uv_client::BaseClientBuilder; use uv_configuration::{ Concurrency, DevGroupsSpecification, DryRun, EditableMode, ExtrasSpecification, InstallOptions, - PreviewMode, TrustedHost, + PreviewMode, }; use uv_fs::which::is_executable; use uv_fs::{PythonExt, Simplified}; @@ -53,7 +53,7 @@ use crate::commands::reporters::PythonDownloadReporter; use crate::commands::run::run_to_completion; use crate::commands::{diagnostics, project, ExitStatus}; use crate::printer::Printer; -use crate::settings::ResolverInstallerSettings; +use crate::settings::{NetworkSettings, ResolverInstallerSettings}; /// Run a command. #[allow(clippy::fn_params_excessive_bools)] @@ -79,13 +79,11 @@ pub(crate) async fn run( python: Option, install_mirrors: PythonInstallMirrors, settings: ResolverInstallerSettings, + network_settings: NetworkSettings, python_preference: PythonPreference, python_downloads: PythonDownloads, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, env_file: Vec, @@ -218,11 +216,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl let environment = ScriptEnvironment::get_or_init( (&script).into(), python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, active.map_or(Some(false), Some), @@ -247,16 +243,14 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl mode, target, settings.as_ref().into(), + &network_settings, &lock_state, if show_resolution { Box::new(DefaultResolveLogger) } else { Box::new(SummaryResolveLogger) }, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -265,10 +259,12 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl { Ok(result) => result.into_lock(), Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) - .with_context("script") - .report(err) - .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) + return diagnostics::OperationDiagnostic::native_tls( + network_settings.native_tls, + ) + .with_context("script") + .report(err) + .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } Err(err) => return Err(err.into()), }; @@ -290,6 +286,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl install_options, modifications, settings.as_ref().into(), + &network_settings, &sync_state, if show_resolution { Box::new(DefaultInstallLogger) @@ -297,10 +294,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl Box::new(SummaryInstallLogger) }, installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, DryRun::Disabled, printer, @@ -310,10 +304,12 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl { Ok(()) => {} Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) - .with_context("script") - .report(err) - .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) + return diagnostics::OperationDiagnostic::native_tls( + network_settings.native_tls, + ) + .with_context("script") + .report(err) + .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } Err(err) => return Err(err.into()), } @@ -339,11 +335,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl let environment = ScriptEnvironment::get_or_init( (&script).into(), python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, active.map_or(Some(false), Some), @@ -359,6 +353,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl spec, modifications, &settings, + &network_settings, &sync_state, if show_resolution { Box::new(DefaultResolveLogger) @@ -371,10 +366,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl Box::new(SummaryInstallLogger) }, installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, DryRun::Disabled, printer, @@ -384,10 +376,12 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl { Ok(update) => Some(update.into_environment().into_interpreter()), Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) - .with_context("script") - .report(err) - .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) + return diagnostics::OperationDiagnostic::native_tls( + network_settings.native_tls, + ) + .with_context("script") + .report(err) + .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } Err(err) => return Err(err.into()), } @@ -396,11 +390,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl let interpreter = ScriptInterpreter::discover( (&script).into(), python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, active.map_or(Some(false), Some), @@ -559,9 +551,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl // If we're isolating the environment, use an ephemeral virtual environment as the // base environment for the project. let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); // Resolve the Python request and requirement for the workspace. let WorkspacePython { @@ -617,11 +609,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl project.workspace(), python.as_deref().map(PythonRequest::parse), &install_mirrors, + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, no_config, active, cache, @@ -664,16 +654,14 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl mode, project.workspace().into(), settings.as_ref().into(), + &network_settings, &lock_state, if show_resolution { Box::new(DefaultResolveLogger) } else { Box::new(SummaryResolveLogger) }, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -682,9 +670,11 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl { Ok(result) => result, Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) - .report(err) - .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) + return diagnostics::OperationDiagnostic::native_tls( + network_settings.native_tls, + ) + .report(err) + .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } Err(err) => return Err(err.into()), }; @@ -750,6 +740,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl install_options, modifications, settings.as_ref().into(), + &network_settings, &sync_state, if show_resolution { Box::new(DefaultInstallLogger) @@ -757,10 +748,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl Box::new(SummaryInstallLogger) }, installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, DryRun::Disabled, printer, @@ -770,9 +758,11 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl { Ok(()) => {} Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) - .report(err) - .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) + return diagnostics::OperationDiagnostic::native_tls( + network_settings.native_tls, + ) + .report(err) + .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } Err(err) => return Err(err.into()), } @@ -789,9 +779,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl let interpreter = { let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); // (1) Explicit request from user let python_request = if let Some(request) = python.as_deref() { @@ -857,9 +847,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl None } else { let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); let spec = RequirementsSpecification::from_simple_sources(&requirements, &client_builder).await?; @@ -881,6 +871,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl ), &base_interpreter, &settings, + &network_settings, &sync_state, if show_resolution { Box::new(DefaultResolveLogger) @@ -893,10 +884,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl Box::new(SummaryInstallLogger) }, installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -906,10 +894,12 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl let environment = match result { Ok(resolution) => resolution, Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) - .with_context("`--with`") - .report(err) - .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) + return diagnostics::OperationDiagnostic::native_tls( + network_settings.native_tls, + ) + .with_context("`--with`") + .report(err) + .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } Err(err) => return Err(err.into()), }; @@ -1362,12 +1352,10 @@ impl RunCommand { #[allow(clippy::fn_params_excessive_bools)] pub(crate) async fn from_args( command: &ExternalCommand, + network_settings: NetworkSettings, module: bool, script: bool, gui_script: bool, - connectivity: Connectivity, - native_tls: bool, - allow_insecure_host: &[TrustedHost], ) -> anyhow::Result { let (target, args) = command.split(); let Some(target) = target else { @@ -1409,9 +1397,9 @@ impl RunCommand { .tempfile()?; let client = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()) + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .build(); let response = client.for_host(&url).get(url.clone()).send().await?; diff --git a/crates/uv/src/commands/project/sync.rs b/crates/uv/src/commands/project/sync.rs index d45a9d54d..add777206 100644 --- a/crates/uv/src/commands/project/sync.rs +++ b/crates/uv/src/commands/project/sync.rs @@ -8,10 +8,10 @@ use itertools::Itertools; use owo_colors::OwoColorize; use uv_cache::Cache; -use uv_client::{Connectivity, FlatIndexClient, RegistryClientBuilder}; +use uv_client::{FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ Concurrency, Constraints, DevGroupsManifest, DevGroupsSpecification, DryRun, EditableMode, - ExtrasSpecification, HashCheckingMode, InstallOptions, PreviewMode, TrustedHost, + ExtrasSpecification, HashCheckingMode, InstallOptions, PreviewMode, }; use uv_dispatch::BuildDispatch; use uv_distribution_types::{ @@ -43,7 +43,7 @@ use crate::commands::project::{ }; use crate::commands::{diagnostics, ExitStatus}; use crate::printer::Printer; -use crate::settings::{InstallerSettingsRef, ResolverInstallerSettings}; +use crate::settings::{InstallerSettingsRef, NetworkSettings, ResolverInstallerSettings}; /// Sync the project environment. #[allow(clippy::fn_params_excessive_bools)] @@ -65,12 +65,10 @@ pub(crate) async fn sync( python_preference: PythonPreference, python_downloads: PythonDownloads, settings: ResolverInstallerSettings, + network_settings: NetworkSettings, script: Option, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], no_config: bool, cache: &Cache, printer: Printer, @@ -125,11 +123,9 @@ pub(crate) async fn sync( project.workspace(), python.as_deref().map(PythonRequest::parse), &install_mirrors, + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, no_config, active, cache, @@ -142,11 +138,9 @@ pub(crate) async fn sync( ScriptEnvironment::get_or_init( Pep723ItemRef::Script(script), python.as_deref().map(PythonRequest::parse), + &network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, active, @@ -284,14 +278,12 @@ pub(crate) async fn sync( spec, modifications, &settings, + &network_settings, &PlatformState::default(), Box::new(DefaultResolveLogger), Box::new(DefaultInstallLogger), installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, dry_run, printer, @@ -301,9 +293,11 @@ pub(crate) async fn sync( { Ok(..) => return Ok(ExitStatus::Success), Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) - .report(err) - .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) + return diagnostics::OperationDiagnostic::native_tls( + network_settings.native_tls, + ) + .report(err) + .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } Err(err) => return Err(err.into()), } @@ -333,12 +327,10 @@ pub(crate) async fn sync( mode, lock_target, settings.as_ref().into(), + &network_settings, &state, Box::new(DefaultResolveLogger), - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -386,7 +378,7 @@ pub(crate) async fn sync( result.into_lock() } Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } @@ -458,13 +450,11 @@ pub(crate) async fn sync( install_options, modifications, settings.as_ref().into(), + &network_settings, &state, Box::new(DefaultInstallLogger), installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, dry_run, printer, @@ -474,7 +464,7 @@ pub(crate) async fn sync( { Ok(()) => {} Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } @@ -522,13 +512,11 @@ pub(super) async fn do_sync( install_options: InstallOptions, modifications: Modifications, settings: InstallerSettingsRef<'_>, + network_settings: &NetworkSettings, state: &PlatformState, logger: Box, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, dry_run: DryRun, printer: Printer, @@ -632,12 +620,12 @@ pub(super) async fn do_sync( // Initialize the registry client. let client = RegistryClientBuilder::new(cache.clone()) - .native_tls(native_tls) - .connectivity(connectivity) + .native_tls(network_settings.native_tls) + .connectivity(network_settings.connectivity) .index_urls(index_locations.index_urls()) .index_strategy(index_strategy) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .markers(venv.interpreter().markers()) .platform(venv.interpreter().platform()) .build(); diff --git a/crates/uv/src/commands/project/tree.rs b/crates/uv/src/commands/project/tree.rs index e46b2761f..eb6ff4990 100644 --- a/crates/uv/src/commands/project/tree.rs +++ b/crates/uv/src/commands/project/tree.rs @@ -6,10 +6,8 @@ use futures::StreamExt; use tokio::sync::Semaphore; use uv_cache::{Cache, Refresh}; use uv_cache_info::Timestamp; -use uv_client::{Connectivity, RegistryClientBuilder}; -use uv_configuration::{ - Concurrency, DevGroupsSpecification, PreviewMode, TargetTriple, TrustedHost, -}; +use uv_client::RegistryClientBuilder; +use uv_configuration::{Concurrency, DevGroupsSpecification, PreviewMode, TargetTriple}; use uv_distribution_types::IndexCapabilities; use uv_pep508::PackageName; use uv_python::{PythonDownloads, PythonPreference, PythonRequest, PythonVersion}; @@ -29,7 +27,7 @@ use crate::commands::project::{ use crate::commands::reporters::LatestVersionReporter; use crate::commands::{diagnostics, ExitStatus}; use crate::printer::Printer; -use crate::settings::ResolverSettings; +use crate::settings::{NetworkSettings, ResolverSettings}; /// Run a command. #[allow(clippy::fn_params_excessive_bools)] @@ -50,13 +48,11 @@ pub(crate) async fn tree( python: Option, install_mirrors: PythonInstallMirrors, settings: ResolverSettings, + network_settings: &NetworkSettings, script: Option, python_preference: PythonPreference, python_downloads: PythonDownloads, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], no_config: bool, cache: &Cache, printer: Printer, @@ -77,6 +73,8 @@ pub(crate) async fn tree( LockTarget::Script(_) => vec![], }; + let native_tls = network_settings.native_tls; + // Find an interpreter for the project, unless `--frozen` and `--universal` are both set. let interpreter = if frozen && universal { None @@ -85,11 +83,9 @@ pub(crate) async fn tree( LockTarget::Script(script) => ScriptInterpreter::discover( Pep723ItemRef::Script(script), python.as_deref().map(PythonRequest::parse), + network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, Some(false), @@ -102,11 +98,9 @@ pub(crate) async fn tree( workspace, project_dir, python.as_deref().map(PythonRequest::parse), + network_settings, python_preference, python_downloads, - connectivity, - native_tls, - allow_insecure_host, &install_mirrors, no_config, Some(false), @@ -138,12 +132,10 @@ pub(crate) async fn tree( mode, target, settings.as_ref(), + network_settings, &state, Box::new(DefaultResolveLogger), - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -211,10 +203,10 @@ pub(crate) async fn tree( let client = RegistryClientBuilder::new( cache.clone().with_refresh(Refresh::All(Timestamp::now())), ) - .native_tls(native_tls) - .connectivity(connectivity) + .native_tls(network_settings.native_tls) + .connectivity(network_settings.connectivity) .keyring(*keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .build(); let download_concurrency = Semaphore::new(concurrency.downloads); diff --git a/crates/uv/src/commands/publish.rs b/crates/uv/src/commands/publish.rs index 898348c64..bcb1cf581 100644 --- a/crates/uv/src/commands/publish.rs +++ b/crates/uv/src/commands/publish.rs @@ -1,6 +1,7 @@ use crate::commands::reporters::PublishReporter; use crate::commands::{human_readable_bytes, ExitStatus}; use crate::printer::Printer; +use crate::settings::NetworkSettings; use anyhow::{bail, Context, Result}; use console::Term; use owo_colors::OwoColorize; @@ -12,10 +13,8 @@ use tokio::sync::Semaphore; use tracing::{debug, info}; use url::Url; use uv_cache::Cache; -use uv_client::{ - AuthIntegration, BaseClient, BaseClientBuilder, Connectivity, RegistryClientBuilder, -}; -use uv_configuration::{KeyringProviderType, TrustedHost, TrustedPublishing}; +use uv_client::{AuthIntegration, BaseClient, BaseClientBuilder, RegistryClientBuilder}; +use uv_configuration::{KeyringProviderType, TrustedPublishing}; use uv_distribution_types::{Index, IndexCapabilities, IndexLocations, IndexUrl}; use uv_publish::{ check_trusted_publishing, files_for_publishing, upload, CheckUrlClient, TrustedPublishResult, @@ -27,16 +26,14 @@ pub(crate) async fn publish( publish_url: Url, trusted_publishing: TrustedPublishing, keyring_provider: KeyringProviderType, - allow_insecure_host: &[TrustedHost], + network_settings: &NetworkSettings, username: Option, password: Option, check_url: Option, cache: &Cache, - connectivity: Connectivity, - native_tls: bool, printer: Printer, ) -> Result { - if connectivity.is_offline() { + if network_settings.connectivity.is_offline() { bail!("Unable to publish files in offline mode"); } @@ -59,8 +56,8 @@ pub(crate) async fn publish( let upload_client = BaseClientBuilder::new() .retries(0) .keyring(keyring_provider) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) // Don't try cloning the request to make an unauthenticated request first. .auth_integration(AuthIntegration::OnlyAuthenticated) // Set a very high timeout for uploads, connections are often 10x slower on upload than @@ -95,11 +92,11 @@ pub(crate) async fn publish( ) .index_urls(); let registry_client_builder = RegistryClientBuilder::new(cache.clone()) - .native_tls(native_tls) - .connectivity(connectivity) + .native_tls(network_settings.native_tls) + .connectivity(network_settings.connectivity) .index_urls(index_urls) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()); + .allow_insecure_host(network_settings.allow_insecure_host.clone()); Some(CheckUrlClient { index_url: index_url.clone(), registry_client_builder, diff --git a/crates/uv/src/commands/python/install.rs b/crates/uv/src/commands/python/install.rs index d64d219bf..23bb11fe6 100644 --- a/crates/uv/src/commands/python/install.rs +++ b/crates/uv/src/commands/python/install.rs @@ -11,9 +11,7 @@ use owo_colors::OwoColorize; use rustc_hash::{FxHashMap, FxHashSet}; use tracing::{debug, trace}; -use uv_client::Connectivity; use uv_configuration::PreviewMode; -use uv_configuration::TrustedHost; use uv_fs::Simplified; use uv_python::downloads::{self, DownloadResult, ManagedPythonDownload, PythonDownloadRequest}; use uv_python::managed::{ @@ -32,6 +30,7 @@ use crate::commands::python::{ChangeEvent, ChangeEventKind}; use crate::commands::reporters::PythonDownloadReporter; use crate::commands::{elapsed, ExitStatus}; use crate::printer::Printer; +use crate::settings::NetworkSettings; #[derive(Debug, Clone)] struct InstallRequest { @@ -131,11 +130,9 @@ pub(crate) async fn install( force: bool, python_install_mirror: Option, pypy_install_mirror: Option, + network_settings: NetworkSettings, default: bool, python_downloads: PythonDownloads, - native_tls: bool, - connectivity: Connectivity, - allow_insecure_host: &[TrustedHost], no_config: bool, preview: PreviewMode, printer: Printer, @@ -296,9 +293,9 @@ pub(crate) async fn install( // Download and unpack the Python versions concurrently let client = uv_client::BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()) + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .build(); let reporter = PythonDownloadReporter::new(printer, downloads.len() as u64); let mut tasks = FuturesUnordered::new(); diff --git a/crates/uv/src/commands/tool/install.rs b/crates/uv/src/commands/tool/install.rs index 6cedbfb6b..4b94fed10 100644 --- a/crates/uv/src/commands/tool/install.rs +++ b/crates/uv/src/commands/tool/install.rs @@ -7,8 +7,8 @@ use tracing::{debug, trace}; use uv_cache::{Cache, Refresh}; use uv_cache_info::Timestamp; -use uv_client::{BaseClientBuilder, Connectivity}; -use uv_configuration::{Concurrency, DryRun, PreviewMode, Reinstall, TrustedHost, Upgrade}; +use uv_client::BaseClientBuilder; +use uv_configuration::{Concurrency, DryRun, PreviewMode, Reinstall, Upgrade}; use uv_distribution_types::{NameRequirementSpecification, UnresolvedRequirementSpecification}; use uv_normalize::PackageName; use uv_pep440::{VersionSpecifier, VersionSpecifiers}; @@ -34,7 +34,7 @@ use crate::commands::tool::{Target, ToolRequest}; use crate::commands::ExitStatus; use crate::commands::{diagnostics, reporters::PythonDownloadReporter}; use crate::printer::Printer; -use crate::settings::ResolverInstallerSettings; +use crate::settings::{NetworkSettings, ResolverInstallerSettings}; /// Install a tool. #[allow(clippy::fn_params_excessive_bools)] @@ -50,21 +50,19 @@ pub(crate) async fn install( force: bool, options: ResolverInstallerOptions, settings: ResolverInstallerSettings, + network_settings: NetworkSettings, python_preference: PythonPreference, python_downloads: PythonDownloads, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: Cache, printer: Printer, preview: PreviewMode, ) -> Result { let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); let reporter = PythonDownloadReporter::single(printer); @@ -90,9 +88,9 @@ pub(crate) async fn install( let state = PlatformState::default(); let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); // Parse the input requirement. let request = ToolRequest::parse(&package, from.as_deref()); @@ -131,11 +129,9 @@ pub(crate) async fn install( requirement, &interpreter, &settings, + &network_settings, &state, - connectivity, concurrency, - native_tls, - allow_insecure_host, &cache, printer, preview, @@ -245,11 +241,9 @@ pub(crate) async fn install( spec.requirements.clone(), &interpreter, &settings, + &network_settings, &state, - connectivity, concurrency, - native_tls, - allow_insecure_host, &cache, printer, preview, @@ -271,11 +265,9 @@ pub(crate) async fn install( spec.overrides, &interpreter, &settings, + &network_settings, &state, - connectivity, concurrency, - native_tls, - allow_insecure_host, &cache, printer, preview, @@ -401,14 +393,12 @@ pub(crate) async fn install( spec, Modifications::Exact, &settings, + &network_settings, &state, Box::new(DefaultResolveLogger), Box::new(DefaultInstallLogger), installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, &cache, DryRun::Disabled, printer, @@ -418,7 +408,7 @@ pub(crate) async fn install( { Ok(update) => update.into_environment(), Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } @@ -441,12 +431,10 @@ pub(crate) async fn install( spec.clone(), &interpreter, settings.as_ref().into(), + &network_settings, &state, Box::new(DefaultResolveLogger), - connectivity, concurrency, - native_tls, - allow_insecure_host, &cache, printer, preview, @@ -478,9 +466,11 @@ pub(crate) async fn install( .await .ok() .flatten() else { - return diagnostics::OperationDiagnostic::native_tls(native_tls) - .report(err) - .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())); + return diagnostics::OperationDiagnostic::native_tls( + network_settings.native_tls, + ) + .report(err) + .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())); }; debug!( @@ -493,12 +483,10 @@ pub(crate) async fn install( spec, &interpreter, settings.as_ref().into(), + &network_settings, &state, Box::new(DefaultResolveLogger), - connectivity, concurrency, - native_tls, - allow_insecure_host, &cache, printer, preview, @@ -507,9 +495,11 @@ pub(crate) async fn install( { Ok(resolution) => (resolution, interpreter), Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) - .report(err) - .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())); + return diagnostics::OperationDiagnostic::native_tls( + network_settings.native_tls, + ) + .report(err) + .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())); } Err(err) => return Err(err.into()), } @@ -532,13 +522,11 @@ pub(crate) async fn install( &resolution.into(), Modifications::Exact, settings.as_ref().into(), + &network_settings, &state, Box::new(DefaultInstallLogger), installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, &cache, printer, preview, @@ -551,7 +539,7 @@ pub(crate) async fn install( }) { Ok(environment) => environment, Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) } diff --git a/crates/uv/src/commands/tool/run.rs b/crates/uv/src/commands/tool/run.rs index 52e70c023..6a057f5d7 100644 --- a/crates/uv/src/commands/tool/run.rs +++ b/crates/uv/src/commands/tool/run.rs @@ -13,8 +13,8 @@ use tracing::{debug, warn}; use uv_cache::{Cache, Refresh}; use uv_cache_info::Timestamp; use uv_cli::ExternalCommand; -use uv_client::{BaseClientBuilder, Connectivity}; -use uv_configuration::{Concurrency, PreviewMode, TrustedHost}; +use uv_client::BaseClientBuilder; +use uv_configuration::{Concurrency, PreviewMode}; use uv_distribution_types::{Name, UnresolvedRequirement, UnresolvedRequirementSpecification}; use uv_installer::{SatisfiesResult, SitePackages}; use uv_normalize::PackageName; @@ -45,6 +45,7 @@ use crate::commands::tool::{Target, ToolRequest}; use crate::commands::ExitStatus; use crate::commands::{diagnostics, project::environment::CachedEnvironment}; use crate::printer::Printer; +use crate::settings::NetworkSettings; use crate::settings::ResolverInstallerSettings; /// The user-facing command used to invoke a tool run. @@ -75,15 +76,13 @@ pub(crate) async fn run( python: Option, install_mirrors: PythonInstallMirrors, settings: ResolverInstallerSettings, + network_settings: NetworkSettings, invocation_source: ToolRunCommand, isolated: bool, python_preference: PythonPreference, python_downloads: PythonDownloads, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: Cache, printer: Printer, preview: PreviewMode, @@ -121,14 +120,12 @@ pub(crate) async fn run( python.as_deref(), install_mirrors, &settings, + &network_settings, isolated, python_preference, python_downloads, installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, &cache, printer, preview, @@ -138,7 +135,7 @@ pub(crate) async fn run( let (from, environment) = match result { Ok(resolution) => resolution, Err(ProjectError::Operation(err)) => { - return diagnostics::OperationDiagnostic::native_tls(native_tls) + return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls) .with_context("tool") .report(err) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) @@ -453,22 +450,20 @@ async fn get_or_create_environment( python: Option<&str>, install_mirrors: PythonInstallMirrors, settings: &ResolverInstallerSettings, + network_settings: &NetworkSettings, isolated: bool, python_preference: PythonPreference, python_downloads: PythonDownloads, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, preview: PreviewMode, ) -> Result<(ToolRequirement, PythonEnvironment), ProjectError> { let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); let reporter = PythonDownloadReporter::single(printer); @@ -560,11 +555,9 @@ async fn get_or_create_environment( vec![spec], &interpreter, settings, + network_settings, &state, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -640,9 +633,9 @@ async fn get_or_create_environment( // Read the `--with` requirements. let spec = { let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); RequirementsSpecification::from_simple_sources(with, &client_builder).await? }; @@ -658,11 +651,9 @@ async fn get_or_create_environment( spec.requirements.clone(), &interpreter, settings, + network_settings, &state, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -727,6 +718,7 @@ async fn get_or_create_environment( spec.clone(), &interpreter, settings, + network_settings, &state, if show_resolution { Box::new(DefaultResolveLogger) @@ -739,10 +731,7 @@ async fn get_or_create_environment( Box::new(SummaryInstallLogger) }, installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -786,6 +775,7 @@ async fn get_or_create_environment( spec, &interpreter, settings, + network_settings, &state, if show_resolution { Box::new(DefaultResolveLogger) @@ -798,10 +788,7 @@ async fn get_or_create_environment( Box::new(SummaryInstallLogger) }, installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, diff --git a/crates/uv/src/commands/tool/upgrade.rs b/crates/uv/src/commands/tool/upgrade.rs index bfd7ee194..cbf785069 100644 --- a/crates/uv/src/commands/tool/upgrade.rs +++ b/crates/uv/src/commands/tool/upgrade.rs @@ -6,8 +6,8 @@ use std::fmt::Write; use tracing::debug; use uv_cache::Cache; -use uv_client::{BaseClientBuilder, Connectivity}; -use uv_configuration::{Concurrency, DryRun, PreviewMode, TrustedHost}; +use uv_client::BaseClientBuilder; +use uv_configuration::{Concurrency, DryRun, PreviewMode}; use uv_fs::CWD; use uv_normalize::PackageName; use uv_pypi_types::Requirement; @@ -30,22 +30,20 @@ use crate::commands::reporters::PythonDownloadReporter; use crate::commands::tool::common::remove_entrypoints; use crate::commands::{conjunction, tool::common::install_executables, ExitStatus}; use crate::printer::Printer; -use crate::settings::ResolverInstallerSettings; +use crate::settings::{NetworkSettings, ResolverInstallerSettings}; /// Upgrade a tool. pub(crate) async fn upgrade( names: Vec, python: Option, install_mirrors: PythonInstallMirrors, - connectivity: Connectivity, args: ResolverInstallerOptions, filesystem: ResolverInstallerOptions, + network_settings: NetworkSettings, python_preference: PythonPreference, python_downloads: PythonDownloads, installer_metadata: bool, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], cache: &Cache, printer: Printer, preview: PreviewMode, @@ -81,9 +79,9 @@ pub(crate) async fn upgrade( let reporter = PythonDownloadReporter::single(printer); let client_builder = BaseClientBuilder::new() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); let python_request = python.as_deref().map(PythonRequest::parse); @@ -123,13 +121,11 @@ pub(crate) async fn upgrade( printer, &installed_tools, &args, + &network_settings, cache, &filesystem, installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, preview, ) .await; @@ -216,13 +212,11 @@ async fn upgrade_tool( printer: Printer, installed_tools: &InstalledTools, args: &ResolverInstallerOptions, + network_settings: &NetworkSettings, cache: &Cache, filesystem: &ResolverInstallerOptions, installer_metadata: bool, - connectivity: Connectivity, concurrency: Concurrency, - native_tls: bool, - allow_insecure_host: &[TrustedHost], preview: PreviewMode, ) -> Result { // Ensure the tool is installed. @@ -298,12 +292,10 @@ async fn upgrade_tool( spec.into(), interpreter, settings.as_ref().into(), + network_settings, &state, Box::new(SummaryResolveLogger), - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -317,13 +309,11 @@ async fn upgrade_tool( &resolution.into(), Modifications::Exact, settings.as_ref().into(), + network_settings, &state, Box::new(DefaultInstallLogger), installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, printer, preview, @@ -343,14 +333,12 @@ async fn upgrade_tool( spec, Modifications::Exact, &settings, + network_settings, &state, Box::new(SummaryResolveLogger), Box::new(UpgradeInstallLogger::new(name.clone())), installer_metadata, - connectivity, concurrency, - native_tls, - allow_insecure_host, cache, DryRun::Disabled, printer, diff --git a/crates/uv/src/commands/venv.rs b/crates/uv/src/commands/venv.rs index 64d24ec94..e9928a899 100644 --- a/crates/uv/src/commands/venv.rs +++ b/crates/uv/src/commands/venv.rs @@ -11,10 +11,10 @@ use owo_colors::OwoColorize; use thiserror::Error; use uv_cache::Cache; -use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; +use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder}; use uv_configuration::{ BuildOptions, Concurrency, ConfigSettings, Constraints, IndexStrategy, KeyringProviderType, - NoBinary, NoBuild, PreviewMode, SourceStrategy, TrustedHost, + NoBinary, NoBuild, PreviewMode, SourceStrategy, }; use uv_dispatch::{BuildDispatch, SharedState}; use uv_distribution_types::{DependencyMetadata, Index, IndexLocations}; @@ -37,6 +37,7 @@ use crate::commands::project::{validate_project_requires_python, WorkspacePython use crate::commands::reporters::PythonDownloadReporter; use crate::commands::ExitStatus; use crate::printer::Printer; +use crate::settings::NetworkSettings; /// Create a virtual environment. #[allow(clippy::unnecessary_wraps, clippy::fn_params_excessive_bools)] @@ -52,15 +53,13 @@ pub(crate) async fn venv( index_strategy: IndexStrategy, dependency_metadata: DependencyMetadata, keyring_provider: KeyringProviderType, - allow_insecure_host: &[TrustedHost], + network_settings: &NetworkSettings, prompt: uv_virtualenv::Prompt, system_site_packages: bool, - connectivity: Connectivity, seed: bool, allow_existing: bool, exclude_newer: Option, concurrency: Concurrency, - native_tls: bool, no_config: bool, no_project: bool, cache: &Cache, @@ -78,17 +77,15 @@ pub(crate) async fn venv( index_strategy, dependency_metadata, keyring_provider, - allow_insecure_host, + network_settings, prompt, system_site_packages, - connectivity, seed, python_preference, python_downloads, allow_existing, exclude_newer, concurrency, - native_tls, no_config, no_project, cache, @@ -137,17 +134,15 @@ async fn venv_impl( index_strategy: IndexStrategy, dependency_metadata: DependencyMetadata, keyring_provider: KeyringProviderType, - allow_insecure_host: &[TrustedHost], + network_settings: &NetworkSettings, prompt: uv_virtualenv::Prompt, system_site_packages: bool, - connectivity: Connectivity, seed: bool, python_preference: PythonPreference, python_downloads: PythonDownloads, allow_existing: bool, exclude_newer: Option, concurrency: Concurrency, - native_tls: bool, no_config: bool, no_project: bool, cache: &Cache, @@ -193,9 +188,9 @@ async fn venv_impl( ); let client_builder = BaseClientBuilder::default() - .connectivity(connectivity) - .native_tls(native_tls) - .allow_insecure_host(allow_insecure_host.to_vec()); + .connectivity(network_settings.connectivity) + .native_tls(network_settings.native_tls) + .allow_insecure_host(network_settings.allow_insecure_host.clone()); let reporter = PythonDownloadReporter::single(printer); @@ -300,7 +295,7 @@ async fn venv_impl( .index_urls(index_locations.index_urls()) .index_strategy(index_strategy) .keyring(keyring_provider) - .allow_insecure_host(allow_insecure_host.to_vec()) + .allow_insecure_host(network_settings.allow_insecure_host.clone()) .markers(interpreter.markers()) .platform(interpreter.platform()) .build(); diff --git a/crates/uv/src/lib.rs b/crates/uv/src/lib.rs index 37cad2117..11cc2ff30 100644 --- a/crates/uv/src/lib.rs +++ b/crates/uv/src/lib.rs @@ -150,12 +150,10 @@ async fn run(mut cli: Cli) -> Result { Some( RunCommand::from_args( command, + settings.network_settings, *module, *script, *gui_script, - settings.connectivity, - settings.native_tls, - &settings.allow_insecure_host, ) .await?, ) @@ -424,9 +422,8 @@ async fn run(mut cli: Cli) -> Result { args.settings.index_strategy, args.settings.dependency_metadata, args.settings.keyring_provider, - &globals.allow_insecure_host, + &globals.network_settings, args.settings.config_setting, - globals.connectivity, args.settings.no_build_isolation, args.settings.no_build_isolation_package, args.settings.build_options, @@ -441,7 +438,6 @@ async fn run(mut cli: Cli) -> Result { args.settings.system, globals.python_preference, globals.concurrency, - globals.native_tls, globals.quiet, cache, printer, @@ -493,9 +489,9 @@ async fn run(mut cli: Cli) -> Result { args.settings.index_strategy, args.settings.dependency_metadata, args.settings.keyring_provider, + &globals.network_settings, args.settings.allow_empty_requirements, globals.installer_metadata, - globals.connectivity, &args.settings.config_setting, args.settings.no_build_isolation, args.settings.no_build_isolation_package, @@ -512,8 +508,6 @@ async fn run(mut cli: Cli) -> Result { args.settings.sources, globals.python_preference, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, cache, args.dry_run, printer, @@ -583,12 +577,12 @@ async fn run(mut cli: Cli) -> Result { args.settings.index_strategy, args.settings.dependency_metadata, args.settings.keyring_provider, + &globals.network_settings, args.settings.reinstall, args.settings.link_mode, args.settings.compile_bytecode, args.settings.hash_checking, globals.installer_metadata, - globals.connectivity, &args.settings.config_setting, args.settings.no_build_isolation, args.settings.no_build_isolation_package, @@ -606,8 +600,6 @@ async fn run(mut cli: Cli) -> Result { args.settings.prefix, globals.python_preference, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, cache, args.dry_run, printer, @@ -642,10 +634,8 @@ async fn run(mut cli: Cli) -> Result { args.settings.target, args.settings.prefix, cache, - globals.connectivity, - globals.native_tls, args.settings.keyring_provider, - &globals.allow_insecure_host, + &globals.network_settings, args.dry_run, printer, ) @@ -692,14 +682,12 @@ async fn run(mut cli: Cli) -> Result { args.settings.index_locations, args.settings.index_strategy, args.settings.keyring_provider, - globals.allow_insecure_host, - globals.connectivity, + &globals.network_settings, globals.concurrency, args.settings.strict, args.settings.exclude_newer, args.settings.python.as_deref(), args.settings.system, - globals.native_tls, &cache, printer, ) @@ -746,14 +734,12 @@ async fn run(mut cli: Cli) -> Result { args.settings.index_locations, args.settings.index_strategy, args.settings.keyring_provider, - globals.allow_insecure_host, - globals.connectivity, + globals.network_settings, globals.concurrency, args.settings.strict, args.settings.exclude_newer, args.settings.python.as_deref(), args.settings.system, - globals.native_tls, &cache, printer, ) @@ -829,13 +815,11 @@ async fn run(mut cli: Cli) -> Result { args.python, args.install_mirrors, args.settings, + &globals.network_settings, cli.top_level.no_config, globals.python_preference, globals.python_downloads, - globals.connectivity, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, &cache, printer, globals.preview, @@ -885,15 +869,13 @@ async fn run(mut cli: Cli) -> Result { args.settings.index_strategy, args.settings.dependency_metadata, args.settings.keyring_provider, - &globals.allow_insecure_host, + &globals.network_settings, uv_virtualenv::Prompt::from_args(prompt), args.system_site_packages, - globals.connectivity, args.seed, args.allow_existing, args.settings.exclude_newer, globals.concurrency, - globals.native_tls, cli.top_level.no_config, args.no_project, &cache, @@ -1010,15 +992,13 @@ async fn run(mut cli: Cli) -> Result { args.python, args.install_mirrors, args.settings, + globals.network_settings, invocation_source, args.isolated, globals.python_preference, globals.python_downloads, globals.installer_metadata, - globals.connectivity, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, cache, printer, globals.preview, @@ -1079,13 +1059,11 @@ async fn run(mut cli: Cli) -> Result { args.force, args.options, args.settings, + globals.network_settings, globals.python_preference, globals.python_downloads, globals.installer_metadata, - globals.connectivity, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, cache, printer, globals.preview, @@ -1124,15 +1102,13 @@ async fn run(mut cli: Cli) -> Result { args.names, args.python, args.install_mirrors, - globals.connectivity, args.args, args.filesystem, + globals.network_settings, globals.python_preference, globals.python_downloads, globals.installer_metadata, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, &cache, printer, globals.preview, @@ -1203,11 +1179,9 @@ async fn run(mut cli: Cli) -> Result { args.force, args.python_install_mirror, args.pypy_install_mirror, + globals.network_settings, args.default, globals.python_downloads, - globals.native_tls, - globals.connectivity, - &globals.allow_insecure_host, cli.top_level.no_config, globals.preview, printer, @@ -1347,13 +1321,11 @@ async fn run(mut cli: Cli) -> Result { publish_url, trusted_publishing, keyring_provider, - &globals.allow_insecure_host, + &globals.network_settings, username, password, check_url, &cache, - globals.connectivity, - globals.native_tls, printer, ) .await @@ -1447,11 +1419,9 @@ async fn run_project( args.python, args.install_mirrors, args.no_workspace, + &globals.network_settings, globals.python_preference, globals.python_downloads, - globals.connectivity, - globals.native_tls, - &globals.allow_insecure_host, no_config, &cache, printer, @@ -1510,13 +1480,11 @@ async fn run_project( args.python, args.install_mirrors, args.settings, + globals.network_settings, globals.python_preference, globals.python_downloads, globals.installer_metadata, - globals.connectivity, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, &cache, printer, args.env_file, @@ -1563,12 +1531,10 @@ async fn run_project( globals.python_preference, globals.python_downloads, args.settings, + globals.network_settings, script, globals.installer_metadata, - globals.connectivity, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, no_config, &cache, printer, @@ -1608,13 +1574,11 @@ async fn run_project( args.python, args.install_mirrors, args.settings, + globals.network_settings, script, globals.python_preference, globals.python_downloads, - globals.connectivity, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, no_config, &cache, printer, @@ -1677,14 +1641,12 @@ async fn run_project( args.python, args.install_mirrors, args.settings, + globals.network_settings, script, globals.python_preference, globals.python_downloads, globals.installer_metadata, - globals.connectivity, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, no_config, &cache, printer, @@ -1723,14 +1685,12 @@ async fn run_project( args.python, args.install_mirrors, args.settings, + globals.network_settings, script, globals.python_preference, globals.python_downloads, globals.installer_metadata, - globals.connectivity, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, no_config, &cache, printer, @@ -1770,13 +1730,11 @@ async fn run_project( args.python, args.install_mirrors, args.resolver, + &globals.network_settings, script, globals.python_preference, globals.python_downloads, - globals.connectivity, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, no_config, &cache, printer, @@ -1818,12 +1776,10 @@ async fn run_project( args.python, args.install_mirrors, args.settings, + globals.network_settings, globals.python_preference, globals.python_downloads, - globals.connectivity, globals.concurrency, - globals.native_tls, - &globals.allow_insecure_host, no_config, globals.quiet, &cache, diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index f483c03a4..8fe1b2dcc 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -59,10 +59,8 @@ pub(crate) struct GlobalSettings { pub(crate) quiet: bool, pub(crate) verbose: u8, pub(crate) color: ColorChoice, - pub(crate) native_tls: bool, + pub(crate) network_settings: NetworkSettings, pub(crate) concurrency: Concurrency, - pub(crate) connectivity: Connectivity, - pub(crate) allow_insecure_host: Vec, pub(crate) show_settings: bool, pub(crate) preview: PreviewMode, pub(crate) python_preference: PythonPreference, @@ -74,6 +72,7 @@ pub(crate) struct GlobalSettings { impl GlobalSettings { /// Resolve the [`GlobalSettings`] from the CLI and filesystem configuration. pub(crate) fn resolve(args: &GlobalArgs, workspace: Option<&FilesystemOptions>) -> Self { + let network_settings = NetworkSettings::resolve(args, workspace); Self { required_version: workspace .and_then(|workspace| workspace.globals.required_version.clone()), @@ -100,9 +99,7 @@ impl GlobalSettings { } else { ColorChoice::Auto }, - native_tls: flag(args.native_tls, args.no_native_tls) - .combine(workspace.and_then(|workspace| workspace.globals.native_tls)) - .unwrap_or(false), + network_settings, concurrency: Concurrency { downloads: env(env::CONCURRENT_DOWNLOADS) .combine(workspace.and_then(|workspace| workspace.globals.concurrent_downloads)) @@ -117,31 +114,6 @@ impl GlobalSettings { .map(NonZeroUsize::get) .unwrap_or_else(Concurrency::threads), }, - connectivity: if flag(args.offline, args.no_offline) - .combine(workspace.and_then(|workspace| workspace.globals.offline)) - .unwrap_or(false) - { - Connectivity::Offline - } else { - Connectivity::Online - }, - allow_insecure_host: args - .allow_insecure_host - .as_ref() - .map(|allow_insecure_host| { - allow_insecure_host - .iter() - .filter_map(|value| value.clone().into_option()) - }) - .into_iter() - .flatten() - .chain( - workspace - .and_then(|workspace| workspace.globals.allow_insecure_host.clone()) - .into_iter() - .flatten(), - ) - .collect(), show_settings: args.show_settings, preview: PreviewMode::from( flag(args.preview, args.no_preview) @@ -165,6 +137,52 @@ impl GlobalSettings { } } +/// The resolved network settings to use for any invocation of the CLI. +#[derive(Debug, Clone)] +pub(crate) struct NetworkSettings { + pub(crate) connectivity: Connectivity, + pub(crate) native_tls: bool, + pub(crate) allow_insecure_host: Vec, +} + +impl NetworkSettings { + pub(crate) fn resolve(args: &GlobalArgs, workspace: Option<&FilesystemOptions>) -> Self { + let connectivity = if flag(args.offline, args.no_offline) + .combine(workspace.and_then(|workspace| workspace.globals.offline)) + .unwrap_or(false) + { + Connectivity::Offline + } else { + Connectivity::Online + }; + let native_tls = flag(args.native_tls, args.no_native_tls) + .combine(workspace.and_then(|workspace| workspace.globals.native_tls)) + .unwrap_or(false); + let allow_insecure_host = args + .allow_insecure_host + .as_ref() + .map(|allow_insecure_host| { + allow_insecure_host + .iter() + .filter_map(|value| value.clone().into_option()) + }) + .into_iter() + .flatten() + .chain( + workspace + .and_then(|workspace| workspace.globals.allow_insecure_host.clone()) + .into_iter() + .flatten(), + ) + .collect(); + Self { + connectivity, + native_tls, + allow_insecure_host, + } + } +} + /// The resolved cache settings to use for any invocation of the CLI. #[allow(clippy::struct_excessive_bools)] #[derive(Debug, Clone)] diff --git a/crates/uv/tests/it/show_settings.rs b/crates/uv/tests/it/show_settings.rs index d9b5a3fef..be833e708 100644 --- a/crates/uv/tests/it/show_settings.rs +++ b/crates/uv/tests/it/show_settings.rs @@ -51,7 +51,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> { // Resolution should use the lowest direct version, and generate hashes. uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -60,14 +60,16 @@ fn resolve_uv_toml() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -216,14 +218,14 @@ fn resolve_uv_toml() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Resolution should use the highest version, and generate hashes. uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") .arg("requirements.in") - .arg("--resolution=highest"), @r###" + .arg("--resolution=highest"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -232,14 +234,16 @@ fn resolve_uv_toml() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -388,7 +392,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Resolution should use the highest version, and omit hashes. @@ -396,7 +400,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> { .arg("--show-settings") .arg("requirements.in") .arg("--resolution=highest") - .arg("--no-generate-hashes"), @r###" + .arg("--no-generate-hashes"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -405,14 +409,16 @@ fn resolve_uv_toml() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -561,7 +567,7 @@ fn resolve_uv_toml() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(()) @@ -601,7 +607,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { // Resolution should use the lowest direct version, and generate hashes. uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -610,14 +616,16 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -766,7 +774,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Remove the `uv.toml` file. @@ -775,7 +783,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { // Resolution should use the highest version, and omit hashes. uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -784,14 +792,16 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -910,7 +920,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Add configuration to the `pyproject.toml` file. @@ -928,7 +938,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { // Resolution should use the lowest direct version, and generate hashes. uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -937,14 +947,16 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -1093,7 +1105,7 @@ fn resolve_pyproject_toml() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(()) @@ -1125,7 +1137,7 @@ fn resolve_index_url() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -1134,14 +1146,16 @@ fn resolve_index_url() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -1319,7 +1333,7 @@ fn resolve_index_url() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Providing an additional index URL on the command-line should be merged with the @@ -1328,7 +1342,7 @@ fn resolve_index_url() -> anyhow::Result<()> { .arg("--show-settings") .arg("requirements.in") .arg("--extra-index-url") - .arg("https://test.pypi.org/simple"), @r###" + .arg("https://test.pypi.org/simple"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -1337,14 +1351,16 @@ fn resolve_index_url() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -1553,7 +1569,7 @@ fn resolve_index_url() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(()) @@ -1585,7 +1601,7 @@ fn resolve_find_links() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -1594,14 +1610,16 @@ fn resolve_find_links() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -1750,7 +1768,7 @@ fn resolve_find_links() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(()) @@ -1781,7 +1799,7 @@ fn resolve_top_level() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -1790,14 +1808,16 @@ fn resolve_top_level() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -1916,7 +1936,7 @@ fn resolve_top_level() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Write out to both the top-level (`tool.uv`) and the pip section (`tool.uv.pip`). The @@ -1940,7 +1960,7 @@ fn resolve_top_level() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -1949,14 +1969,16 @@ fn resolve_top_level() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -2134,14 +2156,14 @@ fn resolve_top_level() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // But the command-line should take precedence over both. uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") .arg("requirements.in") - .arg("--resolution=lowest-direct"), @r###" + .arg("--resolution=lowest-direct"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -2150,14 +2172,16 @@ fn resolve_top_level() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -2335,7 +2359,7 @@ fn resolve_top_level() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(()) @@ -2366,7 +2390,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") .arg("requirements.in") - .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @r###" + .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @r#" success: true exit_code: 0 ----- stdout ----- @@ -2375,14 +2399,16 @@ fn resolve_user_configuration() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -2501,7 +2527,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Add a local configuration to generate hashes. @@ -2515,7 +2541,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") .arg("requirements.in") - .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @r###" + .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @r#" success: true exit_code: 0 ----- stdout ----- @@ -2524,14 +2550,16 @@ fn resolve_user_configuration() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -2650,7 +2678,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Add a local configuration to override the user configuration. @@ -2664,7 +2692,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") .arg("requirements.in") - .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @r###" + .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @r#" success: true exit_code: 0 ----- stdout ----- @@ -2673,14 +2701,16 @@ fn resolve_user_configuration() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -2799,7 +2829,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // However, the user-level `tool.uv.pip` settings override the project-level `tool.uv` settings. @@ -2815,7 +2845,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") .arg("requirements.in") - .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @r###" + .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @r#" success: true exit_code: 0 ----- stdout ----- @@ -2824,14 +2854,16 @@ fn resolve_user_configuration() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -2950,7 +2982,7 @@ fn resolve_user_configuration() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(()) @@ -2985,7 +3017,7 @@ fn resolve_tool() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.tool_install(), context.temp_dir.path()) .arg("--show-settings") .arg("requirements.in") - .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @r###" + .env(EnvVars::XDG_CONFIG_HOME, xdg.path()), @r#" success: true exit_code: 0 ----- stdout ----- @@ -2994,14 +3026,16 @@ fn resolve_tool() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -3103,7 +3137,7 @@ fn resolve_tool() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(()) @@ -3144,7 +3178,7 @@ fn resolve_poetry_toml() -> anyhow::Result<()> { // Resolution should use the lowest direct version, and generate hashes. uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -3153,14 +3187,16 @@ fn resolve_poetry_toml() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -3279,7 +3315,7 @@ fn resolve_poetry_toml() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(()) @@ -3321,7 +3357,7 @@ fn resolve_both() -> anyhow::Result<()> { // Resolution should succeed, but warn that the `pip` section in `pyproject.toml` is ignored. uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -3330,14 +3366,16 @@ fn resolve_both() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -3487,7 +3525,7 @@ fn resolve_both() -> anyhow::Result<()> { ----- stderr ----- warning: Found both a `uv.toml` file and a `[tool.uv]` section in an adjacent `pyproject.toml`. The `[tool.uv]` section will be ignored in favor of the `uv.toml` file. - "### + "# ); Ok(()) @@ -3616,7 +3654,7 @@ fn resolve_config_file() -> anyhow::Result<()> { .arg("--show-settings") .arg("--config-file") .arg(config.path()) - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -3625,14 +3663,16 @@ fn resolve_config_file() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -3781,7 +3821,7 @@ fn resolve_config_file() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Write in `pyproject.toml` schema. @@ -3889,7 +3929,7 @@ fn resolve_skip_empty() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") .arg("requirements.in") - .current_dir(&child), @r###" + .current_dir(&child), @r#" success: true exit_code: 0 ----- stdout ----- @@ -3898,14 +3938,16 @@ fn resolve_skip_empty() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -4024,7 +4066,7 @@ fn resolve_skip_empty() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Adding a `tool.uv` section should cause us to ignore the `uv.toml`. @@ -4041,7 +4083,7 @@ fn resolve_skip_empty() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") .arg("requirements.in") - .current_dir(&child), @r###" + .current_dir(&child), @r#" success: true exit_code: 0 ----- stdout ----- @@ -4050,14 +4092,16 @@ fn resolve_skip_empty() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -4176,7 +4220,7 @@ fn resolve_skip_empty() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(()) @@ -4201,7 +4245,7 @@ fn allow_insecure_host() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("--show-settings") - .arg("requirements.in"), @r###" + .arg("requirements.in"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -4210,25 +4254,27 @@ fn allow_insecure_host() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [ + Host { + scheme: None, + host: "google.com", + port: None, + }, + Host { + scheme: None, + host: "example.com", + port: None, + }, + ], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [ - Host { - scheme: None, - host: "google.com", - port: None, - }, - Host { - scheme: None, - host: "example.com", - port: None, - }, - ], show_settings: true, preview: Disabled, python_preference: Managed, @@ -4347,7 +4393,7 @@ fn allow_insecure_host() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(()) @@ -4375,7 +4421,7 @@ fn index_priority() -> anyhow::Result<()> { .arg("requirements.in") .arg("--show-settings") .arg("--index-url") - .arg("https://cli.pypi.org/simple"), @r###" + .arg("https://cli.pypi.org/simple"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -4384,14 +4430,16 @@ fn index_priority() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -4571,14 +4619,14 @@ fn index_priority() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); uv_snapshot!(context.filters(), add_shared_args(context.pip_compile(), context.temp_dir.path()) .arg("requirements.in") .arg("--show-settings") .arg("--default-index") - .arg("https://cli.pypi.org/simple"), @r###" + .arg("https://cli.pypi.org/simple"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -4587,14 +4635,16 @@ fn index_priority() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -4774,7 +4824,7 @@ fn index_priority() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); let config = context.temp_dir.child("uv.toml"); @@ -4787,7 +4837,7 @@ fn index_priority() -> anyhow::Result<()> { .arg("requirements.in") .arg("--show-settings") .arg("--default-index") - .arg("https://cli.pypi.org/simple"), @r###" + .arg("https://cli.pypi.org/simple"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -4796,14 +4846,16 @@ fn index_priority() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -4983,7 +5035,7 @@ fn index_priority() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Prefer the `--index` from the CLI, but treat the index from the file as the default. @@ -4991,7 +5043,7 @@ fn index_priority() -> anyhow::Result<()> { .arg("requirements.in") .arg("--show-settings") .arg("--index") - .arg("https://cli.pypi.org/simple"), @r###" + .arg("https://cli.pypi.org/simple"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -5000,14 +5052,16 @@ fn index_priority() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -5187,7 +5241,7 @@ fn index_priority() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); let config = context.temp_dir.child("uv.toml"); @@ -5202,7 +5256,7 @@ fn index_priority() -> anyhow::Result<()> { .arg("requirements.in") .arg("--show-settings") .arg("--index-url") - .arg("https://cli.pypi.org/simple"), @r###" + .arg("https://cli.pypi.org/simple"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -5211,14 +5265,16 @@ fn index_priority() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -5398,7 +5454,7 @@ fn index_priority() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); // Prefer the `--extra-index-url` from the CLI, but not as the default. @@ -5406,7 +5462,7 @@ fn index_priority() -> anyhow::Result<()> { .arg("requirements.in") .arg("--show-settings") .arg("--extra-index-url") - .arg("https://cli.pypi.org/simple"), @r###" + .arg("https://cli.pypi.org/simple"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -5415,14 +5471,16 @@ fn index_priority() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -5602,7 +5660,7 @@ fn index_priority() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(()) @@ -5623,7 +5681,7 @@ fn verify_hashes() -> anyhow::Result<()> { uv_snapshot!(context.filters(), add_shared_args(context.pip_install(), context.temp_dir.path()) .arg("-r") .arg("requirements.in") - .arg("--show-settings"), @r###" + .arg("--show-settings"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -5632,14 +5690,16 @@ fn verify_hashes() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -5759,14 +5819,14 @@ fn verify_hashes() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); uv_snapshot!(context.filters(), add_shared_args(context.pip_install(), context.temp_dir.path()) .arg("-r") .arg("requirements.in") .arg("--no-verify-hashes") - .arg("--show-settings"), @r###" + .arg("--show-settings"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -5775,14 +5835,16 @@ fn verify_hashes() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -5900,14 +5962,14 @@ fn verify_hashes() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); uv_snapshot!(context.filters(), add_shared_args(context.pip_install(), context.temp_dir.path()) .arg("-r") .arg("requirements.in") .arg("--require-hashes") - .arg("--show-settings"), @r###" + .arg("--show-settings"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -5916,14 +5978,16 @@ fn verify_hashes() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -6043,14 +6107,14 @@ fn verify_hashes() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); uv_snapshot!(context.filters(), add_shared_args(context.pip_install(), context.temp_dir.path()) .arg("-r") .arg("requirements.in") .arg("--no-require-hashes") - .arg("--show-settings"), @r###" + .arg("--show-settings"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -6059,14 +6123,16 @@ fn verify_hashes() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -6184,14 +6250,14 @@ fn verify_hashes() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); uv_snapshot!(context.filters(), add_shared_args(context.pip_install(), context.temp_dir.path()) .arg("-r") .arg("requirements.in") .env(EnvVars::UV_NO_VERIFY_HASHES, "1") - .arg("--show-settings"), @r###" + .arg("--show-settings"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -6200,14 +6266,16 @@ fn verify_hashes() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -6325,7 +6393,7 @@ fn verify_hashes() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); uv_snapshot!(context.filters(), add_shared_args(context.pip_install(), context.temp_dir.path()) @@ -6333,7 +6401,7 @@ fn verify_hashes() -> anyhow::Result<()> { .arg("requirements.in") .arg("--verify-hashes") .arg("--no-require-hashes") - .arg("--show-settings"), @r###" + .arg("--show-settings"), @r#" success: true exit_code: 0 ----- stdout ----- @@ -6342,14 +6410,16 @@ fn verify_hashes() -> anyhow::Result<()> { quiet: false, verbose: 0, color: Auto, - native_tls: false, + network_settings: NetworkSettings { + connectivity: Online, + native_tls: false, + allow_insecure_host: [], + }, concurrency: Concurrency { downloads: 50, builds: 16, installs: 8, }, - connectivity: Online, - allow_insecure_host: [], show_settings: true, preview: Disabled, python_preference: Managed, @@ -6469,7 +6539,7 @@ fn verify_hashes() -> anyhow::Result<()> { } ----- stderr ----- - "### + "# ); Ok(())