diff --git a/crates/uv/src/commands/project/add.rs b/crates/uv/src/commands/project/add.rs index a0122d0ad..f1e4bfb57 100644 --- a/crates/uv/src/commands/project/add.rs +++ b/crates/uv/src/commands/project/add.rs @@ -186,16 +186,7 @@ pub(crate) async fn add( let lock = project::lock::do_lock( project.workspace(), venv.interpreter(), - &settings.upgrade, - &settings.index_locations, - settings.index_strategy, - settings.keyring_provider, - settings.resolution, - settings.prerelease, - &settings.config_setting, - settings.exclude_newer, - settings.link_mode, - &settings.build_options, + settings.clone().into(), preview, connectivity, concurrency, @@ -218,14 +209,7 @@ pub(crate) async fn add( extras, dev, Modifications::Sufficient, - &settings.reinstall, - &settings.index_locations, - settings.index_strategy, - settings.keyring_provider, - &settings.config_setting, - settings.link_mode, - settings.compile_bytecode, - &settings.build_options, + settings.into(), preview, connectivity, concurrency, diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index b1a506473..20ec9e730 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -2,23 +2,16 @@ use std::collections::Bound; use anstream::eprint; -use distribution_types::{IndexLocations, UnresolvedRequirementSpecification}; -use install_wheel_rs::linker::LinkMode; +use distribution_types::UnresolvedRequirementSpecification; use pep508_rs::RequirementOrigin; use uv_cache::Cache; use uv_client::{Connectivity, FlatIndexClient, RegistryClientBuilder}; -use uv_configuration::{ - BuildOptions, Concurrency, ConfigSettings, ExtrasSpecification, IndexStrategy, - KeyringProviderType, PreviewMode, Reinstall, SetupPyStrategy, Upgrade, -}; +use uv_configuration::{Concurrency, ExtrasSpecification, PreviewMode, Reinstall, SetupPyStrategy}; use uv_dispatch::BuildDispatch; use uv_distribution::{Workspace, DEV_DEPENDENCIES}; use uv_git::GitResolver; use uv_requirements::upgrade::{read_lockfile, LockedRequirements}; -use uv_resolver::{ - ExcludeNewer, FlatIndex, InMemoryIndex, Lock, OptionsBuilder, PreReleaseMode, RequiresPython, - ResolutionMode, -}; +use uv_resolver::{FlatIndex, InMemoryIndex, Lock, OptionsBuilder, RequiresPython}; use uv_toolchain::{Interpreter, ToolchainPreference, ToolchainRequest}; use uv_types::{BuildIsolation, EmptyInstalledPackages, HashStrategy, InFlight}; use uv_warnings::warn_user; @@ -64,16 +57,7 @@ pub(crate) async fn lock( match do_lock( &workspace, &interpreter, - &settings.upgrade, - &settings.index_locations, - settings.index_strategy, - settings.keyring_provider, - settings.resolution, - settings.prerelease, - &settings.config_setting, - settings.exclude_newer, - settings.link_mode, - &settings.build_options, + settings, preview, connectivity, concurrency, @@ -101,16 +85,7 @@ pub(crate) async fn lock( pub(super) async fn do_lock( workspace: &Workspace, interpreter: &Interpreter, - upgrade: &Upgrade, - index_locations: &IndexLocations, - index_strategy: IndexStrategy, - keyring_provider: KeyringProviderType, - resolution: ResolutionMode, - prerelease: PreReleaseMode, - config_setting: &ConfigSettings, - exclude_newer: Option, - link_mode: LinkMode, - build_options: &BuildOptions, + settings: ResolverSettings, preview: PreviewMode, connectivity: Connectivity, concurrency: Concurrency, @@ -118,6 +93,20 @@ pub(super) async fn do_lock( cache: &Cache, printer: Printer, ) -> Result { + // Extract the project settings. + let ResolverSettings { + index_locations, + index_strategy, + keyring_provider, + resolution, + prerelease, + config_setting, + exclude_newer, + link_mode, + upgrade, + build_options, + } = settings; + // When locking, include the project itself (as editable). let requirements = workspace .members_as_requirements() @@ -204,11 +193,11 @@ pub(super) async fn do_lock( let flat_index = { let client = FlatIndexClient::new(&client, cache); let entries = client.fetch(index_locations.flat_index()).await?; - FlatIndex::from_entries(entries, None, &hasher, build_options) + FlatIndex::from_entries(entries, None, &hasher, &build_options) }; // If an existing lockfile exists, build up a set of preferences. - let LockedRequirements { preferences, git } = read_lockfile(workspace, upgrade).await?; + let LockedRequirements { preferences, git } = read_lockfile(workspace, &upgrade).await?; // Create the Git resolver. let git = GitResolver::from_refs(git); @@ -218,17 +207,17 @@ pub(super) async fn do_lock( &client, cache, interpreter, - index_locations, + &index_locations, &flat_index, &index, &git, &in_flight, index_strategy, setup_py, - config_setting, + &config_setting, build_isolation, link_mode, - build_options, + &build_options, exclude_newer, concurrency, preview, @@ -247,7 +236,7 @@ pub(super) async fn do_lock( EmptyInstalledPackages, &hasher, &Reinstall::default(), - upgrade, + &upgrade, interpreter, None, None, diff --git a/crates/uv/src/commands/project/remove.rs b/crates/uv/src/commands/project/remove.rs index b72e12fd1..ef230a4cb 100644 --- a/crates/uv/src/commands/project/remove.rs +++ b/crates/uv/src/commands/project/remove.rs @@ -101,16 +101,7 @@ pub(crate) async fn remove( let lock = project::lock::do_lock( project.workspace(), venv.interpreter(), - &settings.upgrade, - &settings.index_locations, - settings.index_strategy, - settings.keyring_provider, - settings.resolution, - settings.prerelease, - &settings.config_setting, - settings.exclude_newer, - settings.link_mode, - &settings.build_options, + settings, preview, connectivity, concurrency, @@ -134,14 +125,7 @@ pub(crate) async fn remove( extras, dev, Modifications::Exact, - &settings.reinstall, - &settings.index_locations, - settings.index_strategy, - settings.keyring_provider, - &settings.config_setting, - settings.link_mode, - settings.compile_bytecode, - &settings.build_options, + settings, preview, connectivity, concurrency, diff --git a/crates/uv/src/commands/project/run.rs b/crates/uv/src/commands/project/run.rs index 9145f42a3..7a3b4ec33 100644 --- a/crates/uv/src/commands/project/run.rs +++ b/crates/uv/src/commands/project/run.rs @@ -78,16 +78,7 @@ pub(crate) async fn run( let lock = project::lock::do_lock( project.workspace(), venv.interpreter(), - &settings.upgrade, - &settings.index_locations, - settings.index_strategy, - settings.keyring_provider, - settings.resolution, - settings.prerelease, - &settings.config_setting, - settings.exclude_newer, - settings.link_mode, - &settings.build_options, + settings.clone().into(), preview, connectivity, concurrency, @@ -104,14 +95,7 @@ pub(crate) async fn run( extras, dev, Modifications::Sufficient, - &settings.reinstall, - &settings.index_locations, - settings.index_strategy, - settings.keyring_provider, - &settings.config_setting, - settings.link_mode, - settings.compile_bytecode, - &settings.build_options, + settings.clone().into(), preview, connectivity, concurrency, diff --git a/crates/uv/src/commands/project/sync.rs b/crates/uv/src/commands/project/sync.rs index 77e3c310e..b45a682b9 100644 --- a/crates/uv/src/commands/project/sync.rs +++ b/crates/uv/src/commands/project/sync.rs @@ -2,14 +2,9 @@ use std::path::Path; use anyhow::Result; -use distribution_types::IndexLocations; -use install_wheel_rs::linker::LinkMode; use uv_cache::Cache; use uv_client::{Connectivity, FlatIndexClient, RegistryClientBuilder}; -use uv_configuration::{ - BuildOptions, Concurrency, ConfigSettings, ExtrasSpecification, IndexStrategy, - KeyringProviderType, PreviewMode, Reinstall, SetupPyStrategy, -}; +use uv_configuration::{Concurrency, ExtrasSpecification, PreviewMode, SetupPyStrategy}; use uv_dispatch::BuildDispatch; use uv_distribution::{ProjectWorkspace, DEV_DEPENDENCIES}; use uv_git::GitResolver; @@ -77,14 +72,7 @@ pub(crate) async fn sync( extras, dev, modifications, - &settings.reinstall, - &settings.index_locations, - settings.index_strategy, - settings.keyring_provider, - &settings.config_setting, - settings.link_mode, - settings.compile_bytecode, - &settings.build_options, + settings, preview, connectivity, concurrency, @@ -107,14 +95,7 @@ pub(super) async fn do_sync( extras: ExtrasSpecification, dev: bool, modifications: Modifications, - reinstall: &Reinstall, - index_locations: &IndexLocations, - index_strategy: IndexStrategy, - keyring_provider: KeyringProviderType, - config_setting: &ConfigSettings, - link_mode: LinkMode, - compile_bytecode: bool, - build_options: &BuildOptions, + settings: InstallerSettings, preview: PreviewMode, connectivity: Connectivity, concurrency: Concurrency, @@ -122,6 +103,18 @@ pub(super) async fn do_sync( cache: &Cache, printer: Printer, ) -> Result<(), ProjectError> { + // Extract the project settings. + let InstallerSettings { + index_locations, + index_strategy, + keyring_provider, + config_setting, + link_mode, + compile_bytecode, + reinstall, + build_options, + } = settings; + // Validate that the Python version is supported by the lockfile. if let Some(requires_python) = lock.requires_python() { if !requires_python.contains(venv.interpreter().python_version()) { @@ -174,7 +167,7 @@ pub(super) async fn do_sync( let flat_index = { let client = FlatIndexClient::new(&client, cache); let entries = client.fetch(index_locations.flat_index()).await?; - FlatIndex::from_entries(entries, Some(tags), &hasher, build_options) + FlatIndex::from_entries(entries, Some(tags), &hasher, &build_options) }; // Create a build dispatch. @@ -182,17 +175,17 @@ pub(super) async fn do_sync( &client, cache, venv.interpreter(), - index_locations, + &index_locations, &flat_index, &index, &git, &in_flight, index_strategy, setup_py, - config_setting, + &config_setting, build_isolation, link_mode, - build_options, + &build_options, exclude_newer, concurrency, preview, @@ -205,11 +198,11 @@ pub(super) async fn do_sync( &resolution, site_packages, modifications, - reinstall, - build_options, + &reinstall, + &build_options, link_mode, compile_bytecode, - index_locations, + &index_locations, &hasher, tags, &client, diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 4abff65be..96296ea7d 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -1681,6 +1681,38 @@ impl PipSettings { } } +impl From for ResolverSettings { + fn from(settings: ResolverInstallerSettings) -> Self { + Self { + index_locations: settings.index_locations, + index_strategy: settings.index_strategy, + keyring_provider: settings.keyring_provider, + resolution: settings.resolution, + prerelease: settings.prerelease, + config_setting: settings.config_setting, + exclude_newer: settings.exclude_newer, + link_mode: settings.link_mode, + upgrade: settings.upgrade, + build_options: settings.build_options, + } + } +} + +impl From for InstallerSettings { + fn from(settings: ResolverInstallerSettings) -> Self { + Self { + index_locations: settings.index_locations, + index_strategy: settings.index_strategy, + keyring_provider: settings.keyring_provider, + config_setting: settings.config_setting, + link_mode: settings.link_mode, + compile_bytecode: settings.compile_bytecode, + reinstall: settings.reinstall, + build_options: settings.build_options, + } + } +} + // Environment variables that are not exposed as CLI arguments. mod env { pub(super) const CONCURRENT_DOWNLOADS: (&str, &str) =