Make --reinstall, --upgrade, and --refresh shared arguments (#4319)

## Summary

Ensures that we respect these in all the relevant `uv` APIs.

Closes https://github.com/astral-sh/uv/issues/4316.
This commit is contained in:
Charlie Marsh 2024-06-13 18:43:18 -07:00 committed by GitHub
parent db84825908
commit 1d6d98f3a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 346 additions and 275 deletions

View file

@ -77,6 +77,10 @@ impl Combine for ResolverInstallerOptions {
exclude_newer: self.exclude_newer.combine(other.exclude_newer),
link_mode: self.link_mode.combine(other.link_mode),
compile_bytecode: self.compile_bytecode.combine(other.compile_bytecode),
upgrade: self.upgrade.combine(other.upgrade),
upgrade_package: self.upgrade_package.combine(other.upgrade_package),
reinstall: self.reinstall.combine(other.reinstall),
reinstall_package: self.reinstall_package.combine(other.reinstall_package),
}
}
}
@ -142,6 +146,10 @@ impl Combine for PipOptions {
link_mode: self.link_mode.combine(other.link_mode),
compile_bytecode: self.compile_bytecode.combine(other.compile_bytecode),
require_hashes: self.require_hashes.combine(other.require_hashes),
upgrade: self.upgrade.combine(other.upgrade),
upgrade_package: self.upgrade_package.combine(other.upgrade_package),
reinstall: self.reinstall.combine(other.reinstall),
reinstall_package: self.reinstall_package.combine(other.reinstall_package),
concurrent_downloads: self
.concurrent_downloads
.combine(other.concurrent_downloads),

View file

@ -75,6 +75,8 @@ pub struct InstallerOptions {
pub config_settings: Option<ConfigSettings>,
pub link_mode: Option<LinkMode>,
pub compile_bytecode: Option<bool>,
pub reinstall: Option<bool>,
pub reinstall_package: Option<Vec<PackageName>>,
}
/// Settings relevant to all resolver operations.
@ -94,6 +96,8 @@ pub struct ResolverOptions {
pub config_settings: Option<ConfigSettings>,
pub exclude_newer: Option<ExcludeNewer>,
pub link_mode: Option<LinkMode>,
pub upgrade: Option<bool>,
pub upgrade_package: Option<Vec<PackageName>>,
}
/// Shared settings, relevant to all operations that must resolve and install dependencies. The
@ -115,6 +119,10 @@ pub struct ResolverInstallerOptions {
pub exclude_newer: Option<ExcludeNewer>,
pub link_mode: Option<LinkMode>,
pub compile_bytecode: Option<bool>,
pub upgrade: Option<bool>,
pub upgrade_package: Option<Vec<PackageName>>,
pub reinstall: Option<bool>,
pub reinstall_package: Option<Vec<PackageName>>,
}
/// A `[tool.uv.pip]` section.
@ -164,6 +172,10 @@ pub struct PipOptions {
pub link_mode: Option<LinkMode>,
pub compile_bytecode: Option<bool>,
pub require_hashes: Option<bool>,
pub upgrade: Option<bool>,
pub upgrade_package: Option<Vec<PackageName>>,
pub reinstall: Option<bool>,
pub reinstall_package: Option<Vec<PackageName>>,
pub concurrent_downloads: Option<NonZeroUsize>,
pub concurrent_builds: Option<NonZeroUsize>,
pub concurrent_installs: Option<NonZeroUsize>,
@ -217,6 +229,10 @@ impl Options {
link_mode,
compile_bytecode,
require_hashes,
upgrade,
upgrade_package,
reinstall,
reinstall_package,
concurrent_builds,
concurrent_downloads,
concurrent_installs,
@ -235,6 +251,10 @@ impl Options {
exclude_newer: top_level_exclude_newer,
link_mode: top_level_link_mode,
compile_bytecode: top_level_compile_bytecode,
upgrade: top_level_upgrade,
upgrade_package: top_level_upgrade_package,
reinstall: top_level_reinstall,
reinstall_package: top_level_reinstall_package,
} = self.top_level;
PipOptions {
@ -279,6 +299,10 @@ impl Options {
link_mode: link_mode.or(top_level_link_mode),
compile_bytecode: compile_bytecode.or(top_level_compile_bytecode),
require_hashes,
upgrade: upgrade.or(top_level_upgrade),
upgrade_package: upgrade_package.or(top_level_upgrade_package),
reinstall: reinstall.or(top_level_reinstall),
reinstall_package: reinstall_package.or(top_level_reinstall_package),
concurrent_builds,
concurrent_downloads,
concurrent_installs,