Factor out network settings (#11839)

Three network settings are always passed together (though in random
method parameter orders). I factored these out into a struct to make planned future
changes easier.
This commit is contained in:
John Mumm 2025-02-28 10:05:17 +01:00 committed by GitHub
parent 0631d96717
commit 2e7ae19b55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 670 additions and 812 deletions

View File

@ -16,13 +16,13 @@ use crate::commands::project::{find_requires_python, ProjectError};
use crate::commands::reporters::PythonDownloadReporter; use crate::commands::reporters::PythonDownloadReporter;
use crate::commands::ExitStatus; use crate::commands::ExitStatus;
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::{ResolverSettings, ResolverSettingsRef}; use crate::settings::{NetworkSettings, ResolverSettings, ResolverSettingsRef};
use uv_build_backend::check_direct_build; use uv_build_backend::check_direct_build;
use uv_cache::{Cache, CacheBucket}; use uv_cache::{Cache, CacheBucket};
use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
use uv_configuration::{ use uv_configuration::{
BuildKind, BuildOptions, BuildOutput, Concurrency, ConfigSettings, Constraints, BuildKind, BuildOptions, BuildOutput, Concurrency, ConfigSettings, Constraints,
HashCheckingMode, IndexStrategy, KeyringProviderType, PreviewMode, SourceStrategy, TrustedHost, HashCheckingMode, IndexStrategy, KeyringProviderType, PreviewMode, SourceStrategy,
}; };
use uv_dispatch::{BuildDispatch, SharedState}; use uv_dispatch::{BuildDispatch, SharedState};
use uv_distribution_filename::{ use uv_distribution_filename::{
@ -107,13 +107,11 @@ pub(crate) async fn build_frontend(
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
settings: ResolverSettings, settings: ResolverSettings,
network_settings: &NetworkSettings,
no_config: bool, no_config: bool,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
@ -134,13 +132,11 @@ pub(crate) async fn build_frontend(
python.as_deref(), python.as_deref(),
install_mirrors, install_mirrors,
settings.as_ref(), settings.as_ref(),
network_settings,
no_config, no_config,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -179,13 +175,11 @@ async fn build_impl(
python_request: Option<&str>, python_request: Option<&str>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
settings: ResolverSettingsRef<'_>, settings: ResolverSettingsRef<'_>,
network_settings: &NetworkSettings,
no_config: bool, no_config: bool,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
@ -219,9 +213,9 @@ async fn build_impl(
} = settings; } = settings;
let client_builder = BaseClientBuilder::default() let client_builder = BaseClientBuilder::default()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
// Determine the source to build. // Determine the source to build.
let src = if let Some(src) = src { let src = if let Some(src) = src {
@ -339,11 +333,9 @@ async fn build_impl(
build_constraints, build_constraints,
no_build_isolation, no_build_isolation,
no_build_isolation_package, no_build_isolation_package,
native_tls, network_settings,
connectivity,
index_strategy, index_strategy,
keyring_provider, keyring_provider,
allow_insecure_host,
exclude_newer, exclude_newer,
sources, sources,
concurrency, concurrency,
@ -419,11 +411,9 @@ async fn build_package(
build_constraints: &[RequirementsSource], build_constraints: &[RequirementsSource],
no_build_isolation: bool, no_build_isolation: bool,
no_build_isolation_package: &[PackageName], no_build_isolation_package: &[PackageName],
native_tls: bool, network_settings: &NetworkSettings,
connectivity: Connectivity,
index_strategy: IndexStrategy, index_strategy: IndexStrategy,
keyring_provider: KeyringProviderType, keyring_provider: KeyringProviderType,
allow_insecure_host: &[TrustedHost],
exclude_newer: Option<ExcludeNewer>, exclude_newer: Option<ExcludeNewer>,
sources: SourceStrategy, sources: SourceStrategy,
concurrency: Concurrency, concurrency: Concurrency,
@ -528,12 +518,12 @@ async fn build_package(
// Initialize the registry client. // Initialize the registry client.
let client = RegistryClientBuilder::new(cache.clone()) let client = RegistryClientBuilder::new(cache.clone())
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.index_urls(index_locations.index_urls()) .index_urls(index_locations.index_urls())
.index_strategy(index_strategy) .index_strategy(index_strategy)
.keyring(keyring_provider) .keyring(keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.markers(interpreter.markers()) .markers(interpreter.markers())
.platform(interpreter.platform()) .platform(interpreter.platform())
.build(); .build();

View File

@ -11,11 +11,11 @@ use rustc_hash::FxHashSet;
use tracing::debug; use tracing::debug;
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
use uv_configuration::{ use uv_configuration::{
BuildOptions, Concurrency, ConfigSettings, Constraints, DevGroupsSpecification, BuildOptions, Concurrency, ConfigSettings, Constraints, DevGroupsSpecification,
ExtrasSpecification, IndexStrategy, NoBinary, NoBuild, PreviewMode, Reinstall, SourceStrategy, ExtrasSpecification, IndexStrategy, NoBinary, NoBuild, PreviewMode, Reinstall, SourceStrategy,
TrustedHost, Upgrade, Upgrade,
}; };
use uv_configuration::{KeyringProviderType, TargetTriple}; use uv_configuration::{KeyringProviderType, TargetTriple};
use uv_dispatch::{BuildDispatch, SharedState}; 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::pip::{operations, resolution_environment};
use crate::commands::{diagnostics, ExitStatus, OutputWriter}; use crate::commands::{diagnostics, ExitStatus, OutputWriter};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::NetworkSettings;
/// Resolve a set of requirements into a set of pinned versions. /// Resolve a set of requirements into a set of pinned versions.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -82,9 +83,8 @@ pub(crate) async fn pip_compile(
index_strategy: IndexStrategy, index_strategy: IndexStrategy,
dependency_metadata: DependencyMetadata, dependency_metadata: DependencyMetadata,
keyring_provider: KeyringProviderType, keyring_provider: KeyringProviderType,
allow_insecure_host: &[TrustedHost], network_settings: &NetworkSettings,
config_settings: ConfigSettings, config_settings: ConfigSettings,
connectivity: Connectivity,
no_build_isolation: bool, no_build_isolation: bool,
no_build_isolation_package: Vec<PackageName>, no_build_isolation_package: Vec<PackageName>,
build_options: BuildOptions, build_options: BuildOptions,
@ -99,7 +99,6 @@ pub(crate) async fn pip_compile(
system: bool, system: bool,
python_preference: PythonPreference, python_preference: PythonPreference,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
quiet: bool, quiet: bool,
cache: Cache, cache: Cache,
printer: Printer, printer: Printer,
@ -137,10 +136,10 @@ pub(crate) async fn pip_compile(
} }
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.keyring(keyring_provider) .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. // Read all requirements from the provided sources.
let RequirementsSpecification { let RequirementsSpecification {
@ -443,7 +442,7 @@ pub(crate) async fn pip_compile(
{ {
Ok(resolution) => resolution, Ok(resolution) => resolution,
Err(err) => { Err(err) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }

View File

@ -7,11 +7,11 @@ use owo_colors::OwoColorize;
use tracing::{debug, enabled, Level}; use tracing::{debug, enabled, Level};
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
use uv_configuration::{ use uv_configuration::{
BuildOptions, Concurrency, ConfigSettings, Constraints, DevGroupsSpecification, DryRun, BuildOptions, Concurrency, ConfigSettings, Constraints, DevGroupsSpecification, DryRun,
ExtrasSpecification, HashCheckingMode, IndexStrategy, PreviewMode, Reinstall, SourceStrategy, ExtrasSpecification, HashCheckingMode, IndexStrategy, PreviewMode, Reinstall, SourceStrategy,
TrustedHost, Upgrade, Upgrade,
}; };
use uv_configuration::{KeyringProviderType, TargetTriple}; use uv_configuration::{KeyringProviderType, TargetTriple};
use uv_dispatch::{BuildDispatch, SharedState}; 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::pip::{operations, resolution_markers, resolution_tags};
use crate::commands::{diagnostics, ExitStatus}; use crate::commands::{diagnostics, ExitStatus};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::NetworkSettings;
/// Install packages into the current environment. /// Install packages into the current environment.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -62,12 +63,12 @@ pub(crate) async fn pip_install(
index_strategy: IndexStrategy, index_strategy: IndexStrategy,
dependency_metadata: DependencyMetadata, dependency_metadata: DependencyMetadata,
keyring_provider: KeyringProviderType, keyring_provider: KeyringProviderType,
network_settings: &NetworkSettings,
reinstall: Reinstall, reinstall: Reinstall,
link_mode: LinkMode, link_mode: LinkMode,
compile: bool, compile: bool,
hash_checking: Option<HashCheckingMode>, hash_checking: Option<HashCheckingMode>,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
config_settings: &ConfigSettings, config_settings: &ConfigSettings,
no_build_isolation: bool, no_build_isolation: bool,
no_build_isolation_package: Vec<PackageName>, no_build_isolation_package: Vec<PackageName>,
@ -85,8 +86,6 @@ pub(crate) async fn pip_install(
prefix: Option<Prefix>, prefix: Option<Prefix>,
python_preference: PythonPreference, python_preference: PythonPreference,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: Cache, cache: Cache,
dry_run: DryRun, dry_run: DryRun,
printer: Printer, printer: Printer,
@ -95,10 +94,10 @@ pub(crate) async fn pip_install(
let start = std::time::Instant::now(); let start = std::time::Instant::now();
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.keyring(keyring_provider) .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. // Read all requirements from the provided sources.
let RequirementsSpecification { let RequirementsSpecification {
@ -447,7 +446,7 @@ pub(crate) async fn pip_install(
{ {
Ok(graph) => Resolution::from(graph), Ok(graph) => Resolution::from(graph),
Err(err) => { Err(err) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }
@ -481,7 +480,7 @@ pub(crate) async fn pip_install(
{ {
Ok(_) => {} Ok(_) => {}
Err(err) => { Err(err) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }

View File

@ -14,8 +14,8 @@ use unicode_width::UnicodeWidthStr;
use uv_cache::{Cache, Refresh}; use uv_cache::{Cache, Refresh};
use uv_cache_info::Timestamp; use uv_cache_info::Timestamp;
use uv_cli::ListFormat; use uv_cli::ListFormat;
use uv_client::{Connectivity, RegistryClientBuilder}; use uv_client::RegistryClientBuilder;
use uv_configuration::{Concurrency, IndexStrategy, KeyringProviderType, TrustedHost}; use uv_configuration::{Concurrency, IndexStrategy, KeyringProviderType};
use uv_distribution_filename::DistFilename; use uv_distribution_filename::DistFilename;
use uv_distribution_types::{Diagnostic, IndexCapabilities, IndexLocations, InstalledDist, Name}; use uv_distribution_types::{Diagnostic, IndexCapabilities, IndexLocations, InstalledDist, Name};
use uv_fs::Simplified; use uv_fs::Simplified;
@ -31,6 +31,7 @@ use crate::commands::pip::operations::report_target_environment;
use crate::commands::reporters::LatestVersionReporter; use crate::commands::reporters::LatestVersionReporter;
use crate::commands::ExitStatus; use crate::commands::ExitStatus;
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::NetworkSettings;
/// Enumerate the installed packages in the current environment. /// Enumerate the installed packages in the current environment.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -43,14 +44,12 @@ pub(crate) async fn pip_list(
index_locations: IndexLocations, index_locations: IndexLocations,
index_strategy: IndexStrategy, index_strategy: IndexStrategy,
keyring_provider: KeyringProviderType, keyring_provider: KeyringProviderType,
allow_insecure_host: Vec<TrustedHost>, network_settings: &NetworkSettings,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
strict: bool, strict: bool,
exclude_newer: Option<ExcludeNewer>, exclude_newer: Option<ExcludeNewer>,
python: Option<&str>, python: Option<&str>,
system: bool, system: bool,
native_tls: bool,
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
) -> Result<ExitStatus> { ) -> Result<ExitStatus> {
@ -86,12 +85,12 @@ pub(crate) async fn pip_list(
// Initialize the registry client. // Initialize the registry client.
let client = let client =
RegistryClientBuilder::new(cache.clone().with_refresh(Refresh::All(Timestamp::now()))) RegistryClientBuilder::new(cache.clone().with_refresh(Refresh::All(Timestamp::now())))
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.index_urls(index_locations.index_urls()) .index_urls(index_locations.index_urls())
.index_strategy(index_strategy) .index_strategy(index_strategy)
.keyring(keyring_provider) .keyring(keyring_provider)
.allow_insecure_host(allow_insecure_host.clone()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.markers(environment.interpreter().markers()) .markers(environment.interpreter().markers())
.platform(environment.interpreter().platform()) .platform(environment.interpreter().platform())
.build(); .build();

View File

@ -7,11 +7,11 @@ use owo_colors::OwoColorize;
use tracing::debug; use tracing::debug;
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
use uv_configuration::{ use uv_configuration::{
BuildOptions, Concurrency, ConfigSettings, Constraints, DevGroupsSpecification, DryRun, BuildOptions, Concurrency, ConfigSettings, Constraints, DevGroupsSpecification, DryRun,
ExtrasSpecification, HashCheckingMode, IndexStrategy, PreviewMode, Reinstall, SourceStrategy, ExtrasSpecification, HashCheckingMode, IndexStrategy, PreviewMode, Reinstall, SourceStrategy,
TrustedHost, Upgrade, Upgrade,
}; };
use uv_configuration::{KeyringProviderType, TargetTriple}; use uv_configuration::{KeyringProviderType, TargetTriple};
use uv_dispatch::{BuildDispatch, SharedState}; 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::pip::{operations, resolution_markers, resolution_tags};
use crate::commands::{diagnostics, ExitStatus}; use crate::commands::{diagnostics, ExitStatus};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::NetworkSettings;
/// Install a set of locked requirements into the current Python environment. /// Install a set of locked requirements into the current Python environment.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -53,9 +54,9 @@ pub(crate) async fn pip_sync(
index_strategy: IndexStrategy, index_strategy: IndexStrategy,
dependency_metadata: DependencyMetadata, dependency_metadata: DependencyMetadata,
keyring_provider: KeyringProviderType, keyring_provider: KeyringProviderType,
network_settings: &NetworkSettings,
allow_empty_requirements: bool, allow_empty_requirements: bool,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
config_settings: &ConfigSettings, config_settings: &ConfigSettings,
no_build_isolation: bool, no_build_isolation: bool,
no_build_isolation_package: Vec<PackageName>, no_build_isolation_package: Vec<PackageName>,
@ -72,18 +73,16 @@ pub(crate) async fn pip_sync(
sources: SourceStrategy, sources: SourceStrategy,
python_preference: PythonPreference, python_preference: PythonPreference,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: Cache, cache: Cache,
dry_run: DryRun, dry_run: DryRun,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
) -> Result<ExitStatus> { ) -> Result<ExitStatus> {
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.keyring(keyring_provider) .keyring(keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
// Initialize a few defaults. // Initialize a few defaults.
let overrides = &[]; let overrides = &[];
@ -381,7 +380,7 @@ pub(crate) async fn pip_sync(
{ {
Ok(resolution) => Resolution::from(resolution), Ok(resolution) => Resolution::from(resolution),
Err(err) => { Err(err) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }
@ -415,7 +414,7 @@ pub(crate) async fn pip_sync(
{ {
Ok(_) => {} Ok(_) => {}
Err(err) => { Err(err) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }

View File

@ -12,8 +12,8 @@ use tokio::sync::Semaphore;
use uv_cache::{Cache, Refresh}; use uv_cache::{Cache, Refresh};
use uv_cache_info::Timestamp; use uv_cache_info::Timestamp;
use uv_client::{Connectivity, RegistryClientBuilder}; use uv_client::RegistryClientBuilder;
use uv_configuration::{Concurrency, IndexStrategy, KeyringProviderType, TrustedHost}; use uv_configuration::{Concurrency, IndexStrategy, KeyringProviderType};
use uv_distribution_types::{Diagnostic, IndexCapabilities, IndexLocations, Name}; use uv_distribution_types::{Diagnostic, IndexCapabilities, IndexLocations, Name};
use uv_installer::SitePackages; use uv_installer::SitePackages;
use uv_normalize::PackageName; use uv_normalize::PackageName;
@ -28,6 +28,7 @@ use crate::commands::pip::operations::report_target_environment;
use crate::commands::reporters::LatestVersionReporter; use crate::commands::reporters::LatestVersionReporter;
use crate::commands::ExitStatus; use crate::commands::ExitStatus;
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::NetworkSettings;
/// Display the installed packages in the current environment as a dependency tree. /// Display the installed packages in the current environment as a dependency tree.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -43,14 +44,12 @@ pub(crate) async fn pip_tree(
index_locations: IndexLocations, index_locations: IndexLocations,
index_strategy: IndexStrategy, index_strategy: IndexStrategy,
keyring_provider: KeyringProviderType, keyring_provider: KeyringProviderType,
allow_insecure_host: Vec<TrustedHost>, network_settings: NetworkSettings,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
strict: bool, strict: bool,
exclude_newer: Option<ExcludeNewer>, exclude_newer: Option<ExcludeNewer>,
python: Option<&str>, python: Option<&str>,
system: bool, system: bool,
native_tls: bool,
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
) -> Result<ExitStatus> { ) -> Result<ExitStatus> {
@ -87,12 +86,12 @@ pub(crate) async fn pip_tree(
// Initialize the registry client. // Initialize the registry client.
let client = let client =
RegistryClientBuilder::new(cache.clone().with_refresh(Refresh::All(Timestamp::now()))) RegistryClientBuilder::new(cache.clone().with_refresh(Refresh::All(Timestamp::now())))
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.index_urls(index_locations.index_urls()) .index_urls(index_locations.index_urls())
.index_strategy(index_strategy) .index_strategy(index_strategy)
.keyring(keyring_provider) .keyring(keyring_provider)
.allow_insecure_host(allow_insecure_host.clone()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.markers(environment.interpreter().markers()) .markers(environment.interpreter().markers())
.platform(environment.interpreter().platform()) .platform(environment.interpreter().platform())
.build(); .build();

View File

@ -6,8 +6,8 @@ use owo_colors::OwoColorize;
use tracing::debug; use tracing::debug;
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::{BaseClientBuilder, Connectivity}; use uv_client::BaseClientBuilder;
use uv_configuration::{DryRun, KeyringProviderType, TrustedHost}; use uv_configuration::{DryRun, KeyringProviderType};
use uv_distribution_types::{InstalledMetadata, Name, UnresolvedRequirement}; use uv_distribution_types::{InstalledMetadata, Name, UnresolvedRequirement};
use uv_fs::Simplified; use uv_fs::Simplified;
use uv_pep508::UnnamedRequirement; use uv_pep508::UnnamedRequirement;
@ -21,6 +21,7 @@ use uv_requirements::{RequirementsSource, RequirementsSpecification};
use crate::commands::pip::operations::report_target_environment; use crate::commands::pip::operations::report_target_environment;
use crate::commands::{elapsed, ExitStatus}; use crate::commands::{elapsed, ExitStatus};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::NetworkSettings;
/// Uninstall packages from the current environment. /// Uninstall packages from the current environment.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -32,20 +33,18 @@ pub(crate) async fn pip_uninstall(
target: Option<Target>, target: Option<Target>,
prefix: Option<Prefix>, prefix: Option<Prefix>,
cache: Cache, cache: Cache,
connectivity: Connectivity,
native_tls: bool,
keyring_provider: KeyringProviderType, keyring_provider: KeyringProviderType,
allow_insecure_host: &[TrustedHost], network_settings: &NetworkSettings,
dry_run: DryRun, dry_run: DryRun,
printer: Printer, printer: Printer,
) -> Result<ExitStatus> { ) -> Result<ExitStatus> {
let start = std::time::Instant::now(); let start = std::time::Instant::now();
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.keyring(keyring_provider) .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. // Read all requirements from the provided sources.
let spec = RequirementsSpecification::from_simple_sources(sources, &client_builder).await?; let spec = RequirementsSpecification::from_simple_sources(sources, &client_builder).await?;

View File

@ -14,10 +14,10 @@ use url::Url;
use uv_cache::Cache; use uv_cache::Cache;
use uv_cache_key::RepositoryUrl; use uv_cache_key::RepositoryUrl;
use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
use uv_configuration::{ use uv_configuration::{
Concurrency, Constraints, DevGroupsSpecification, DevMode, DryRun, EditableMode, Concurrency, Constraints, DevGroupsSpecification, DevMode, DryRun, EditableMode,
ExtrasSpecification, InstallOptions, PreviewMode, SourceStrategy, TrustedHost, ExtrasSpecification, InstallOptions, PreviewMode, SourceStrategy,
}; };
use uv_dispatch::BuildDispatch; use uv_dispatch::BuildDispatch;
use uv_distribution::DistributionDatabase; use uv_distribution::DistributionDatabase;
@ -53,7 +53,7 @@ use crate::commands::project::{
use crate::commands::reporters::{PythonDownloadReporter, ResolverReporter}; use crate::commands::reporters::{PythonDownloadReporter, ResolverReporter};
use crate::commands::{diagnostics, project, ExitStatus, ScriptPath}; use crate::commands::{diagnostics, project, ExitStatus, ScriptPath};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::{ResolverInstallerSettings, ResolverInstallerSettingsRef}; use crate::settings::{NetworkSettings, ResolverInstallerSettings, ResolverInstallerSettingsRef};
/// Add one or more packages to the project requirements. /// Add one or more packages to the project requirements.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -76,14 +76,12 @@ pub(crate) async fn add(
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
settings: ResolverInstallerSettings, settings: ResolverInstallerSettings,
network_settings: NetworkSettings,
script: Option<ScriptPath>, script: Option<ScriptPath>,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
no_config: bool, no_config: bool,
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
@ -130,9 +128,9 @@ pub(crate) async fn add(
} }
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
// If we found a script, add to the existing metadata. Otherwise, create a new inline // If we found a script, add to the existing metadata. Otherwise, create a new inline
// metadata tag. // metadata tag.
@ -160,11 +158,9 @@ pub(crate) async fn add(
let interpreter = ScriptInterpreter::discover( let interpreter = ScriptInterpreter::discover(
Pep723ItemRef::Script(&script), Pep723ItemRef::Script(&script),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
active, active,
@ -209,11 +205,9 @@ pub(crate) async fn add(
project.workspace(), project.workspace(),
project_dir, project_dir,
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
active, active,
@ -230,11 +224,9 @@ pub(crate) async fn add(
project.workspace(), project.workspace(),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&install_mirrors, &install_mirrors,
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
no_config, no_config,
active, active,
cache, cache,
@ -249,10 +241,10 @@ pub(crate) async fn add(
}; };
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.keyring(settings.keyring_provider) .keyring(settings.keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
// Read the requirements. // Read the requirements.
let RequirementsSpecification { requirements, .. } = let RequirementsSpecification { requirements, .. } =
@ -632,11 +624,9 @@ pub(crate) async fn add(
&dependency_type, &dependency_type,
raw_sources, raw_sources,
settings.as_ref(), settings.as_ref(),
&network_settings,
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -649,7 +639,7 @@ pub(crate) async fn add(
let _ = snapshot.revert(); let _ = snapshot.revert();
} }
match err { 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) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())), .map_or(Ok(ExitStatus::Failure), |err| Err(err.into())),
err => Err(err.into()), err => Err(err.into()),
@ -670,11 +660,9 @@ async fn lock_and_sync(
dependency_type: &DependencyType, dependency_type: &DependencyType,
raw_sources: bool, raw_sources: bool,
settings: ResolverInstallerSettingsRef<'_>, settings: ResolverInstallerSettingsRef<'_>,
network_settings: &NetworkSettings,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
@ -687,12 +675,10 @@ async fn lock_and_sync(
}, },
(&target).into(), (&target).into(),
settings.into(), settings.into(),
network_settings,
&lock_state, &lock_state,
Box::new(DefaultResolveLogger), Box::new(DefaultResolveLogger),
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -807,12 +793,10 @@ async fn lock_and_sync(
}, },
(&target).into(), (&target).into(),
settings.into(), settings.into(),
network_settings,
&lock_state, &lock_state,
Box::new(SummaryResolveLogger), Box::new(SummaryResolveLogger),
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -878,13 +862,11 @@ async fn lock_and_sync(
InstallOptions::default(), InstallOptions::default(),
Modifications::Sufficient, Modifications::Sufficient,
settings.into(), settings.into(),
network_settings,
&sync_state, &sync_state,
Box::new(DefaultInstallLogger), Box::new(DefaultInstallLogger),
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
DryRun::Disabled, DryRun::Disabled,
printer, printer,

View File

@ -2,8 +2,7 @@ use tracing::debug;
use uv_cache::{Cache, CacheBucket}; use uv_cache::{Cache, CacheBucket};
use uv_cache_key::{cache_digest, hash_digest}; use uv_cache_key::{cache_digest, hash_digest};
use uv_client::Connectivity; use uv_configuration::{Concurrency, PreviewMode};
use uv_configuration::{Concurrency, PreviewMode, TrustedHost};
use uv_distribution_types::{Name, Resolution}; use uv_distribution_types::{Name, Resolution};
use uv_python::{Interpreter, PythonEnvironment}; use uv_python::{Interpreter, PythonEnvironment};
@ -13,7 +12,7 @@ use crate::commands::project::{
resolve_environment, sync_environment, EnvironmentSpecification, PlatformState, ProjectError, resolve_environment, sync_environment, EnvironmentSpecification, PlatformState, ProjectError,
}; };
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::ResolverInstallerSettings; use crate::settings::{NetworkSettings, ResolverInstallerSettings};
/// A [`PythonEnvironment`] stored in the cache. /// A [`PythonEnvironment`] stored in the cache.
#[derive(Debug)] #[derive(Debug)]
@ -31,14 +30,12 @@ impl CachedEnvironment {
spec: EnvironmentSpecification<'_>, spec: EnvironmentSpecification<'_>,
interpreter: &Interpreter, interpreter: &Interpreter,
settings: &ResolverInstallerSettings, settings: &ResolverInstallerSettings,
network_settings: &NetworkSettings,
state: &PlatformState, state: &PlatformState,
resolve: Box<dyn ResolveLogger>, resolve: Box<dyn ResolveLogger>,
install: Box<dyn InstallLogger>, install: Box<dyn InstallLogger>,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
@ -51,12 +48,10 @@ impl CachedEnvironment {
spec, spec,
&interpreter, &interpreter,
settings.as_ref().into(), settings.as_ref().into(),
network_settings,
state, state,
resolve, resolve,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -105,13 +100,11 @@ impl CachedEnvironment {
&resolution, &resolution,
Modifications::Exact, Modifications::Exact,
settings.as_ref().into(), settings.as_ref().into(),
network_settings,
state, state,
install, install,
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,

View File

@ -7,10 +7,9 @@ use std::path::{Path, PathBuf};
use uv_settings::PythonInstallMirrors; use uv_settings::PythonInstallMirrors;
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::Connectivity;
use uv_configuration::{ use uv_configuration::{
Concurrency, DevGroupsSpecification, EditableMode, ExportFormat, ExtrasSpecification, Concurrency, DevGroupsSpecification, EditableMode, ExportFormat, ExtrasSpecification,
InstallOptions, PreviewMode, TrustedHost, InstallOptions, PreviewMode,
}; };
use uv_normalize::PackageName; use uv_normalize::PackageName;
use uv_python::{PythonDownloads, PythonPreference, PythonRequest}; use uv_python::{PythonDownloads, PythonPreference, PythonRequest};
@ -28,7 +27,7 @@ use crate::commands::project::{
}; };
use crate::commands::{diagnostics, ExitStatus, OutputWriter}; use crate::commands::{diagnostics, ExitStatus, OutputWriter};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::ResolverSettings; use crate::settings::{NetworkSettings, ResolverSettings};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
enum ExportTarget { enum ExportTarget {
@ -69,12 +68,10 @@ pub(crate) async fn export(
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
settings: ResolverSettings, settings: ResolverSettings,
network_settings: NetworkSettings,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
no_config: bool, no_config: bool,
quiet: bool, quiet: bool,
cache: &Cache, cache: &Cache,
@ -122,11 +119,9 @@ pub(crate) async fn export(
ExportTarget::Script(script) => ScriptInterpreter::discover( ExportTarget::Script(script) => ScriptInterpreter::discover(
Pep723ItemRef::Script(script), Pep723ItemRef::Script(script),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
Some(false), Some(false),
@ -139,11 +134,9 @@ pub(crate) async fn export(
project.workspace(), project.workspace(),
project_dir, project_dir,
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
Some(false), Some(false),
@ -177,12 +170,10 @@ pub(crate) async fn export(
mode, mode,
(&target).into(), (&target).into(),
settings.as_ref(), settings.as_ref(),
&network_settings,
&state, &state,
Box::new(DefaultResolveLogger), Box::new(DefaultResolveLogger),
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -191,7 +182,7 @@ pub(crate) async fn export(
{ {
Ok(result) => result.into_lock(), Ok(result) => result.into_lock(),
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }

View File

@ -8,9 +8,9 @@ use std::str::FromStr;
use tracing::{debug, warn}; use tracing::{debug, warn};
use uv_cache::Cache; use uv_cache::Cache;
use uv_cli::AuthorFrom; use uv_cli::AuthorFrom;
use uv_client::{BaseClientBuilder, Connectivity}; use uv_client::BaseClientBuilder;
use uv_configuration::{ use uv_configuration::{
PreviewMode, ProjectBuildBackend, TrustedHost, VersionControlError, VersionControlSystem, PreviewMode, ProjectBuildBackend, VersionControlError, VersionControlSystem,
}; };
use uv_fs::{Simplified, CWD}; use uv_fs::{Simplified, CWD};
use uv_git::GIT; 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::reporters::PythonDownloadReporter;
use crate::commands::ExitStatus; use crate::commands::ExitStatus;
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::NetworkSettings;
/// Add one or more packages to the project requirements. /// Add one or more packages to the project requirements.
#[allow(clippy::single_match_else, clippy::fn_params_excessive_bools)] #[allow(clippy::single_match_else, clippy::fn_params_excessive_bools)]
@ -52,11 +53,9 @@ pub(crate) async fn init(
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
no_workspace: bool, no_workspace: bool,
network_settings: &NetworkSettings,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
connectivity: Connectivity,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
no_config: bool, no_config: bool,
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
@ -75,7 +74,7 @@ pub(crate) async fn init(
path, path,
python, python,
install_mirrors, install_mirrors,
connectivity, network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
cache, cache,
@ -85,8 +84,6 @@ pub(crate) async fn init(
author_from, author_from,
pin_python, pin_python,
package, package,
native_tls,
allow_insecure_host,
no_config, no_config,
) )
.await?; .await?;
@ -146,11 +143,9 @@ pub(crate) async fn init(
python, python,
install_mirrors, install_mirrors,
no_workspace, no_workspace,
network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
no_config, no_config,
cache, cache,
printer, printer,
@ -193,7 +188,7 @@ async fn init_script(
script_path: &Path, script_path: &Path,
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
connectivity: Connectivity, network_settings: &NetworkSettings,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
cache: &Cache, cache: &Cache,
@ -203,8 +198,6 @@ async fn init_script(
author_from: Option<AuthorFrom>, author_from: Option<AuthorFrom>,
pin_python: bool, pin_python: bool,
package: bool, package: bool,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
no_config: bool, no_config: bool,
) -> Result<()> { ) -> Result<()> {
if no_workspace { 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"); warn_user_once!("`--package` is a no-op for Python scripts, which are standalone");
} }
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
let reporter = PythonDownloadReporter::single(printer); let reporter = PythonDownloadReporter::single(printer);
@ -290,11 +283,9 @@ async fn init_project(
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
no_workspace: bool, no_workspace: bool,
network_settings: &NetworkSettings,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
connectivity: Connectivity,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
no_config: bool, no_config: bool,
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
@ -344,9 +335,9 @@ async fn init_project(
let reporter = PythonDownloadReporter::single(printer); let reporter = PythonDownloadReporter::single(printer);
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
// First, determine if there is an request for Python // First, determine if there is an request for Python
let python_request = if let Some(request) = python { let python_request = if let Some(request) = python {

View File

@ -10,10 +10,10 @@ use rustc_hash::{FxBuildHasher, FxHashMap};
use tracing::debug; use tracing::debug;
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
use uv_configuration::{ use uv_configuration::{
Concurrency, Constraints, DevGroupsSpecification, DryRun, ExtrasSpecification, PreviewMode, Concurrency, Constraints, DevGroupsSpecification, DryRun, ExtrasSpecification, PreviewMode,
Reinstall, TrustedHost, Upgrade, Reinstall, Upgrade,
}; };
use uv_dispatch::BuildDispatch; use uv_dispatch::BuildDispatch;
use uv_distribution::DistributionDatabase; use uv_distribution::DistributionDatabase;
@ -47,7 +47,7 @@ use crate::commands::project::{
use crate::commands::reporters::{PythonDownloadReporter, ResolverReporter}; use crate::commands::reporters::{PythonDownloadReporter, ResolverReporter};
use crate::commands::{diagnostics, pip, ExitStatus, ScriptPath}; use crate::commands::{diagnostics, pip, ExitStatus, ScriptPath};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::{ResolverSettings, ResolverSettingsRef}; use crate::settings::{NetworkSettings, ResolverSettings, ResolverSettingsRef};
/// The result of running a lock operation. /// The result of running a lock operation.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -84,13 +84,11 @@ pub(crate) async fn lock(
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
settings: ResolverSettings, settings: ResolverSettings,
network_settings: NetworkSettings,
script: Option<ScriptPath>, script: Option<ScriptPath>,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
no_config: bool, no_config: bool,
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
@ -100,9 +98,9 @@ pub(crate) async fn lock(
let script = match script { let script = match script {
Some(ScriptPath::Path(path)) => { Some(ScriptPath::Path(path)) => {
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
let reporter = PythonDownloadReporter::single(printer); let reporter = PythonDownloadReporter::single(printer);
let requires_python = init_script_python_requirement( let requires_python = init_script_python_requirement(
python.as_deref(), python.as_deref(),
@ -142,11 +140,9 @@ pub(crate) async fn lock(
workspace, workspace,
project_dir, project_dir,
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
Some(false), Some(false),
@ -158,11 +154,9 @@ pub(crate) async fn lock(
LockTarget::Script(script) => ScriptInterpreter::discover( LockTarget::Script(script) => ScriptInterpreter::discover(
Pep723ItemRef::Script(script), Pep723ItemRef::Script(script),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
Some(false), Some(false),
@ -190,12 +184,10 @@ pub(crate) async fn lock(
mode, mode,
target, target,
settings.as_ref(), settings.as_ref(),
&network_settings,
&state, &state,
Box::new(DefaultResolveLogger), Box::new(DefaultResolveLogger),
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -230,7 +222,7 @@ pub(crate) async fn lock(
Ok(ExitStatus::Success) Ok(ExitStatus::Success)
} }
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
diagnostics::OperationDiagnostic::native_tls(native_tls) diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }
@ -256,12 +248,10 @@ pub(super) async fn do_safe_lock(
mode: LockMode<'_>, mode: LockMode<'_>,
target: LockTarget<'_>, target: LockTarget<'_>,
settings: ResolverSettingsRef<'_>, settings: ResolverSettingsRef<'_>,
network_settings: &NetworkSettings,
state: &UniversalState, state: &UniversalState,
logger: Box<dyn ResolveLogger>, logger: Box<dyn ResolveLogger>,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
@ -288,12 +278,10 @@ pub(super) async fn do_safe_lock(
interpreter, interpreter,
Some(existing), Some(existing),
settings, settings,
network_settings,
state, state,
logger, logger,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -327,12 +315,10 @@ pub(super) async fn do_safe_lock(
interpreter, interpreter,
existing, existing,
settings, settings,
network_settings,
state, state,
logger, logger,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -357,12 +343,10 @@ async fn do_lock(
interpreter: &Interpreter, interpreter: &Interpreter,
existing_lock: Option<Lock>, existing_lock: Option<Lock>,
settings: ResolverSettingsRef<'_>, settings: ResolverSettingsRef<'_>,
network_settings: &NetworkSettings,
state: &UniversalState, state: &UniversalState,
logger: Box<dyn ResolveLogger>, logger: Box<dyn ResolveLogger>,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
@ -553,12 +537,12 @@ async fn do_lock(
// Initialize the registry client. // Initialize the registry client.
let client = RegistryClientBuilder::new(cache.clone()) let client = RegistryClientBuilder::new(cache.clone())
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.index_urls(index_locations.index_urls()) .index_urls(index_locations.index_urls())
.index_strategy(index_strategy) .index_strategy(index_strategy)
.keyring(keyring_provider) .keyring(keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.markers(interpreter.markers()) .markers(interpreter.markers())
.platform(interpreter.platform()) .platform(interpreter.platform())
.build(); .build();

View File

@ -10,10 +10,10 @@ use tracing::{debug, warn};
use uv_cache::{Cache, CacheBucket}; use uv_cache::{Cache, CacheBucket};
use uv_cache_key::cache_digest; use uv_cache_key::cache_digest;
use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
use uv_configuration::{ use uv_configuration::{
Concurrency, Constraints, DevGroupsManifest, DevGroupsSpecification, DryRun, Concurrency, Constraints, DevGroupsManifest, DevGroupsSpecification, DryRun,
ExtrasSpecification, PreviewMode, Reinstall, SourceStrategy, TrustedHost, Upgrade, ExtrasSpecification, PreviewMode, Reinstall, SourceStrategy, Upgrade,
}; };
use uv_dispatch::{BuildDispatch, SharedState}; use uv_dispatch::{BuildDispatch, SharedState};
use uv_distribution::{DistributionDatabase, LoweredRequirement}; 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::reporters::{PythonDownloadReporter, ResolverReporter};
use crate::commands::{capitalize, conjunction, pip}; use crate::commands::{capitalize, conjunction, pip};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::{InstallerSettingsRef, ResolverInstallerSettings, ResolverSettingsRef}; use crate::settings::{
InstallerSettingsRef, NetworkSettings, ResolverInstallerSettings, ResolverSettingsRef,
};
pub(crate) mod add; pub(crate) mod add;
pub(crate) mod environment; pub(crate) mod environment;
@ -630,11 +632,9 @@ impl ScriptInterpreter {
pub(crate) async fn discover( pub(crate) async fn discover(
script: Pep723ItemRef<'_>, script: Pep723ItemRef<'_>,
python_request: Option<PythonRequest>, python_request: Option<PythonRequest>,
network_settings: &NetworkSettings,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
connectivity: Connectivity,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
install_mirrors: &PythonInstallMirrors, install_mirrors: &PythonInstallMirrors,
no_config: bool, no_config: bool,
active: Option<bool>, active: Option<bool>,
@ -686,9 +686,9 @@ impl ScriptInterpreter {
}; };
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
let reporter = PythonDownloadReporter::single(printer); let reporter = PythonDownloadReporter::single(printer);
@ -773,11 +773,9 @@ impl ProjectInterpreter {
workspace: &Workspace, workspace: &Workspace,
project_dir: &Path, project_dir: &Path,
python_request: Option<PythonRequest>, python_request: Option<PythonRequest>,
network_settings: &NetworkSettings,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
connectivity: Connectivity,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
install_mirrors: &PythonInstallMirrors, install_mirrors: &PythonInstallMirrors,
no_config: bool, no_config: bool,
active: Option<bool>, active: Option<bool>,
@ -861,9 +859,9 @@ impl ProjectInterpreter {
}; };
let client_builder = BaseClientBuilder::default() let client_builder = BaseClientBuilder::default()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
let reporter = PythonDownloadReporter::single(printer); let reporter = PythonDownloadReporter::single(printer);
@ -1137,11 +1135,9 @@ impl ProjectEnvironment {
workspace: &Workspace, workspace: &Workspace,
python: Option<PythonRequest>, python: Option<PythonRequest>,
install_mirrors: &PythonInstallMirrors, install_mirrors: &PythonInstallMirrors,
network_settings: &NetworkSettings,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
connectivity: Connectivity,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
no_config: bool, no_config: bool,
active: Option<bool>, active: Option<bool>,
cache: &Cache, cache: &Cache,
@ -1155,11 +1151,9 @@ impl ProjectEnvironment {
workspace, workspace,
workspace.install_path().as_ref(), workspace.install_path().as_ref(),
python, python,
network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
install_mirrors, install_mirrors,
no_config, no_config,
active, active,
@ -1342,11 +1336,9 @@ impl ScriptEnvironment {
pub(crate) async fn get_or_init( pub(crate) async fn get_or_init(
script: Pep723ItemRef<'_>, script: Pep723ItemRef<'_>,
python_request: Option<PythonRequest>, python_request: Option<PythonRequest>,
network_settings: &NetworkSettings,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
connectivity: Connectivity,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
install_mirrors: &PythonInstallMirrors, install_mirrors: &PythonInstallMirrors,
no_config: bool, no_config: bool,
active: Option<bool>, active: Option<bool>,
@ -1360,11 +1352,9 @@ impl ScriptEnvironment {
match ScriptInterpreter::discover( match ScriptInterpreter::discover(
script, script,
python_request, python_request,
network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
install_mirrors, install_mirrors,
no_config, no_config,
active, active,
@ -1482,11 +1472,9 @@ pub(crate) async fn resolve_names(
requirements: Vec<UnresolvedRequirementSpecification>, requirements: Vec<UnresolvedRequirementSpecification>,
interpreter: &Interpreter, interpreter: &Interpreter,
settings: &ResolverInstallerSettings, settings: &ResolverInstallerSettings,
network_settings: &NetworkSettings,
state: &SharedState, state: &SharedState,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
@ -1541,12 +1529,12 @@ pub(crate) async fn resolve_names(
// Initialize the registry client. // Initialize the registry client.
let client = RegistryClientBuilder::new(cache.clone()) let client = RegistryClientBuilder::new(cache.clone())
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.index_urls(index_locations.index_urls()) .index_urls(index_locations.index_urls())
.index_strategy(*index_strategy) .index_strategy(*index_strategy)
.keyring(*keyring_provider) .keyring(*keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.markers(interpreter.markers()) .markers(interpreter.markers())
.platform(interpreter.platform()) .platform(interpreter.platform())
.build(); .build();
@ -1636,12 +1624,10 @@ pub(crate) async fn resolve_environment(
spec: EnvironmentSpecification<'_>, spec: EnvironmentSpecification<'_>,
interpreter: &Interpreter, interpreter: &Interpreter,
settings: ResolverSettingsRef<'_>, settings: ResolverSettingsRef<'_>,
network_settings: &NetworkSettings,
state: &PlatformState, state: &PlatformState,
logger: Box<dyn ResolveLogger>, logger: Box<dyn ResolveLogger>,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
@ -1694,12 +1680,12 @@ pub(crate) async fn resolve_environment(
// Initialize the registry client. // Initialize the registry client.
let client = RegistryClientBuilder::new(cache.clone()) let client = RegistryClientBuilder::new(cache.clone())
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.index_urls(index_locations.index_urls()) .index_urls(index_locations.index_urls())
.index_strategy(index_strategy) .index_strategy(index_strategy)
.keyring(keyring_provider) .keyring(keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.markers(interpreter.markers()) .markers(interpreter.markers())
.platform(interpreter.platform()) .platform(interpreter.platform())
.build(); .build();
@ -1819,13 +1805,11 @@ pub(crate) async fn sync_environment(
resolution: &Resolution, resolution: &Resolution,
modifications: Modifications, modifications: Modifications,
settings: InstallerSettingsRef<'_>, settings: InstallerSettingsRef<'_>,
network_settings: &NetworkSettings,
state: &PlatformState, state: &PlatformState,
logger: Box<dyn InstallLogger>, logger: Box<dyn InstallLogger>,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
@ -1865,12 +1849,12 @@ pub(crate) async fn sync_environment(
// Initialize the registry client. // Initialize the registry client.
let client = RegistryClientBuilder::new(cache.clone()) let client = RegistryClientBuilder::new(cache.clone())
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.index_urls(index_locations.index_urls()) .index_urls(index_locations.index_urls())
.index_strategy(index_strategy) .index_strategy(index_strategy)
.keyring(keyring_provider) .keyring(keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.markers(interpreter.markers()) .markers(interpreter.markers())
.platform(interpreter.platform()) .platform(interpreter.platform())
.build(); .build();
@ -1976,14 +1960,12 @@ pub(crate) async fn update_environment(
spec: RequirementsSpecification, spec: RequirementsSpecification,
modifications: Modifications, modifications: Modifications,
settings: &ResolverInstallerSettings, settings: &ResolverInstallerSettings,
network_settings: &NetworkSettings,
state: &SharedState, state: &SharedState,
resolve: Box<dyn ResolveLogger>, resolve: Box<dyn ResolveLogger>,
install: Box<dyn InstallLogger>, install: Box<dyn InstallLogger>,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
dry_run: DryRun, dry_run: DryRun,
printer: Printer, printer: Printer,
@ -2069,12 +2051,12 @@ pub(crate) async fn update_environment(
// Initialize the registry client. // Initialize the registry client.
let client = RegistryClientBuilder::new(cache.clone()) let client = RegistryClientBuilder::new(cache.clone())
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.index_urls(index_locations.index_urls()) .index_urls(index_locations.index_urls())
.index_strategy(*index_strategy) .index_strategy(*index_strategy)
.keyring(*keyring_provider) .keyring(*keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.markers(interpreter.markers()) .markers(interpreter.markers())
.platform(interpreter.platform()) .platform(interpreter.platform())
.build(); .build();

View File

@ -8,10 +8,9 @@ use owo_colors::OwoColorize;
use tracing::debug; use tracing::debug;
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::Connectivity;
use uv_configuration::{ use uv_configuration::{
Concurrency, DevGroupsSpecification, DryRun, EditableMode, ExtrasSpecification, InstallOptions, Concurrency, DevGroupsSpecification, DryRun, EditableMode, ExtrasSpecification, InstallOptions,
PreviewMode, TrustedHost, PreviewMode,
}; };
use uv_fs::Simplified; use uv_fs::Simplified;
use uv_normalize::DEV_DEPENDENCIES; use uv_normalize::DEV_DEPENDENCIES;
@ -36,7 +35,7 @@ use crate::commands::project::{
}; };
use crate::commands::{diagnostics, project, ExitStatus}; use crate::commands::{diagnostics, project, ExitStatus};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::ResolverInstallerSettings; use crate::settings::{NetworkSettings, ResolverInstallerSettings};
/// Remove one or more packages from the project requirements. /// Remove one or more packages from the project requirements.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -52,14 +51,12 @@ pub(crate) async fn remove(
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
settings: ResolverInstallerSettings, settings: ResolverInstallerSettings,
network_settings: NetworkSettings,
script: Option<Pep723Script>, script: Option<Pep723Script>,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
no_config: bool, no_config: bool,
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
@ -204,11 +201,9 @@ pub(crate) async fn remove(
project.workspace(), project.workspace(),
project_dir, project_dir,
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
active, active,
@ -225,11 +220,9 @@ pub(crate) async fn remove(
project.workspace(), project.workspace(),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&install_mirrors, &install_mirrors,
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
no_config, no_config,
active, active,
cache, cache,
@ -246,11 +239,9 @@ pub(crate) async fn remove(
let interpreter = ScriptInterpreter::discover( let interpreter = ScriptInterpreter::discover(
Pep723ItemRef::Script(&script), Pep723ItemRef::Script(&script),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
active, active,
@ -279,12 +270,10 @@ pub(crate) async fn remove(
mode, mode,
(&target).into(), (&target).into(),
settings.as_ref().into(), settings.as_ref().into(),
&network_settings,
&state, &state,
Box::new(DefaultResolveLogger), Box::new(DefaultResolveLogger),
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -293,7 +282,7 @@ pub(crate) async fn remove(
{ {
Ok(result) => result.into_lock(), Ok(result) => result.into_lock(),
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }
@ -342,13 +331,11 @@ pub(crate) async fn remove(
install_options, install_options,
Modifications::Exact, Modifications::Exact,
settings.as_ref().into(), settings.as_ref().into(),
&network_settings,
&state, &state,
Box::new(DefaultInstallLogger), Box::new(DefaultInstallLogger),
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
DryRun::Disabled, DryRun::Disabled,
printer, printer,
@ -358,7 +345,7 @@ pub(crate) async fn remove(
{ {
Ok(()) => {} Ok(()) => {}
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }

View File

@ -15,10 +15,10 @@ use url::Url;
use uv_cache::Cache; use uv_cache::Cache;
use uv_cli::ExternalCommand; use uv_cli::ExternalCommand;
use uv_client::{BaseClientBuilder, Connectivity}; use uv_client::BaseClientBuilder;
use uv_configuration::{ use uv_configuration::{
Concurrency, DevGroupsSpecification, DryRun, EditableMode, ExtrasSpecification, InstallOptions, Concurrency, DevGroupsSpecification, DryRun, EditableMode, ExtrasSpecification, InstallOptions,
PreviewMode, TrustedHost, PreviewMode,
}; };
use uv_fs::which::is_executable; use uv_fs::which::is_executable;
use uv_fs::{PythonExt, Simplified}; use uv_fs::{PythonExt, Simplified};
@ -53,7 +53,7 @@ use crate::commands::reporters::PythonDownloadReporter;
use crate::commands::run::run_to_completion; use crate::commands::run::run_to_completion;
use crate::commands::{diagnostics, project, ExitStatus}; use crate::commands::{diagnostics, project, ExitStatus};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::ResolverInstallerSettings; use crate::settings::{NetworkSettings, ResolverInstallerSettings};
/// Run a command. /// Run a command.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -79,13 +79,11 @@ pub(crate) async fn run(
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
settings: ResolverInstallerSettings, settings: ResolverInstallerSettings,
network_settings: NetworkSettings,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
env_file: Vec<PathBuf>, env_file: Vec<PathBuf>,
@ -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( let environment = ScriptEnvironment::get_or_init(
(&script).into(), (&script).into(),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
active.map_or(Some(false), Some), 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, mode,
target, target,
settings.as_ref().into(), settings.as_ref().into(),
&network_settings,
&lock_state, &lock_state,
if show_resolution { if show_resolution {
Box::new(DefaultResolveLogger) Box::new(DefaultResolveLogger)
} else { } else {
Box::new(SummaryResolveLogger) Box::new(SummaryResolveLogger)
}, },
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -265,7 +259,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
{ {
Ok(result) => result.into_lock(), Ok(result) => result.into_lock(),
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(
network_settings.native_tls,
)
.with_context("script") .with_context("script")
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| 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, install_options,
modifications, modifications,
settings.as_ref().into(), settings.as_ref().into(),
&network_settings,
&sync_state, &sync_state,
if show_resolution { if show_resolution {
Box::new(DefaultInstallLogger) 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) Box::new(SummaryInstallLogger)
}, },
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
DryRun::Disabled, DryRun::Disabled,
printer, printer,
@ -310,7 +304,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
{ {
Ok(()) => {} Ok(()) => {}
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(
network_settings.native_tls,
)
.with_context("script") .with_context("script")
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| 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( let environment = ScriptEnvironment::get_or_init(
(&script).into(), (&script).into(),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
active.map_or(Some(false), Some), 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, spec,
modifications, modifications,
&settings, &settings,
&network_settings,
&sync_state, &sync_state,
if show_resolution { if show_resolution {
Box::new(DefaultResolveLogger) 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) Box::new(SummaryInstallLogger)
}, },
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
DryRun::Disabled, DryRun::Disabled,
printer, printer,
@ -384,7 +376,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
{ {
Ok(update) => Some(update.into_environment().into_interpreter()), Ok(update) => Some(update.into_environment().into_interpreter()),
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(
network_settings.native_tls,
)
.with_context("script") .with_context("script")
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| 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( let interpreter = ScriptInterpreter::discover(
(&script).into(), (&script).into(),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
active.map_or(Some(false), Some), 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 // If we're isolating the environment, use an ephemeral virtual environment as the
// base environment for the project. // base environment for the project.
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
// Resolve the Python request and requirement for the workspace. // Resolve the Python request and requirement for the workspace.
let WorkspacePython { let WorkspacePython {
@ -617,11 +609,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
project.workspace(), project.workspace(),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&install_mirrors, &install_mirrors,
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
no_config, no_config,
active, active,
cache, cache,
@ -664,16 +654,14 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
mode, mode,
project.workspace().into(), project.workspace().into(),
settings.as_ref().into(), settings.as_ref().into(),
&network_settings,
&lock_state, &lock_state,
if show_resolution { if show_resolution {
Box::new(DefaultResolveLogger) Box::new(DefaultResolveLogger)
} else { } else {
Box::new(SummaryResolveLogger) Box::new(SummaryResolveLogger)
}, },
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -682,7 +670,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
{ {
Ok(result) => result, Ok(result) => result,
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(
network_settings.native_tls,
)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| 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, install_options,
modifications, modifications,
settings.as_ref().into(), settings.as_ref().into(),
&network_settings,
&sync_state, &sync_state,
if show_resolution { if show_resolution {
Box::new(DefaultInstallLogger) 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) Box::new(SummaryInstallLogger)
}, },
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
DryRun::Disabled, DryRun::Disabled,
printer, printer,
@ -770,7 +758,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
{ {
Ok(()) => {} Ok(()) => {}
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(
network_settings.native_tls,
)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| 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 interpreter = {
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
// (1) Explicit request from user // (1) Explicit request from user
let python_request = if let Some(request) = python.as_deref() { 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 None
} else { } else {
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
let spec = let spec =
RequirementsSpecification::from_simple_sources(&requirements, &client_builder).await?; 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, &base_interpreter,
&settings, &settings,
&network_settings,
&sync_state, &sync_state,
if show_resolution { if show_resolution {
Box::new(DefaultResolveLogger) 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) Box::new(SummaryInstallLogger)
}, },
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -906,7 +894,9 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
let environment = match result { let environment = match result {
Ok(resolution) => resolution, Ok(resolution) => resolution,
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(
network_settings.native_tls,
)
.with_context("`--with`") .with_context("`--with`")
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
@ -1362,12 +1352,10 @@ impl RunCommand {
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
pub(crate) async fn from_args( pub(crate) async fn from_args(
command: &ExternalCommand, command: &ExternalCommand,
network_settings: NetworkSettings,
module: bool, module: bool,
script: bool, script: bool,
gui_script: bool, gui_script: bool,
connectivity: Connectivity,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
) -> anyhow::Result<Self> { ) -> anyhow::Result<Self> {
let (target, args) = command.split(); let (target, args) = command.split();
let Some(target) = target else { let Some(target) = target else {
@ -1409,9 +1397,9 @@ impl RunCommand {
.tempfile()?; .tempfile()?;
let client = BaseClientBuilder::new() let client = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.build(); .build();
let response = client.for_host(&url).get(url.clone()).send().await?; let response = client.for_host(&url).get(url.clone()).send().await?;

View File

@ -8,10 +8,10 @@ use itertools::Itertools;
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::{Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_client::{FlatIndexClient, RegistryClientBuilder};
use uv_configuration::{ use uv_configuration::{
Concurrency, Constraints, DevGroupsManifest, DevGroupsSpecification, DryRun, EditableMode, Concurrency, Constraints, DevGroupsManifest, DevGroupsSpecification, DryRun, EditableMode,
ExtrasSpecification, HashCheckingMode, InstallOptions, PreviewMode, TrustedHost, ExtrasSpecification, HashCheckingMode, InstallOptions, PreviewMode,
}; };
use uv_dispatch::BuildDispatch; use uv_dispatch::BuildDispatch;
use uv_distribution_types::{ use uv_distribution_types::{
@ -43,7 +43,7 @@ use crate::commands::project::{
}; };
use crate::commands::{diagnostics, ExitStatus}; use crate::commands::{diagnostics, ExitStatus};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::{InstallerSettingsRef, ResolverInstallerSettings}; use crate::settings::{InstallerSettingsRef, NetworkSettings, ResolverInstallerSettings};
/// Sync the project environment. /// Sync the project environment.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -65,12 +65,10 @@ pub(crate) async fn sync(
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
settings: ResolverInstallerSettings, settings: ResolverInstallerSettings,
network_settings: NetworkSettings,
script: Option<Pep723Script>, script: Option<Pep723Script>,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
no_config: bool, no_config: bool,
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
@ -125,11 +123,9 @@ pub(crate) async fn sync(
project.workspace(), project.workspace(),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&install_mirrors, &install_mirrors,
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
no_config, no_config,
active, active,
cache, cache,
@ -142,11 +138,9 @@ pub(crate) async fn sync(
ScriptEnvironment::get_or_init( ScriptEnvironment::get_or_init(
Pep723ItemRef::Script(script), Pep723ItemRef::Script(script),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
&network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
active, active,
@ -284,14 +278,12 @@ pub(crate) async fn sync(
spec, spec,
modifications, modifications,
&settings, &settings,
&network_settings,
&PlatformState::default(), &PlatformState::default(),
Box::new(DefaultResolveLogger), Box::new(DefaultResolveLogger),
Box::new(DefaultInstallLogger), Box::new(DefaultInstallLogger),
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
dry_run, dry_run,
printer, printer,
@ -301,7 +293,9 @@ pub(crate) async fn sync(
{ {
Ok(..) => return Ok(ExitStatus::Success), Ok(..) => return Ok(ExitStatus::Success),
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(
network_settings.native_tls,
)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }
@ -333,12 +327,10 @@ pub(crate) async fn sync(
mode, mode,
lock_target, lock_target,
settings.as_ref().into(), settings.as_ref().into(),
&network_settings,
&state, &state,
Box::new(DefaultResolveLogger), Box::new(DefaultResolveLogger),
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -386,7 +378,7 @@ pub(crate) async fn sync(
result.into_lock() result.into_lock()
} }
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }
@ -458,13 +450,11 @@ pub(crate) async fn sync(
install_options, install_options,
modifications, modifications,
settings.as_ref().into(), settings.as_ref().into(),
&network_settings,
&state, &state,
Box::new(DefaultInstallLogger), Box::new(DefaultInstallLogger),
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
dry_run, dry_run,
printer, printer,
@ -474,7 +464,7 @@ pub(crate) async fn sync(
{ {
Ok(()) => {} Ok(()) => {}
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }
@ -522,13 +512,11 @@ pub(super) async fn do_sync(
install_options: InstallOptions, install_options: InstallOptions,
modifications: Modifications, modifications: Modifications,
settings: InstallerSettingsRef<'_>, settings: InstallerSettingsRef<'_>,
network_settings: &NetworkSettings,
state: &PlatformState, state: &PlatformState,
logger: Box<dyn InstallLogger>, logger: Box<dyn InstallLogger>,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
dry_run: DryRun, dry_run: DryRun,
printer: Printer, printer: Printer,
@ -632,12 +620,12 @@ pub(super) async fn do_sync(
// Initialize the registry client. // Initialize the registry client.
let client = RegistryClientBuilder::new(cache.clone()) let client = RegistryClientBuilder::new(cache.clone())
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.index_urls(index_locations.index_urls()) .index_urls(index_locations.index_urls())
.index_strategy(index_strategy) .index_strategy(index_strategy)
.keyring(keyring_provider) .keyring(keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.markers(venv.interpreter().markers()) .markers(venv.interpreter().markers())
.platform(venv.interpreter().platform()) .platform(venv.interpreter().platform())
.build(); .build();

View File

@ -6,10 +6,8 @@ use futures::StreamExt;
use tokio::sync::Semaphore; use tokio::sync::Semaphore;
use uv_cache::{Cache, Refresh}; use uv_cache::{Cache, Refresh};
use uv_cache_info::Timestamp; use uv_cache_info::Timestamp;
use uv_client::{Connectivity, RegistryClientBuilder}; use uv_client::RegistryClientBuilder;
use uv_configuration::{ use uv_configuration::{Concurrency, DevGroupsSpecification, PreviewMode, TargetTriple};
Concurrency, DevGroupsSpecification, PreviewMode, TargetTriple, TrustedHost,
};
use uv_distribution_types::IndexCapabilities; use uv_distribution_types::IndexCapabilities;
use uv_pep508::PackageName; use uv_pep508::PackageName;
use uv_python::{PythonDownloads, PythonPreference, PythonRequest, PythonVersion}; use uv_python::{PythonDownloads, PythonPreference, PythonRequest, PythonVersion};
@ -29,7 +27,7 @@ use crate::commands::project::{
use crate::commands::reporters::LatestVersionReporter; use crate::commands::reporters::LatestVersionReporter;
use crate::commands::{diagnostics, ExitStatus}; use crate::commands::{diagnostics, ExitStatus};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::ResolverSettings; use crate::settings::{NetworkSettings, ResolverSettings};
/// Run a command. /// Run a command.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -50,13 +48,11 @@ pub(crate) async fn tree(
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
settings: ResolverSettings, settings: ResolverSettings,
network_settings: &NetworkSettings,
script: Option<Pep723Script>, script: Option<Pep723Script>,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
no_config: bool, no_config: bool,
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
@ -77,6 +73,8 @@ pub(crate) async fn tree(
LockTarget::Script(_) => vec![], LockTarget::Script(_) => vec![],
}; };
let native_tls = network_settings.native_tls;
// Find an interpreter for the project, unless `--frozen` and `--universal` are both set. // Find an interpreter for the project, unless `--frozen` and `--universal` are both set.
let interpreter = if frozen && universal { let interpreter = if frozen && universal {
None None
@ -85,11 +83,9 @@ pub(crate) async fn tree(
LockTarget::Script(script) => ScriptInterpreter::discover( LockTarget::Script(script) => ScriptInterpreter::discover(
Pep723ItemRef::Script(script), Pep723ItemRef::Script(script),
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
Some(false), Some(false),
@ -102,11 +98,9 @@ pub(crate) async fn tree(
workspace, workspace,
project_dir, project_dir,
python.as_deref().map(PythonRequest::parse), python.as_deref().map(PythonRequest::parse),
network_settings,
python_preference, python_preference,
python_downloads, python_downloads,
connectivity,
native_tls,
allow_insecure_host,
&install_mirrors, &install_mirrors,
no_config, no_config,
Some(false), Some(false),
@ -138,12 +132,10 @@ pub(crate) async fn tree(
mode, mode,
target, target,
settings.as_ref(), settings.as_ref(),
network_settings,
&state, &state,
Box::new(DefaultResolveLogger), Box::new(DefaultResolveLogger),
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -211,10 +203,10 @@ pub(crate) async fn tree(
let client = RegistryClientBuilder::new( let client = RegistryClientBuilder::new(
cache.clone().with_refresh(Refresh::All(Timestamp::now())), cache.clone().with_refresh(Refresh::All(Timestamp::now())),
) )
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.keyring(*keyring_provider) .keyring(*keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.build(); .build();
let download_concurrency = Semaphore::new(concurrency.downloads); let download_concurrency = Semaphore::new(concurrency.downloads);

View File

@ -1,6 +1,7 @@
use crate::commands::reporters::PublishReporter; use crate::commands::reporters::PublishReporter;
use crate::commands::{human_readable_bytes, ExitStatus}; use crate::commands::{human_readable_bytes, ExitStatus};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::NetworkSettings;
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use console::Term; use console::Term;
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
@ -12,10 +13,8 @@ use tokio::sync::Semaphore;
use tracing::{debug, info}; use tracing::{debug, info};
use url::Url; use url::Url;
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::{ use uv_client::{AuthIntegration, BaseClient, BaseClientBuilder, RegistryClientBuilder};
AuthIntegration, BaseClient, BaseClientBuilder, Connectivity, RegistryClientBuilder, use uv_configuration::{KeyringProviderType, TrustedPublishing};
};
use uv_configuration::{KeyringProviderType, TrustedHost, TrustedPublishing};
use uv_distribution_types::{Index, IndexCapabilities, IndexLocations, IndexUrl}; use uv_distribution_types::{Index, IndexCapabilities, IndexLocations, IndexUrl};
use uv_publish::{ use uv_publish::{
check_trusted_publishing, files_for_publishing, upload, CheckUrlClient, TrustedPublishResult, check_trusted_publishing, files_for_publishing, upload, CheckUrlClient, TrustedPublishResult,
@ -27,16 +26,14 @@ pub(crate) async fn publish(
publish_url: Url, publish_url: Url,
trusted_publishing: TrustedPublishing, trusted_publishing: TrustedPublishing,
keyring_provider: KeyringProviderType, keyring_provider: KeyringProviderType,
allow_insecure_host: &[TrustedHost], network_settings: &NetworkSettings,
username: Option<String>, username: Option<String>,
password: Option<String>, password: Option<String>,
check_url: Option<IndexUrl>, check_url: Option<IndexUrl>,
cache: &Cache, cache: &Cache,
connectivity: Connectivity,
native_tls: bool,
printer: Printer, printer: Printer,
) -> Result<ExitStatus> { ) -> Result<ExitStatus> {
if connectivity.is_offline() { if network_settings.connectivity.is_offline() {
bail!("Unable to publish files in offline mode"); bail!("Unable to publish files in offline mode");
} }
@ -59,8 +56,8 @@ pub(crate) async fn publish(
let upload_client = BaseClientBuilder::new() let upload_client = BaseClientBuilder::new()
.retries(0) .retries(0)
.keyring(keyring_provider) .keyring(keyring_provider)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
// Don't try cloning the request to make an unauthenticated request first. // Don't try cloning the request to make an unauthenticated request first.
.auth_integration(AuthIntegration::OnlyAuthenticated) .auth_integration(AuthIntegration::OnlyAuthenticated)
// Set a very high timeout for uploads, connections are often 10x slower on upload than // 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(); .index_urls();
let registry_client_builder = RegistryClientBuilder::new(cache.clone()) let registry_client_builder = RegistryClientBuilder::new(cache.clone())
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.index_urls(index_urls) .index_urls(index_urls)
.keyring(keyring_provider) .keyring(keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
Some(CheckUrlClient { Some(CheckUrlClient {
index_url: index_url.clone(), index_url: index_url.clone(),
registry_client_builder, registry_client_builder,

View File

@ -11,9 +11,7 @@ use owo_colors::OwoColorize;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use tracing::{debug, trace}; use tracing::{debug, trace};
use uv_client::Connectivity;
use uv_configuration::PreviewMode; use uv_configuration::PreviewMode;
use uv_configuration::TrustedHost;
use uv_fs::Simplified; use uv_fs::Simplified;
use uv_python::downloads::{self, DownloadResult, ManagedPythonDownload, PythonDownloadRequest}; use uv_python::downloads::{self, DownloadResult, ManagedPythonDownload, PythonDownloadRequest};
use uv_python::managed::{ use uv_python::managed::{
@ -32,6 +30,7 @@ use crate::commands::python::{ChangeEvent, ChangeEventKind};
use crate::commands::reporters::PythonDownloadReporter; use crate::commands::reporters::PythonDownloadReporter;
use crate::commands::{elapsed, ExitStatus}; use crate::commands::{elapsed, ExitStatus};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::NetworkSettings;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct InstallRequest { struct InstallRequest {
@ -131,11 +130,9 @@ pub(crate) async fn install(
force: bool, force: bool,
python_install_mirror: Option<String>, python_install_mirror: Option<String>,
pypy_install_mirror: Option<String>, pypy_install_mirror: Option<String>,
network_settings: NetworkSettings,
default: bool, default: bool,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
native_tls: bool,
connectivity: Connectivity,
allow_insecure_host: &[TrustedHost],
no_config: bool, no_config: bool,
preview: PreviewMode, preview: PreviewMode,
printer: Printer, printer: Printer,
@ -296,9 +293,9 @@ pub(crate) async fn install(
// Download and unpack the Python versions concurrently // Download and unpack the Python versions concurrently
let client = uv_client::BaseClientBuilder::new() let client = uv_client::BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.build(); .build();
let reporter = PythonDownloadReporter::new(printer, downloads.len() as u64); let reporter = PythonDownloadReporter::new(printer, downloads.len() as u64);
let mut tasks = FuturesUnordered::new(); let mut tasks = FuturesUnordered::new();

View File

@ -7,8 +7,8 @@ use tracing::{debug, trace};
use uv_cache::{Cache, Refresh}; use uv_cache::{Cache, Refresh};
use uv_cache_info::Timestamp; use uv_cache_info::Timestamp;
use uv_client::{BaseClientBuilder, Connectivity}; use uv_client::BaseClientBuilder;
use uv_configuration::{Concurrency, DryRun, PreviewMode, Reinstall, TrustedHost, Upgrade}; use uv_configuration::{Concurrency, DryRun, PreviewMode, Reinstall, Upgrade};
use uv_distribution_types::{NameRequirementSpecification, UnresolvedRequirementSpecification}; use uv_distribution_types::{NameRequirementSpecification, UnresolvedRequirementSpecification};
use uv_normalize::PackageName; use uv_normalize::PackageName;
use uv_pep440::{VersionSpecifier, VersionSpecifiers}; use uv_pep440::{VersionSpecifier, VersionSpecifiers};
@ -34,7 +34,7 @@ use crate::commands::tool::{Target, ToolRequest};
use crate::commands::ExitStatus; use crate::commands::ExitStatus;
use crate::commands::{diagnostics, reporters::PythonDownloadReporter}; use crate::commands::{diagnostics, reporters::PythonDownloadReporter};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::ResolverInstallerSettings; use crate::settings::{NetworkSettings, ResolverInstallerSettings};
/// Install a tool. /// Install a tool.
#[allow(clippy::fn_params_excessive_bools)] #[allow(clippy::fn_params_excessive_bools)]
@ -50,21 +50,19 @@ pub(crate) async fn install(
force: bool, force: bool,
options: ResolverInstallerOptions, options: ResolverInstallerOptions,
settings: ResolverInstallerSettings, settings: ResolverInstallerSettings,
network_settings: NetworkSettings,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: Cache, cache: Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
) -> Result<ExitStatus> { ) -> Result<ExitStatus> {
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
let reporter = PythonDownloadReporter::single(printer); let reporter = PythonDownloadReporter::single(printer);
@ -90,9 +88,9 @@ pub(crate) async fn install(
let state = PlatformState::default(); let state = PlatformState::default();
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
// Parse the input requirement. // Parse the input requirement.
let request = ToolRequest::parse(&package, from.as_deref()); let request = ToolRequest::parse(&package, from.as_deref());
@ -131,11 +129,9 @@ pub(crate) async fn install(
requirement, requirement,
&interpreter, &interpreter,
&settings, &settings,
&network_settings,
&state, &state,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
&cache, &cache,
printer, printer,
preview, preview,
@ -245,11 +241,9 @@ pub(crate) async fn install(
spec.requirements.clone(), spec.requirements.clone(),
&interpreter, &interpreter,
&settings, &settings,
&network_settings,
&state, &state,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
&cache, &cache,
printer, printer,
preview, preview,
@ -271,11 +265,9 @@ pub(crate) async fn install(
spec.overrides, spec.overrides,
&interpreter, &interpreter,
&settings, &settings,
&network_settings,
&state, &state,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
&cache, &cache,
printer, printer,
preview, preview,
@ -401,14 +393,12 @@ pub(crate) async fn install(
spec, spec,
Modifications::Exact, Modifications::Exact,
&settings, &settings,
&network_settings,
&state, &state,
Box::new(DefaultResolveLogger), Box::new(DefaultResolveLogger),
Box::new(DefaultInstallLogger), Box::new(DefaultInstallLogger),
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
&cache, &cache,
DryRun::Disabled, DryRun::Disabled,
printer, printer,
@ -418,7 +408,7 @@ pub(crate) async fn install(
{ {
Ok(update) => update.into_environment(), Ok(update) => update.into_environment(),
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }
@ -441,12 +431,10 @@ pub(crate) async fn install(
spec.clone(), spec.clone(),
&interpreter, &interpreter,
settings.as_ref().into(), settings.as_ref().into(),
&network_settings,
&state, &state,
Box::new(DefaultResolveLogger), Box::new(DefaultResolveLogger),
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
&cache, &cache,
printer, printer,
preview, preview,
@ -478,7 +466,9 @@ pub(crate) async fn install(
.await .await
.ok() .ok()
.flatten() else { .flatten() else {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(
network_settings.native_tls,
)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())); .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()));
}; };
@ -493,12 +483,10 @@ pub(crate) async fn install(
spec, spec,
&interpreter, &interpreter,
settings.as_ref().into(), settings.as_ref().into(),
&network_settings,
&state, &state,
Box::new(DefaultResolveLogger), Box::new(DefaultResolveLogger),
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
&cache, &cache,
printer, printer,
preview, preview,
@ -507,7 +495,9 @@ pub(crate) async fn install(
{ {
Ok(resolution) => (resolution, interpreter), Ok(resolution) => (resolution, interpreter),
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(
network_settings.native_tls,
)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())); .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()));
} }
@ -532,13 +522,11 @@ pub(crate) async fn install(
&resolution.into(), &resolution.into(),
Modifications::Exact, Modifications::Exact,
settings.as_ref().into(), settings.as_ref().into(),
&network_settings,
&state, &state,
Box::new(DefaultInstallLogger), Box::new(DefaultInstallLogger),
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
&cache, &cache,
printer, printer,
preview, preview,
@ -551,7 +539,7 @@ pub(crate) async fn install(
}) { }) {
Ok(environment) => environment, Ok(environment) => environment,
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
} }

View File

@ -13,8 +13,8 @@ use tracing::{debug, warn};
use uv_cache::{Cache, Refresh}; use uv_cache::{Cache, Refresh};
use uv_cache_info::Timestamp; use uv_cache_info::Timestamp;
use uv_cli::ExternalCommand; use uv_cli::ExternalCommand;
use uv_client::{BaseClientBuilder, Connectivity}; use uv_client::BaseClientBuilder;
use uv_configuration::{Concurrency, PreviewMode, TrustedHost}; use uv_configuration::{Concurrency, PreviewMode};
use uv_distribution_types::{Name, UnresolvedRequirement, UnresolvedRequirementSpecification}; use uv_distribution_types::{Name, UnresolvedRequirement, UnresolvedRequirementSpecification};
use uv_installer::{SatisfiesResult, SitePackages}; use uv_installer::{SatisfiesResult, SitePackages};
use uv_normalize::PackageName; use uv_normalize::PackageName;
@ -45,6 +45,7 @@ use crate::commands::tool::{Target, ToolRequest};
use crate::commands::ExitStatus; use crate::commands::ExitStatus;
use crate::commands::{diagnostics, project::environment::CachedEnvironment}; use crate::commands::{diagnostics, project::environment::CachedEnvironment};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::NetworkSettings;
use crate::settings::ResolverInstallerSettings; use crate::settings::ResolverInstallerSettings;
/// The user-facing command used to invoke a tool run. /// The user-facing command used to invoke a tool run.
@ -75,15 +76,13 @@ pub(crate) async fn run(
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
settings: ResolverInstallerSettings, settings: ResolverInstallerSettings,
network_settings: NetworkSettings,
invocation_source: ToolRunCommand, invocation_source: ToolRunCommand,
isolated: bool, isolated: bool,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: Cache, cache: Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
@ -121,14 +120,12 @@ pub(crate) async fn run(
python.as_deref(), python.as_deref(),
install_mirrors, install_mirrors,
&settings, &settings,
&network_settings,
isolated, isolated,
python_preference, python_preference,
python_downloads, python_downloads,
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
&cache, &cache,
printer, printer,
preview, preview,
@ -138,7 +135,7 @@ pub(crate) async fn run(
let (from, environment) = match result { let (from, environment) = match result {
Ok(resolution) => resolution, Ok(resolution) => resolution,
Err(ProjectError::Operation(err)) => { Err(ProjectError::Operation(err)) => {
return diagnostics::OperationDiagnostic::native_tls(native_tls) return diagnostics::OperationDiagnostic::native_tls(network_settings.native_tls)
.with_context("tool") .with_context("tool")
.report(err) .report(err)
.map_or(Ok(ExitStatus::Failure), |err| Err(err.into())) .map_or(Ok(ExitStatus::Failure), |err| Err(err.into()))
@ -453,22 +450,20 @@ async fn get_or_create_environment(
python: Option<&str>, python: Option<&str>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
settings: &ResolverInstallerSettings, settings: &ResolverInstallerSettings,
network_settings: &NetworkSettings,
isolated: bool, isolated: bool,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
) -> Result<(ToolRequirement, PythonEnvironment), ProjectError> { ) -> Result<(ToolRequirement, PythonEnvironment), ProjectError> {
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
let reporter = PythonDownloadReporter::single(printer); let reporter = PythonDownloadReporter::single(printer);
@ -560,11 +555,9 @@ async fn get_or_create_environment(
vec![spec], vec![spec],
&interpreter, &interpreter,
settings, settings,
network_settings,
&state, &state,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -640,9 +633,9 @@ async fn get_or_create_environment(
// Read the `--with` requirements. // Read the `--with` requirements.
let spec = { let spec = {
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
RequirementsSpecification::from_simple_sources(with, &client_builder).await? RequirementsSpecification::from_simple_sources(with, &client_builder).await?
}; };
@ -658,11 +651,9 @@ async fn get_or_create_environment(
spec.requirements.clone(), spec.requirements.clone(),
&interpreter, &interpreter,
settings, settings,
network_settings,
&state, &state,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -727,6 +718,7 @@ async fn get_or_create_environment(
spec.clone(), spec.clone(),
&interpreter, &interpreter,
settings, settings,
network_settings,
&state, &state,
if show_resolution { if show_resolution {
Box::new(DefaultResolveLogger) Box::new(DefaultResolveLogger)
@ -739,10 +731,7 @@ async fn get_or_create_environment(
Box::new(SummaryInstallLogger) Box::new(SummaryInstallLogger)
}, },
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -786,6 +775,7 @@ async fn get_or_create_environment(
spec, spec,
&interpreter, &interpreter,
settings, settings,
network_settings,
&state, &state,
if show_resolution { if show_resolution {
Box::new(DefaultResolveLogger) Box::new(DefaultResolveLogger)
@ -798,10 +788,7 @@ async fn get_or_create_environment(
Box::new(SummaryInstallLogger) Box::new(SummaryInstallLogger)
}, },
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,

View File

@ -6,8 +6,8 @@ use std::fmt::Write;
use tracing::debug; use tracing::debug;
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::{BaseClientBuilder, Connectivity}; use uv_client::BaseClientBuilder;
use uv_configuration::{Concurrency, DryRun, PreviewMode, TrustedHost}; use uv_configuration::{Concurrency, DryRun, PreviewMode};
use uv_fs::CWD; use uv_fs::CWD;
use uv_normalize::PackageName; use uv_normalize::PackageName;
use uv_pypi_types::Requirement; use uv_pypi_types::Requirement;
@ -30,22 +30,20 @@ use crate::commands::reporters::PythonDownloadReporter;
use crate::commands::tool::common::remove_entrypoints; use crate::commands::tool::common::remove_entrypoints;
use crate::commands::{conjunction, tool::common::install_executables, ExitStatus}; use crate::commands::{conjunction, tool::common::install_executables, ExitStatus};
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::ResolverInstallerSettings; use crate::settings::{NetworkSettings, ResolverInstallerSettings};
/// Upgrade a tool. /// Upgrade a tool.
pub(crate) async fn upgrade( pub(crate) async fn upgrade(
names: Vec<String>, names: Vec<String>,
python: Option<String>, python: Option<String>,
install_mirrors: PythonInstallMirrors, install_mirrors: PythonInstallMirrors,
connectivity: Connectivity,
args: ResolverInstallerOptions, args: ResolverInstallerOptions,
filesystem: ResolverInstallerOptions, filesystem: ResolverInstallerOptions,
network_settings: NetworkSettings,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
installer_metadata: bool, installer_metadata: bool,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
cache: &Cache, cache: &Cache,
printer: Printer, printer: Printer,
preview: PreviewMode, preview: PreviewMode,
@ -81,9 +79,9 @@ pub(crate) async fn upgrade(
let reporter = PythonDownloadReporter::single(printer); let reporter = PythonDownloadReporter::single(printer);
let client_builder = BaseClientBuilder::new() let client_builder = BaseClientBuilder::new()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
let python_request = python.as_deref().map(PythonRequest::parse); let python_request = python.as_deref().map(PythonRequest::parse);
@ -123,13 +121,11 @@ pub(crate) async fn upgrade(
printer, printer,
&installed_tools, &installed_tools,
&args, &args,
&network_settings,
cache, cache,
&filesystem, &filesystem,
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
preview, preview,
) )
.await; .await;
@ -216,13 +212,11 @@ async fn upgrade_tool(
printer: Printer, printer: Printer,
installed_tools: &InstalledTools, installed_tools: &InstalledTools,
args: &ResolverInstallerOptions, args: &ResolverInstallerOptions,
network_settings: &NetworkSettings,
cache: &Cache, cache: &Cache,
filesystem: &ResolverInstallerOptions, filesystem: &ResolverInstallerOptions,
installer_metadata: bool, installer_metadata: bool,
connectivity: Connectivity,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
allow_insecure_host: &[TrustedHost],
preview: PreviewMode, preview: PreviewMode,
) -> Result<UpgradeOutcome> { ) -> Result<UpgradeOutcome> {
// Ensure the tool is installed. // Ensure the tool is installed.
@ -298,12 +292,10 @@ async fn upgrade_tool(
spec.into(), spec.into(),
interpreter, interpreter,
settings.as_ref().into(), settings.as_ref().into(),
network_settings,
&state, &state,
Box::new(SummaryResolveLogger), Box::new(SummaryResolveLogger),
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -317,13 +309,11 @@ async fn upgrade_tool(
&resolution.into(), &resolution.into(),
Modifications::Exact, Modifications::Exact,
settings.as_ref().into(), settings.as_ref().into(),
network_settings,
&state, &state,
Box::new(DefaultInstallLogger), Box::new(DefaultInstallLogger),
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
printer, printer,
preview, preview,
@ -343,14 +333,12 @@ async fn upgrade_tool(
spec, spec,
Modifications::Exact, Modifications::Exact,
&settings, &settings,
network_settings,
&state, &state,
Box::new(SummaryResolveLogger), Box::new(SummaryResolveLogger),
Box::new(UpgradeInstallLogger::new(name.clone())), Box::new(UpgradeInstallLogger::new(name.clone())),
installer_metadata, installer_metadata,
connectivity,
concurrency, concurrency,
native_tls,
allow_insecure_host,
cache, cache,
DryRun::Disabled, DryRun::Disabled,
printer, printer,

View File

@ -11,10 +11,10 @@ use owo_colors::OwoColorize;
use thiserror::Error; use thiserror::Error;
use uv_cache::Cache; use uv_cache::Cache;
use uv_client::{BaseClientBuilder, Connectivity, FlatIndexClient, RegistryClientBuilder}; use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
use uv_configuration::{ use uv_configuration::{
BuildOptions, Concurrency, ConfigSettings, Constraints, IndexStrategy, KeyringProviderType, BuildOptions, Concurrency, ConfigSettings, Constraints, IndexStrategy, KeyringProviderType,
NoBinary, NoBuild, PreviewMode, SourceStrategy, TrustedHost, NoBinary, NoBuild, PreviewMode, SourceStrategy,
}; };
use uv_dispatch::{BuildDispatch, SharedState}; use uv_dispatch::{BuildDispatch, SharedState};
use uv_distribution_types::{DependencyMetadata, Index, IndexLocations}; 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::reporters::PythonDownloadReporter;
use crate::commands::ExitStatus; use crate::commands::ExitStatus;
use crate::printer::Printer; use crate::printer::Printer;
use crate::settings::NetworkSettings;
/// Create a virtual environment. /// Create a virtual environment.
#[allow(clippy::unnecessary_wraps, clippy::fn_params_excessive_bools)] #[allow(clippy::unnecessary_wraps, clippy::fn_params_excessive_bools)]
@ -52,15 +53,13 @@ pub(crate) async fn venv(
index_strategy: IndexStrategy, index_strategy: IndexStrategy,
dependency_metadata: DependencyMetadata, dependency_metadata: DependencyMetadata,
keyring_provider: KeyringProviderType, keyring_provider: KeyringProviderType,
allow_insecure_host: &[TrustedHost], network_settings: &NetworkSettings,
prompt: uv_virtualenv::Prompt, prompt: uv_virtualenv::Prompt,
system_site_packages: bool, system_site_packages: bool,
connectivity: Connectivity,
seed: bool, seed: bool,
allow_existing: bool, allow_existing: bool,
exclude_newer: Option<ExcludeNewer>, exclude_newer: Option<ExcludeNewer>,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
no_config: bool, no_config: bool,
no_project: bool, no_project: bool,
cache: &Cache, cache: &Cache,
@ -78,17 +77,15 @@ pub(crate) async fn venv(
index_strategy, index_strategy,
dependency_metadata, dependency_metadata,
keyring_provider, keyring_provider,
allow_insecure_host, network_settings,
prompt, prompt,
system_site_packages, system_site_packages,
connectivity,
seed, seed,
python_preference, python_preference,
python_downloads, python_downloads,
allow_existing, allow_existing,
exclude_newer, exclude_newer,
concurrency, concurrency,
native_tls,
no_config, no_config,
no_project, no_project,
cache, cache,
@ -137,17 +134,15 @@ async fn venv_impl(
index_strategy: IndexStrategy, index_strategy: IndexStrategy,
dependency_metadata: DependencyMetadata, dependency_metadata: DependencyMetadata,
keyring_provider: KeyringProviderType, keyring_provider: KeyringProviderType,
allow_insecure_host: &[TrustedHost], network_settings: &NetworkSettings,
prompt: uv_virtualenv::Prompt, prompt: uv_virtualenv::Prompt,
system_site_packages: bool, system_site_packages: bool,
connectivity: Connectivity,
seed: bool, seed: bool,
python_preference: PythonPreference, python_preference: PythonPreference,
python_downloads: PythonDownloads, python_downloads: PythonDownloads,
allow_existing: bool, allow_existing: bool,
exclude_newer: Option<ExcludeNewer>, exclude_newer: Option<ExcludeNewer>,
concurrency: Concurrency, concurrency: Concurrency,
native_tls: bool,
no_config: bool, no_config: bool,
no_project: bool, no_project: bool,
cache: &Cache, cache: &Cache,
@ -193,9 +188,9 @@ async fn venv_impl(
); );
let client_builder = BaseClientBuilder::default() let client_builder = BaseClientBuilder::default()
.connectivity(connectivity) .connectivity(network_settings.connectivity)
.native_tls(native_tls) .native_tls(network_settings.native_tls)
.allow_insecure_host(allow_insecure_host.to_vec()); .allow_insecure_host(network_settings.allow_insecure_host.clone());
let reporter = PythonDownloadReporter::single(printer); let reporter = PythonDownloadReporter::single(printer);
@ -300,7 +295,7 @@ async fn venv_impl(
.index_urls(index_locations.index_urls()) .index_urls(index_locations.index_urls())
.index_strategy(index_strategy) .index_strategy(index_strategy)
.keyring(keyring_provider) .keyring(keyring_provider)
.allow_insecure_host(allow_insecure_host.to_vec()) .allow_insecure_host(network_settings.allow_insecure_host.clone())
.markers(interpreter.markers()) .markers(interpreter.markers())
.platform(interpreter.platform()) .platform(interpreter.platform())
.build(); .build();

View File

@ -150,12 +150,10 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
Some( Some(
RunCommand::from_args( RunCommand::from_args(
command, command,
settings.network_settings,
*module, *module,
*script, *script,
*gui_script, *gui_script,
settings.connectivity,
settings.native_tls,
&settings.allow_insecure_host,
) )
.await?, .await?,
) )
@ -424,9 +422,8 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.settings.index_strategy, args.settings.index_strategy,
args.settings.dependency_metadata, args.settings.dependency_metadata,
args.settings.keyring_provider, args.settings.keyring_provider,
&globals.allow_insecure_host, &globals.network_settings,
args.settings.config_setting, args.settings.config_setting,
globals.connectivity,
args.settings.no_build_isolation, args.settings.no_build_isolation,
args.settings.no_build_isolation_package, args.settings.no_build_isolation_package,
args.settings.build_options, args.settings.build_options,
@ -441,7 +438,6 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.settings.system, args.settings.system,
globals.python_preference, globals.python_preference,
globals.concurrency, globals.concurrency,
globals.native_tls,
globals.quiet, globals.quiet,
cache, cache,
printer, printer,
@ -493,9 +489,9 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.settings.index_strategy, args.settings.index_strategy,
args.settings.dependency_metadata, args.settings.dependency_metadata,
args.settings.keyring_provider, args.settings.keyring_provider,
&globals.network_settings,
args.settings.allow_empty_requirements, args.settings.allow_empty_requirements,
globals.installer_metadata, globals.installer_metadata,
globals.connectivity,
&args.settings.config_setting, &args.settings.config_setting,
args.settings.no_build_isolation, args.settings.no_build_isolation,
args.settings.no_build_isolation_package, args.settings.no_build_isolation_package,
@ -512,8 +508,6 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.settings.sources, args.settings.sources,
globals.python_preference, globals.python_preference,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
cache, cache,
args.dry_run, args.dry_run,
printer, printer,
@ -583,12 +577,12 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.settings.index_strategy, args.settings.index_strategy,
args.settings.dependency_metadata, args.settings.dependency_metadata,
args.settings.keyring_provider, args.settings.keyring_provider,
&globals.network_settings,
args.settings.reinstall, args.settings.reinstall,
args.settings.link_mode, args.settings.link_mode,
args.settings.compile_bytecode, args.settings.compile_bytecode,
args.settings.hash_checking, args.settings.hash_checking,
globals.installer_metadata, globals.installer_metadata,
globals.connectivity,
&args.settings.config_setting, &args.settings.config_setting,
args.settings.no_build_isolation, args.settings.no_build_isolation,
args.settings.no_build_isolation_package, args.settings.no_build_isolation_package,
@ -606,8 +600,6 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.settings.prefix, args.settings.prefix,
globals.python_preference, globals.python_preference,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
cache, cache,
args.dry_run, args.dry_run,
printer, printer,
@ -642,10 +634,8 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.settings.target, args.settings.target,
args.settings.prefix, args.settings.prefix,
cache, cache,
globals.connectivity,
globals.native_tls,
args.settings.keyring_provider, args.settings.keyring_provider,
&globals.allow_insecure_host, &globals.network_settings,
args.dry_run, args.dry_run,
printer, printer,
) )
@ -692,14 +682,12 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.settings.index_locations, args.settings.index_locations,
args.settings.index_strategy, args.settings.index_strategy,
args.settings.keyring_provider, args.settings.keyring_provider,
globals.allow_insecure_host, &globals.network_settings,
globals.connectivity,
globals.concurrency, globals.concurrency,
args.settings.strict, args.settings.strict,
args.settings.exclude_newer, args.settings.exclude_newer,
args.settings.python.as_deref(), args.settings.python.as_deref(),
args.settings.system, args.settings.system,
globals.native_tls,
&cache, &cache,
printer, printer,
) )
@ -746,14 +734,12 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.settings.index_locations, args.settings.index_locations,
args.settings.index_strategy, args.settings.index_strategy,
args.settings.keyring_provider, args.settings.keyring_provider,
globals.allow_insecure_host, globals.network_settings,
globals.connectivity,
globals.concurrency, globals.concurrency,
args.settings.strict, args.settings.strict,
args.settings.exclude_newer, args.settings.exclude_newer,
args.settings.python.as_deref(), args.settings.python.as_deref(),
args.settings.system, args.settings.system,
globals.native_tls,
&cache, &cache,
printer, printer,
) )
@ -829,13 +815,11 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.python, args.python,
args.install_mirrors, args.install_mirrors,
args.settings, args.settings,
&globals.network_settings,
cli.top_level.no_config, cli.top_level.no_config,
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
globals.connectivity,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
&cache, &cache,
printer, printer,
globals.preview, globals.preview,
@ -885,15 +869,13 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.settings.index_strategy, args.settings.index_strategy,
args.settings.dependency_metadata, args.settings.dependency_metadata,
args.settings.keyring_provider, args.settings.keyring_provider,
&globals.allow_insecure_host, &globals.network_settings,
uv_virtualenv::Prompt::from_args(prompt), uv_virtualenv::Prompt::from_args(prompt),
args.system_site_packages, args.system_site_packages,
globals.connectivity,
args.seed, args.seed,
args.allow_existing, args.allow_existing,
args.settings.exclude_newer, args.settings.exclude_newer,
globals.concurrency, globals.concurrency,
globals.native_tls,
cli.top_level.no_config, cli.top_level.no_config,
args.no_project, args.no_project,
&cache, &cache,
@ -1010,15 +992,13 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.python, args.python,
args.install_mirrors, args.install_mirrors,
args.settings, args.settings,
globals.network_settings,
invocation_source, invocation_source,
args.isolated, args.isolated,
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
globals.installer_metadata, globals.installer_metadata,
globals.connectivity,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
cache, cache,
printer, printer,
globals.preview, globals.preview,
@ -1079,13 +1059,11 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.force, args.force,
args.options, args.options,
args.settings, args.settings,
globals.network_settings,
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
globals.installer_metadata, globals.installer_metadata,
globals.connectivity,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
cache, cache,
printer, printer,
globals.preview, globals.preview,
@ -1124,15 +1102,13 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.names, args.names,
args.python, args.python,
args.install_mirrors, args.install_mirrors,
globals.connectivity,
args.args, args.args,
args.filesystem, args.filesystem,
globals.network_settings,
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
globals.installer_metadata, globals.installer_metadata,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
&cache, &cache,
printer, printer,
globals.preview, globals.preview,
@ -1203,11 +1179,9 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
args.force, args.force,
args.python_install_mirror, args.python_install_mirror,
args.pypy_install_mirror, args.pypy_install_mirror,
globals.network_settings,
args.default, args.default,
globals.python_downloads, globals.python_downloads,
globals.native_tls,
globals.connectivity,
&globals.allow_insecure_host,
cli.top_level.no_config, cli.top_level.no_config,
globals.preview, globals.preview,
printer, printer,
@ -1347,13 +1321,11 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
publish_url, publish_url,
trusted_publishing, trusted_publishing,
keyring_provider, keyring_provider,
&globals.allow_insecure_host, &globals.network_settings,
username, username,
password, password,
check_url, check_url,
&cache, &cache,
globals.connectivity,
globals.native_tls,
printer, printer,
) )
.await .await
@ -1447,11 +1419,9 @@ async fn run_project(
args.python, args.python,
args.install_mirrors, args.install_mirrors,
args.no_workspace, args.no_workspace,
&globals.network_settings,
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
globals.connectivity,
globals.native_tls,
&globals.allow_insecure_host,
no_config, no_config,
&cache, &cache,
printer, printer,
@ -1510,13 +1480,11 @@ async fn run_project(
args.python, args.python,
args.install_mirrors, args.install_mirrors,
args.settings, args.settings,
globals.network_settings,
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
globals.installer_metadata, globals.installer_metadata,
globals.connectivity,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
&cache, &cache,
printer, printer,
args.env_file, args.env_file,
@ -1563,12 +1531,10 @@ async fn run_project(
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
args.settings, args.settings,
globals.network_settings,
script, script,
globals.installer_metadata, globals.installer_metadata,
globals.connectivity,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
no_config, no_config,
&cache, &cache,
printer, printer,
@ -1608,13 +1574,11 @@ async fn run_project(
args.python, args.python,
args.install_mirrors, args.install_mirrors,
args.settings, args.settings,
globals.network_settings,
script, script,
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
globals.connectivity,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
no_config, no_config,
&cache, &cache,
printer, printer,
@ -1677,14 +1641,12 @@ async fn run_project(
args.python, args.python,
args.install_mirrors, args.install_mirrors,
args.settings, args.settings,
globals.network_settings,
script, script,
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
globals.installer_metadata, globals.installer_metadata,
globals.connectivity,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
no_config, no_config,
&cache, &cache,
printer, printer,
@ -1723,14 +1685,12 @@ async fn run_project(
args.python, args.python,
args.install_mirrors, args.install_mirrors,
args.settings, args.settings,
globals.network_settings,
script, script,
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
globals.installer_metadata, globals.installer_metadata,
globals.connectivity,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
no_config, no_config,
&cache, &cache,
printer, printer,
@ -1770,13 +1730,11 @@ async fn run_project(
args.python, args.python,
args.install_mirrors, args.install_mirrors,
args.resolver, args.resolver,
&globals.network_settings,
script, script,
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
globals.connectivity,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
no_config, no_config,
&cache, &cache,
printer, printer,
@ -1818,12 +1776,10 @@ async fn run_project(
args.python, args.python,
args.install_mirrors, args.install_mirrors,
args.settings, args.settings,
globals.network_settings,
globals.python_preference, globals.python_preference,
globals.python_downloads, globals.python_downloads,
globals.connectivity,
globals.concurrency, globals.concurrency,
globals.native_tls,
&globals.allow_insecure_host,
no_config, no_config,
globals.quiet, globals.quiet,
&cache, &cache,

View File

@ -59,10 +59,8 @@ pub(crate) struct GlobalSettings {
pub(crate) quiet: bool, pub(crate) quiet: bool,
pub(crate) verbose: u8, pub(crate) verbose: u8,
pub(crate) color: ColorChoice, pub(crate) color: ColorChoice,
pub(crate) native_tls: bool, pub(crate) network_settings: NetworkSettings,
pub(crate) concurrency: Concurrency, pub(crate) concurrency: Concurrency,
pub(crate) connectivity: Connectivity,
pub(crate) allow_insecure_host: Vec<TrustedHost>,
pub(crate) show_settings: bool, pub(crate) show_settings: bool,
pub(crate) preview: PreviewMode, pub(crate) preview: PreviewMode,
pub(crate) python_preference: PythonPreference, pub(crate) python_preference: PythonPreference,
@ -74,6 +72,7 @@ pub(crate) struct GlobalSettings {
impl GlobalSettings { impl GlobalSettings {
/// Resolve the [`GlobalSettings`] from the CLI and filesystem configuration. /// Resolve the [`GlobalSettings`] from the CLI and filesystem configuration.
pub(crate) fn resolve(args: &GlobalArgs, workspace: Option<&FilesystemOptions>) -> Self { pub(crate) fn resolve(args: &GlobalArgs, workspace: Option<&FilesystemOptions>) -> Self {
let network_settings = NetworkSettings::resolve(args, workspace);
Self { Self {
required_version: workspace required_version: workspace
.and_then(|workspace| workspace.globals.required_version.clone()), .and_then(|workspace| workspace.globals.required_version.clone()),
@ -100,9 +99,7 @@ impl GlobalSettings {
} else { } else {
ColorChoice::Auto ColorChoice::Auto
}, },
native_tls: flag(args.native_tls, args.no_native_tls) network_settings,
.combine(workspace.and_then(|workspace| workspace.globals.native_tls))
.unwrap_or(false),
concurrency: Concurrency { concurrency: Concurrency {
downloads: env(env::CONCURRENT_DOWNLOADS) downloads: env(env::CONCURRENT_DOWNLOADS)
.combine(workspace.and_then(|workspace| workspace.globals.concurrent_downloads)) .combine(workspace.and_then(|workspace| workspace.globals.concurrent_downloads))
@ -117,31 +114,6 @@ impl GlobalSettings {
.map(NonZeroUsize::get) .map(NonZeroUsize::get)
.unwrap_or_else(Concurrency::threads), .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, show_settings: args.show_settings,
preview: PreviewMode::from( preview: PreviewMode::from(
flag(args.preview, args.no_preview) 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<TrustedHost>,
}
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. /// The resolved cache settings to use for any invocation of the CLI.
#[allow(clippy::struct_excessive_bools)] #[allow(clippy::struct_excessive_bools)]
#[derive(Debug, Clone)] #[derive(Debug, Clone)]

File diff suppressed because it is too large Load Diff