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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff