From d24b075b2de3479f6daafc23d81bbfdd203eb8b1 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 3 Jul 2024 14:05:05 -0400 Subject: [PATCH] Add `--exclude-newer` to installer arguments (#4785) ## Summary We already support this in `pip sync` and have it stubbed to `None` in `sync. --- crates/uv-cli/src/lib.rs | 14 +++++++------- crates/uv-cli/src/options.rs | 4 ++++ crates/uv-settings/src/settings.rs | 1 + crates/uv/src/commands/project/sync.rs | 2 +- crates/uv/src/settings.rs | 9 ++++++--- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index bc832e44b..268ed6ee7 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -668,13 +668,6 @@ pub struct PipSyncArgs { #[command(flatten)] pub refresh: RefreshArgs, - /// Limit candidate packages to those that were uploaded prior to the given date. - /// - /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and UTC dates in the same - /// format (e.g., `2006-12-02`). - #[arg(long, env = "UV_EXCLUDE_NEWER")] - pub exclude_newer: Option, - /// Require a matching hash for each requirement. /// /// Hash-checking mode is all or nothing. If enabled, _all_ requirements must be provided @@ -2228,6 +2221,13 @@ pub struct InstallerArgs { #[arg(long, short = 'C', alias = "config-settings")] pub config_setting: Option>, + /// Limit candidate packages to those that were uploaded prior to the given date. + /// + /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and UTC dates in the same + /// format (e.g., `2006-12-02`). + #[arg(long, env = "UV_EXCLUDE_NEWER")] + pub exclude_newer: Option, + /// The method to use when installing packages from the global cache. /// /// Defaults to `clone` (also known as Copy-on-Write) on macOS, and `hardlink` on Linux and diff --git a/crates/uv-cli/src/options.rs b/crates/uv-cli/src/options.rs index d552dbaed..77cdacf46 100644 --- a/crates/uv-cli/src/options.rs +++ b/crates/uv-cli/src/options.rs @@ -76,6 +76,7 @@ impl From for PipOptions { index_strategy, keyring_provider, config_setting, + exclude_newer, link_mode, compile_bytecode, no_compile_bytecode, @@ -88,6 +89,7 @@ impl From for PipOptions { keyring_provider, config_settings: config_setting .map(|config_settings| config_settings.into_iter().collect::()), + exclude_newer, link_mode, compile_bytecode: flag(compile_bytecode, no_compile_bytecode), ..PipOptions::from(index_args) @@ -174,6 +176,7 @@ pub fn installer_options(installer_args: InstallerArgs, build_args: BuildArgs) - index_strategy, keyring_provider, config_setting, + exclude_newer, link_mode, compile_bytecode, no_compile_bytecode, @@ -208,6 +211,7 @@ pub fn installer_options(installer_args: InstallerArgs, build_args: BuildArgs) - keyring_provider, config_settings: config_setting .map(|config_settings| config_settings.into_iter().collect::()), + exclude_newer, link_mode, compile_bytecode: flag(compile_bytecode, no_compile_bytecode), no_build: flag(no_build, build), diff --git a/crates/uv-settings/src/settings.rs b/crates/uv-settings/src/settings.rs index ae1c2e13d..83212c92f 100644 --- a/crates/uv-settings/src/settings.rs +++ b/crates/uv-settings/src/settings.rs @@ -76,6 +76,7 @@ pub struct InstallerOptions { pub index_strategy: Option, pub keyring_provider: Option, pub config_settings: Option, + pub exclude_newer: Option, pub link_mode: Option, pub compile_bytecode: Option, pub reinstall: Option, diff --git a/crates/uv/src/commands/project/sync.rs b/crates/uv/src/commands/project/sync.rs index 9847cee59..8f2c79468 100644 --- a/crates/uv/src/commands/project/sync.rs +++ b/crates/uv/src/commands/project/sync.rs @@ -105,6 +105,7 @@ pub(super) async fn do_sync( index_strategy, keyring_provider, config_setting, + exclude_newer, link_mode, compile_bytecode, reinstall, @@ -149,7 +150,6 @@ pub(super) async fn do_sync( // optional on the downstream APIs. let build_isolation = BuildIsolation::default(); let dry_run = false; - let exclude_newer = None; let hasher = HashStrategy::default(); let setup_py = SetupPyStrategy::default(); diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 823bc9a63..1b38d2859 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -746,7 +746,6 @@ impl PipSyncSettings { constraint, installer, refresh, - exclude_newer, require_hashes, no_require_hashes, python, @@ -787,7 +786,6 @@ impl PipSyncSettings { python, system: flag(system, no_system), break_system_packages: flag(break_system_packages, no_break_system_packages), - exclude_newer, target, prefix, require_hashes: flag(require_hashes, no_require_hashes), @@ -1232,6 +1230,7 @@ pub(crate) struct InstallerSettings { pub(crate) index_strategy: IndexStrategy, pub(crate) keyring_provider: KeyringProviderType, pub(crate) config_setting: ConfigSettings, + pub(crate) exclude_newer: Option, pub(crate) link_mode: LinkMode, pub(crate) compile_bytecode: bool, pub(crate) reinstall: Reinstall, @@ -1244,6 +1243,7 @@ pub(crate) struct InstallerSettingsRef<'a> { pub(crate) index_strategy: IndexStrategy, pub(crate) keyring_provider: KeyringProviderType, pub(crate) config_setting: &'a ConfigSettings, + pub(crate) exclude_newer: Option, pub(crate) link_mode: LinkMode, pub(crate) compile_bytecode: bool, pub(crate) reinstall: &'a Reinstall, @@ -1263,7 +1263,7 @@ impl InstallerSettings { resolution: _, prerelease: _, config_settings, - exclude_newer: _, + exclude_newer, link_mode, compile_bytecode, upgrade: _, @@ -1300,6 +1300,7 @@ impl InstallerSettings { .config_settings .combine(config_settings) .unwrap_or_default(), + exclude_newer: args.exclude_newer.combine(exclude_newer), link_mode: args.link_mode.combine(link_mode).unwrap_or_default(), compile_bytecode: args .compile_bytecode @@ -1334,6 +1335,7 @@ impl InstallerSettings { index_strategy: self.index_strategy, keyring_provider: self.keyring_provider, config_setting: &self.config_setting, + exclude_newer: self.exclude_newer, link_mode: self.link_mode, compile_bytecode: self.compile_bytecode, reinstall: &self.reinstall, @@ -1958,6 +1960,7 @@ impl<'a> From> for InstallerSettingsRef<'a> { index_strategy: settings.index_strategy, keyring_provider: settings.keyring_provider, config_setting: settings.config_setting, + exclude_newer: settings.exclude_newer, link_mode: settings.link_mode, compile_bytecode: settings.compile_bytecode, reinstall: settings.reinstall,