diff --git a/Cargo.lock b/Cargo.lock index ef7511af52942..380355c19576c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5807,6 +5807,7 @@ version = "0.0.1" dependencies = [ "clap", "fs-err 3.1.1", + "rustc-hash", "schemars", "serde", "textwrap", diff --git a/crates/uv-bench/benches/uv.rs b/crates/uv-bench/benches/uv.rs index 9bdd7adb92377..885e68785b1a5 100644 --- a/crates/uv-bench/benches/uv.rs +++ b/crates/uv-bench/benches/uv.rs @@ -99,8 +99,8 @@ mod resolver { use uv_pypi_types::{Conflicts, ResolverMarkerEnvironment}; use uv_python::Interpreter; use uv_resolver::{ - FlatIndex, InMemoryIndex, Manifest, OptionsBuilder, PythonRequirement, Resolver, - ResolverEnvironment, ResolverOutput, + ExcludeNewer, FlatIndex, InMemoryIndex, Manifest, OptionsBuilder, PythonRequirement, + Resolver, ResolverEnvironment, ResolverOutput, }; use uv_types::{BuildIsolation, EmptyInstalledPackages, HashStrategy}; use uv_workspace::WorkspaceCache; @@ -144,7 +144,7 @@ mod resolver { let build_options = BuildOptions::default(); let concurrency = Concurrency::default(); let config_settings = ConfigSettings::default(); - let exclude_newer = Some( + let exclude_newer = ExcludeNewer::global( jiff::civil::date(2024, 9, 1) .to_zoned(jiff::tz::TimeZone::UTC) .unwrap() @@ -158,7 +158,9 @@ mod resolver { let index = InMemoryIndex::default(); let index_locations = IndexLocations::default(); let installed_packages = EmptyInstalledPackages; - let options = OptionsBuilder::new().exclude_newer(exclude_newer).build(); + let options = OptionsBuilder::new() + .exclude_newer(exclude_newer.clone()) + .build(); let sources = SourceStrategy::default(); let dependency_metadata = DependencyMetadata::default(); let conflicts = Conflicts::empty(); diff --git a/crates/uv-cli/src/lib.rs b/crates/uv-cli/src/lib.rs index bf605198fa6e4..1d285c709512e 100644 --- a/crates/uv-cli/src/lib.rs +++ b/crates/uv-cli/src/lib.rs @@ -19,7 +19,10 @@ use uv_pep508::{MarkerTree, Requirement}; use uv_pypi_types::VerbatimParsedUrl; use uv_python::{PythonDownloads, PythonPreference, PythonVersion}; use uv_redacted::DisplaySafeUrl; -use uv_resolver::{AnnotationStyle, ExcludeNewer, ForkStrategy, PrereleaseMode, ResolutionMode}; +use uv_resolver::{ + AnnotationStyle, ExcludeNewerPackageEntry, ExcludeNewerTimestamp, ForkStrategy, PrereleaseMode, + ResolutionMode, +}; use uv_static::EnvVars; use uv_torch::TorchMode; use uv_workspace::pyproject_mut::AddBoundsKind; @@ -2644,7 +2647,16 @@ pub struct VenvArgs { /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same /// format (e.g., `2006-12-02`) in your system's configured time zone. #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER)] - pub exclude_newer: Option, + pub exclude_newer: Option, + + /// Limit candidate packages for a specific package to those that were uploaded prior to the given date. + /// + /// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp + /// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone. + /// + /// Can be provided multiple times for different packages. + #[arg(long)] + pub exclude_newer_package: Option>, /// The method to use when installing packages from the global cache. /// @@ -4626,7 +4638,16 @@ pub struct ToolUpgradeArgs { /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same /// format (e.g., `2006-12-02`) in your system's configured time zone. #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")] - pub exclude_newer: Option, + pub exclude_newer: Option, + + /// Limit candidate packages for specific packages to those that were uploaded prior to the given date. + /// + /// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp + /// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone. + /// + /// Can be provided multiple times for different packages. + #[arg(long, help_heading = "Resolver options")] + pub exclude_newer_package: Option>, /// The method to use when installing packages from the global cache. /// @@ -5367,7 +5388,16 @@ pub struct InstallerArgs { /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same /// format (e.g., `2006-12-02`) in your system's configured time zone. #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")] - pub exclude_newer: Option, + pub exclude_newer: Option, + + /// Limit candidate packages for specific packages to those that were uploaded prior to the given date. + /// + /// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp + /// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone. + /// + /// Can be provided multiple times for different packages. + #[arg(long, help_heading = "Resolver options")] + pub exclude_newer_package: Option>, /// The method to use when installing packages from the global cache. /// @@ -5560,7 +5590,16 @@ pub struct ResolverArgs { /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same /// format (e.g., `2006-12-02`) in your system's configured time zone. #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")] - pub exclude_newer: Option, + pub exclude_newer: Option, + + /// Limit candidate packages for a specific package to those that were uploaded prior to the given date. + /// + /// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp + /// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone. + /// + /// Can be provided multiple times for different packages. + #[arg(long, help_heading = "Resolver options")] + pub exclude_newer_package: Option>, /// The method to use when installing packages from the global cache. /// @@ -5749,7 +5788,16 @@ pub struct ResolverInstallerArgs { /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same /// format (e.g., `2006-12-02`) in your system's configured time zone. #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")] - pub exclude_newer: Option, + pub exclude_newer: Option, + + /// Limit candidate packages for specific packages to those that were uploaded prior to the given date. + /// + /// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp + /// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone. + /// + /// Can be provided multiple times for different packages. + #[arg(long, help_heading = "Resolver options")] + pub exclude_newer_package: Option>, /// The method to use when installing packages from the global cache. /// @@ -5838,7 +5886,7 @@ pub struct FetchArgs { /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same /// format (e.g., `2006-12-02`) in your system's configured time zone. #[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")] - pub exclude_newer: Option, + pub exclude_newer: Option, } #[derive(Args)] diff --git a/crates/uv-cli/src/options.rs b/crates/uv-cli/src/options.rs index f522022a16ca9..dfd0a82ad69a2 100644 --- a/crates/uv-cli/src/options.rs +++ b/crates/uv-cli/src/options.rs @@ -2,7 +2,7 @@ use anstream::eprintln; use uv_cache::Refresh; use uv_configuration::ConfigSettings; -use uv_resolver::PrereleaseMode; +use uv_resolver::{ExcludeNewer, PrereleaseMode}; use uv_settings::{Combine, PipOptions, ResolverInstallerOptions, ResolverOptions}; use uv_warnings::owo_colors::OwoColorize; @@ -68,6 +68,7 @@ impl From for PipOptions { exclude_newer, link_mode, no_sources, + exclude_newer_package, } = args; Self { @@ -87,6 +88,12 @@ impl From for PipOptions { no_build_isolation: flag(no_build_isolation, build_isolation, "build-isolation"), no_build_isolation_package: Some(no_build_isolation_package), exclude_newer, + exclude_newer_package: exclude_newer_package.map(|entries| { + entries + .into_iter() + .map(|e| (e.package, e.timestamp)) + .collect() + }), link_mode, no_sources: if no_sources { Some(true) } else { None }, ..PipOptions::from(index_args) @@ -111,6 +118,7 @@ impl From for PipOptions { compile_bytecode, no_compile_bytecode, no_sources, + exclude_newer_package: _, } = args; Self { @@ -155,6 +163,7 @@ impl From for PipOptions { compile_bytecode, no_compile_bytecode, no_sources, + exclude_newer_package, } = args; Self { @@ -176,6 +185,12 @@ impl From for PipOptions { no_build_isolation: flag(no_build_isolation, build_isolation, "build-isolation"), no_build_isolation_package: Some(no_build_isolation_package), exclude_newer, + exclude_newer_package: exclude_newer_package.map(|entries| { + entries + .into_iter() + .map(|e| (e.package, e.timestamp)) + .collect() + }), link_mode, compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"), no_sources: if no_sources { Some(true) } else { None }, @@ -266,6 +281,7 @@ pub fn resolver_options( exclude_newer, link_mode, no_sources, + exclude_newer_package, } = resolver_args; let BuildOptionsArgs { @@ -323,7 +339,10 @@ pub fn resolver_options( .map(|config_settings| config_settings.into_iter().collect::()), no_build_isolation: flag(no_build_isolation, build_isolation, "build-isolation"), no_build_isolation_package: Some(no_build_isolation_package), - exclude_newer, + exclude_newer: ExcludeNewer::from_args( + exclude_newer, + exclude_newer_package.unwrap_or_default(), + ), link_mode, no_build: flag(no_build, build, "build"), no_build_package: Some(no_build_package), @@ -357,6 +376,7 @@ pub fn resolver_installer_options( no_build_isolation_package, build_isolation, exclude_newer, + exclude_newer_package, link_mode, compile_bytecode, no_compile_bytecode, @@ -435,6 +455,12 @@ pub fn resolver_installer_options( Some(no_build_isolation_package) }, exclude_newer, + exclude_newer_package: exclude_newer_package.map(|entries| { + entries + .into_iter() + .map(|e| (e.package, e.timestamp)) + .collect() + }), link_mode, compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"), no_build: flag(no_build, build, "build"), diff --git a/crates/uv-dispatch/src/lib.rs b/crates/uv-dispatch/src/lib.rs index 874e412e5b73e..e24f7b2874981 100644 --- a/crates/uv-dispatch/src/lib.rs +++ b/crates/uv-dispatch/src/lib.rs @@ -92,7 +92,7 @@ pub struct BuildDispatch<'a> { build_options: &'a BuildOptions, config_settings: &'a ConfigSettings, hasher: &'a HashStrategy, - exclude_newer: Option, + exclude_newer: ExcludeNewer, source_build_context: SourceBuildContext, build_extra_env_vars: FxHashMap, sources: SourceStrategy, @@ -117,7 +117,7 @@ impl<'a> BuildDispatch<'a> { link_mode: uv_install_wheel::LinkMode, build_options: &'a BuildOptions, hasher: &'a HashStrategy, - exclude_newer: Option, + exclude_newer: ExcludeNewer, sources: SourceStrategy, workspace_cache: WorkspaceCache, concurrency: Concurrency, @@ -224,7 +224,7 @@ impl BuildContext for BuildDispatch<'_> { let resolver = Resolver::new( Manifest::simple(requirements.to_vec()).with_constraints(self.constraints.clone()), OptionsBuilder::new() - .exclude_newer(self.exclude_newer) + .exclude_newer(self.exclude_newer.clone()) .index_strategy(self.index_strategy) .build_options(self.build_options.clone()) .flexibility(Flexibility::Fixed) diff --git a/crates/uv-resolver/src/exclude_newer.rs b/crates/uv-resolver/src/exclude_newer.rs index 65fa55cfe165c..db363555c66be 100644 --- a/crates/uv-resolver/src/exclude_newer.rs +++ b/crates/uv-resolver/src/exclude_newer.rs @@ -1,30 +1,35 @@ #[cfg(feature = "schemars")] use std::borrow::Cow; -use std::str::FromStr; +use std::{ + ops::{Deref, DerefMut}, + str::FromStr, +}; use jiff::{Timestamp, ToSpan, tz::TimeZone}; +use rustc_hash::FxHashMap; +use uv_normalize::PackageName; /// A timestamp that excludes files newer than it. #[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize)] -pub struct ExcludeNewer(Timestamp); +pub struct ExcludeNewerTimestamp(Timestamp); -impl ExcludeNewer { +impl ExcludeNewerTimestamp { /// Returns the timestamp in milliseconds. pub fn timestamp_millis(&self) -> i64 { self.0.as_millisecond() } } -impl From for ExcludeNewer { +impl From for ExcludeNewerTimestamp { fn from(timestamp: Timestamp) -> Self { Self(timestamp) } } -impl FromStr for ExcludeNewer { +impl FromStr for ExcludeNewerTimestamp { type Err = String; - /// Parse an [`ExcludeNewer`] from a string. + /// Parse an [`ExcludeNewerTimestamp`] from a string. /// /// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same /// format (e.g., `2006-12-02`). @@ -61,16 +66,179 @@ impl FromStr for ExcludeNewer { } } -impl std::fmt::Display for ExcludeNewer { +impl std::fmt::Display for ExcludeNewerTimestamp { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } +/// A package-specific exclude-newer entry. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ExcludeNewerPackageEntry { + pub package: PackageName, + pub timestamp: ExcludeNewerTimestamp, +} + +impl FromStr for ExcludeNewerPackageEntry { + type Err = String; + + /// Parses a [`ExcludeNewerPackageEntry`] from a string in the format `PACKAGE=DATE`. + fn from_str(s: &str) -> Result { + let Some((package, date)) = s.split_once('=') else { + return Err(format!( + "Invalid `exclude-newer-package` value `{s}`: expected format `PACKAGE=DATE`" + )); + }; + + let package = PackageName::from_str(package).map_err(|err| { + format!("Invalid `exclude-newer-package` package name `{package}`: {err}") + })?; + let timestamp = ExcludeNewerTimestamp::from_str(date) + .map_err(|err| format!("Invalid `exclude-newer-package` timestamp `{date}`: {err}"))?; + + Ok(Self { package, timestamp }) + } +} + +impl From<(PackageName, ExcludeNewerTimestamp)> for ExcludeNewerPackageEntry { + fn from((package, timestamp): (PackageName, ExcludeNewerTimestamp)) -> Self { + Self { package, timestamp } + } +} + +#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct ExcludeNewerPackage(FxHashMap); + +impl Deref for ExcludeNewerPackage { + type Target = FxHashMap; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for ExcludeNewerPackage { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +impl FromIterator for ExcludeNewerPackage { + fn from_iter>(iter: T) -> Self { + Self( + iter.into_iter() + .map(|entry| (entry.package, entry.timestamp)) + .collect(), + ) + } +} + +impl IntoIterator for ExcludeNewerPackage { + type Item = (PackageName, ExcludeNewerTimestamp); + type IntoIter = std::collections::hash_map::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.0.into_iter() + } +} + +impl<'a> IntoIterator for &'a ExcludeNewerPackage { + type Item = (&'a PackageName, &'a ExcludeNewerTimestamp); + type IntoIter = std::collections::hash_map::Iter<'a, PackageName, ExcludeNewerTimestamp>; + + fn into_iter(self) -> Self::IntoIter { + self.0.iter() + } +} + +impl ExcludeNewerPackage { + /// Convert to the inner `HashMap`. + pub fn into_inner(self) -> FxHashMap { + self.0 + } +} + +/// A setting that excludes files newer than a timestamp, at a global level or per-package. +#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, Default)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +pub struct ExcludeNewer { + /// Global timestamp that applies to all packages if no package-specific timestamp is set. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub global: Option, + /// Per-package timestamps that override the global timestamp. + #[serde(default, skip_serializing_if = "FxHashMap::is_empty")] + pub package: ExcludeNewerPackage, +} + +impl ExcludeNewer { + /// Create a new exclude newer configuration with just a global timestamp. + pub fn global(global: ExcludeNewerTimestamp) -> Self { + Self { + global: Some(global), + package: ExcludeNewerPackage::default(), + } + } + + /// Create a new exclude newer configuration. + pub fn new(global: Option, package: ExcludeNewerPackage) -> Self { + Self { global, package } + } + + /// Create from CLI arguments. + pub fn from_args( + global: Option, + package: Vec, + ) -> Self { + let package: ExcludeNewerPackage = package.into_iter().collect(); + + Self { global, package } + } + + /// Returns the timestamp for a specific package, falling back to the global timestamp if set. + pub fn exclude_newer_package( + &self, + package_name: &PackageName, + ) -> Option { + self.package.get(package_name).copied().or(self.global) + } + + /// Returns the timestamp in milliseconds for a specific package. + pub fn timestamp_millis(&self, package_name: &PackageName) -> Option { + self.exclude_newer_package(package_name) + .map(|ts| ts.timestamp_millis()) + } + + /// Returns true if this has any configuration (global or per-package). + pub fn is_empty(&self) -> bool { + self.global.is_none() && self.package.is_empty() + } +} + +impl std::fmt::Display for ExcludeNewer { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if let Some(global) = self.global { + write!(f, "global: {global}")?; + if !self.package.is_empty() { + write!(f, ", ")?; + } + } + let mut first = true; + for (name, timestamp) in &self.package { + if !first { + write!(f, ", ")?; + } + write!(f, "{name}: {timestamp}")?; + first = false; + } + Ok(()) + } +} + #[cfg(feature = "schemars")] -impl schemars::JsonSchema for ExcludeNewer { +impl schemars::JsonSchema for ExcludeNewerTimestamp { fn schema_name() -> Cow<'static, str> { - Cow::Borrowed("ExcludeNewer") + Cow::Borrowed("ExcludeNewerTimestamp") } fn json_schema(_generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema { diff --git a/crates/uv-resolver/src/lib.rs b/crates/uv-resolver/src/lib.rs index e91df3a7e2242..db0435d6ceba6 100644 --- a/crates/uv-resolver/src/lib.rs +++ b/crates/uv-resolver/src/lib.rs @@ -1,6 +1,6 @@ pub use dependency_mode::DependencyMode; pub use error::{ErrorTree, NoSolutionError, NoSolutionHeader, ResolveError, SentinelRange}; -pub use exclude_newer::ExcludeNewer; +pub use exclude_newer::{ExcludeNewer, ExcludeNewerPackageEntry, ExcludeNewerTimestamp}; pub use exclusions::Exclusions; pub use flat_index::{FlatDistributions, FlatIndex}; pub use fork_strategy::ForkStrategy; diff --git a/crates/uv-resolver/src/lock/mod.rs b/crates/uv-resolver/src/lock/mod.rs index beeadc9121d25..f130c6fef8bbd 100644 --- a/crates/uv-resolver/src/lock/mod.rs +++ b/crates/uv-resolver/src/lock/mod.rs @@ -60,7 +60,8 @@ pub use crate::lock::tree::TreeDisplay; use crate::resolution::{AnnotatedDist, ResolutionGraphNode}; use crate::universal_marker::{ConflictMarker, UniversalMarker}; use crate::{ - ExcludeNewer, InMemoryIndex, MetadataResponse, PrereleaseMode, ResolutionMode, ResolverOutput, + ExcludeNewer, ExcludeNewerTimestamp, InMemoryIndex, MetadataResponse, PrereleaseMode, + ResolutionMode, ResolverOutput, }; mod export; @@ -278,11 +279,23 @@ impl Lock { } let packages = packages.into_values().collect(); + let (exclude_newer, exclude_newer_package) = { + let exclude_newer = &resolution.options.exclude_newer; + let global_exclude_newer = exclude_newer.global; + let package_exclude_newer = if exclude_newer.package.is_empty() { + None + } else { + Some(exclude_newer.package.clone().into_inner()) + }; + (global_exclude_newer, package_exclude_newer) + }; + let options = ResolverOptions { resolution_mode: resolution.options.resolution_mode, prerelease_mode: resolution.options.prerelease_mode, fork_strategy: resolution.options.fork_strategy, - exclude_newer: resolution.options.exclude_newer, + exclude_newer, + exclude_newer_package, }; let lock = Self::new( VERSION, @@ -643,8 +656,8 @@ impl Lock { } /// Returns the exclude newer setting used to generate this lock. - pub fn exclude_newer(&self) -> Option { - self.options.exclude_newer + pub fn exclude_newer(&self) -> ExcludeNewer { + self.options.exclude_newer() } /// Returns the conflicting groups that were used to generate this lock. @@ -890,8 +903,21 @@ impl Lock { value(self.options.fork_strategy.to_string()), ); } - if let Some(exclude_newer) = self.options.exclude_newer { - options_table.insert("exclude-newer", value(exclude_newer.to_string())); + let exclude_newer = &self.options.exclude_newer(); + if !exclude_newer.is_empty() { + // Always serialize global exclude-newer as a string + if let Some(global) = exclude_newer.global { + options_table.insert("exclude-newer", value(global.to_string())); + } + + // Serialize package-specific exclusions as a separate field + if !exclude_newer.package.is_empty() { + let mut package_table = toml_edit::Table::new(); + for (name, timestamp) in &exclude_newer.package { + package_table.insert(name.as_ref(), value(timestamp.to_string())); + } + options_table.insert("exclude-newer-package", Item::Table(package_table)); + } } if !options_table.is_empty() { @@ -1840,8 +1866,25 @@ struct ResolverOptions { /// The [`ForkStrategy`] used to generate this lock. #[serde(default)] fork_strategy: ForkStrategy, - /// The [`ExcludeNewer`] used to generate this lock. - exclude_newer: Option, + /// The global [`ExcludeNewer`] timestamp. + exclude_newer: Option, + /// Package-specific [`ExcludeNewer`] timestamps. + exclude_newer_package: Option>, +} + +impl ResolverOptions { + /// Get the combined exclude-newer configuration. + fn exclude_newer(&self) -> ExcludeNewer { + ExcludeNewer::from_args( + self.exclude_newer, + self.exclude_newer_package + .clone() + .unwrap_or_default() + .into_iter() + .map(Into::into) + .collect(), + ) + } } #[derive(Clone, Debug, Default, serde::Deserialize, PartialEq, Eq)] diff --git a/crates/uv-resolver/src/options.rs b/crates/uv-resolver/src/options.rs index 176b32910a48a..f7baa4ef2f9f6 100644 --- a/crates/uv-resolver/src/options.rs +++ b/crates/uv-resolver/src/options.rs @@ -12,7 +12,7 @@ pub struct Options { pub prerelease_mode: PrereleaseMode, pub dependency_mode: DependencyMode, pub fork_strategy: ForkStrategy, - pub exclude_newer: Option, + pub exclude_newer: ExcludeNewer, pub index_strategy: IndexStrategy, pub required_environments: SupportedEnvironments, pub flexibility: Flexibility, @@ -27,7 +27,7 @@ pub struct OptionsBuilder { prerelease_mode: PrereleaseMode, dependency_mode: DependencyMode, fork_strategy: ForkStrategy, - exclude_newer: Option, + exclude_newer: ExcludeNewer, index_strategy: IndexStrategy, required_environments: SupportedEnvironments, flexibility: Flexibility, @@ -71,7 +71,7 @@ impl OptionsBuilder { /// Sets the exclusion date. #[must_use] - pub fn exclude_newer(mut self, exclude_newer: Option) -> Self { + pub fn exclude_newer(mut self, exclude_newer: ExcludeNewer) -> Self { self.exclude_newer = exclude_newer; self } diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index ed1cd48afc2b5..ea8a8095c1166 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -182,7 +182,7 @@ impl<'a, Context: BuildContext, InstalledPackages: InstalledPackagesProvider> python_requirement.target(), AllowedYanks::from_manifest(&manifest, &env, options.dependency_mode), hasher, - options.exclude_newer, + options.exclude_newer.clone(), build_context.build_options(), build_context.capabilities(), ); @@ -366,7 +366,7 @@ impl ResolverState ResolverState, + exclude_newer: Option<&ExcludeNewer>, visited: &FxHashSet, ) -> ResolveError { err = NoSolutionError::collapse_local_version_segments(NoSolutionError::collapse_proxies( @@ -2583,7 +2583,8 @@ impl ResolverState= exclude_newer.timestamp_millis() + upload_time + >= exclude_newer.timestamp_millis(name).unwrap_or(0) }) }) { continue; diff --git a/crates/uv-resolver/src/resolver/provider.rs b/crates/uv-resolver/src/resolver/provider.rs index d6384e3e29117..18a9016043321 100644 --- a/crates/uv-resolver/src/resolver/provider.rs +++ b/crates/uv-resolver/src/resolver/provider.rs @@ -116,7 +116,7 @@ pub struct DefaultResolverProvider<'a, Context: BuildContext> { requires_python: RequiresPython, allowed_yanks: AllowedYanks, hasher: HashStrategy, - exclude_newer: Option, + exclude_newer: ExcludeNewer, build_options: &'a BuildOptions, capabilities: &'a IndexCapabilities, } @@ -130,7 +130,7 @@ impl<'a, Context: BuildContext> DefaultResolverProvider<'a, Context> { requires_python: &'a RequiresPython, allowed_yanks: AllowedYanks, hasher: &'a HashStrategy, - exclude_newer: Option, + exclude_newer: ExcludeNewer, build_options: &'a BuildOptions, capabilities: &'a IndexCapabilities, ) -> Self { @@ -184,7 +184,7 @@ impl ResolverProvider for DefaultResolverProvider<'_, Con &self.requires_python, &self.allowed_yanks, &self.hasher, - self.exclude_newer.as_ref(), + Some(&self.exclude_newer), flat_index .and_then(|flat_index| flat_index.get(package_name)) .cloned(), diff --git a/crates/uv-resolver/src/version_map.rs b/crates/uv-resolver/src/version_map.rs index 63132ad0d7490..4b0e07ad89000 100644 --- a/crates/uv-resolver/src/version_map.rs +++ b/crates/uv-resolver/src/version_map.rs @@ -22,7 +22,7 @@ use uv_types::HashStrategy; use uv_warnings::warn_user_once; use crate::flat_index::FlatDistributions; -use crate::{ExcludeNewer, yanks::AllowedYanks}; +use crate::{ExcludeNewer, ExcludeNewerTimestamp, yanks::AllowedYanks}; /// A map from versions to distributions. #[derive(Debug)] @@ -112,7 +112,7 @@ impl VersionMap { allowed_yanks: allowed_yanks.clone(), hasher: hasher.clone(), requires_python: requires_python.clone(), - exclude_newer: exclude_newer.copied(), + exclude_newer: exclude_newer.and_then(|en| en.exclude_newer_package(package_name)), }), } } @@ -365,7 +365,7 @@ struct VersionMapLazy { /// in the current environment. tags: Option, /// Whether files newer than this timestamp should be excluded or not. - exclude_newer: Option, + exclude_newer: Option, /// Which yanked versions are allowed allowed_yanks: AllowedYanks, /// The hashes of allowed distributions. @@ -420,7 +420,7 @@ impl VersionMapLazy { for (filename, file) in files.all() { // Support resolving as if it were an earlier timestamp, at least as long files have // upload time information. - let (excluded, upload_time) = if let Some(exclude_newer) = self.exclude_newer { + let (excluded, upload_time) = if let Some(exclude_newer) = &self.exclude_newer { match file.upload_time_utc_ms.as_ref() { Some(&upload_time) if upload_time >= exclude_newer.timestamp_millis() => { (true, Some(upload_time)) diff --git a/crates/uv-settings/Cargo.toml b/crates/uv-settings/Cargo.toml index 1cc376eea6eef..a12015c120a7f 100644 --- a/crates/uv-settings/Cargo.toml +++ b/crates/uv-settings/Cargo.toml @@ -37,6 +37,7 @@ uv-workspace = { workspace = true, features = ["schemars", "clap"] } clap = { workspace = true } fs-err = { workspace = true } +rustc-hash = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true } textwrap = { workspace = true } diff --git a/crates/uv-settings/src/combine.rs b/crates/uv-settings/src/combine.rs index 8edbd2a05f6e8..2f9e3fc70d73c 100644 --- a/crates/uv-settings/src/combine.rs +++ b/crates/uv-settings/src/combine.rs @@ -1,7 +1,9 @@ use std::num::NonZeroUsize; use std::path::PathBuf; +use rustc_hash::FxHashMap; use url::Url; +use uv_normalize::PackageName; use uv_configuration::{ ConfigSettings, ExportFormat, IndexStrategy, KeyringProviderType, RequiredVersion, @@ -12,7 +14,10 @@ use uv_install_wheel::LinkMode; use uv_pypi_types::{SchemaConflicts, SupportedEnvironments}; use uv_python::{PythonDownloads, PythonPreference, PythonVersion}; use uv_redacted::DisplaySafeUrl; -use uv_resolver::{AnnotationStyle, ExcludeNewer, ForkStrategy, PrereleaseMode, ResolutionMode}; +use uv_resolver::{ + AnnotationStyle, ExcludeNewer, ExcludeNewerTimestamp, ForkStrategy, PrereleaseMode, + ResolutionMode, +}; use uv_torch::TorchMode; use uv_workspace::pyproject_mut::AddBoundsKind; @@ -78,6 +83,7 @@ macro_rules! impl_combine_or { impl_combine_or!(AddBoundsKind); impl_combine_or!(AnnotationStyle); impl_combine_or!(ExcludeNewer); +impl_combine_or!(ExcludeNewerTimestamp); impl_combine_or!(ExportFormat); impl_combine_or!(ForkStrategy); impl_combine_or!(Index); @@ -120,6 +126,25 @@ impl Combine for Option> { } } +impl Combine for Option> { + /// Combine two hashmaps by merging them, with the values in `self` taking precedence. + fn combine( + self, + other: Option>, + ) -> Option> { + match (self, other) { + (Some(mut a), Some(b)) => { + // Extend with values from b, but a takes precedence (we don't overwrite existing keys) + for (key, value) in b { + a.entry(key).or_insert(value); + } + Some(a) + } + (a, b) => a.or(b), + } + } +} + impl Combine for Option { /// Combine two maps by merging the map in `self` with the map in `other`, if they're both /// `Some`. @@ -142,3 +167,22 @@ impl Combine for Option { self } } + +impl Combine for ExcludeNewer { + fn combine(mut self, other: Self) -> Self { + self.global = self.global.combine(other.global); + + if !other.package.is_empty() { + if self.package.is_empty() { + self.package = other.package; + } else { + // Merge package-specific timestamps, with self taking precedence + for (pkg, timestamp) in &other.package { + self.package.entry(pkg.clone()).or_insert(*timestamp); + } + } + } + + self + } +} diff --git a/crates/uv-settings/src/settings.rs b/crates/uv-settings/src/settings.rs index d80ccce2f77a2..082848d8bde0a 100644 --- a/crates/uv-settings/src/settings.rs +++ b/crates/uv-settings/src/settings.rs @@ -1,5 +1,6 @@ use std::{fmt::Debug, num::NonZeroUsize, path::Path, path::PathBuf}; +use rustc_hash::FxHashMap; use serde::{Deserialize, Serialize}; use uv_cache_info::CacheKey; @@ -12,12 +13,16 @@ use uv_distribution_types::{ }; use uv_install_wheel::LinkMode; use uv_macros::{CombineOptions, OptionsMetadata}; + use uv_normalize::{ExtraName, PackageName, PipGroupName}; use uv_pep508::Requirement; use uv_pypi_types::{SupportedEnvironments, VerbatimParsedUrl}; use uv_python::{PythonDownloads, PythonPreference, PythonVersion}; use uv_redacted::DisplaySafeUrl; -use uv_resolver::{AnnotationStyle, ExcludeNewer, ForkStrategy, PrereleaseMode, ResolutionMode}; +use uv_resolver::{ + AnnotationStyle, ExcludeNewer, ExcludeNewerTimestamp, ForkStrategy, PrereleaseMode, + ResolutionMode, +}; use uv_static::EnvVars; use uv_torch::TorchMode; use uv_workspace::pyproject_mut::AddBoundsKind; @@ -333,7 +338,7 @@ pub struct InstallerOptions { pub index_strategy: Option, pub keyring_provider: Option, pub config_settings: Option, - pub exclude_newer: Option, + pub exclude_newer: Option, pub link_mode: Option, pub compile_bytecode: Option, pub reinstall: Option, @@ -361,7 +366,7 @@ pub struct ResolverOptions { pub fork_strategy: Option, pub dependency_metadata: Option>, pub config_settings: Option, - pub exclude_newer: Option, + pub exclude_newer: ExcludeNewer, pub link_mode: Option, pub upgrade: Option, pub upgrade_package: Option>>, @@ -623,7 +628,18 @@ pub struct ResolverInstallerOptions { exclude-newer = "2006-12-02T02:07:43Z" "# )] - pub exclude_newer: Option, + pub exclude_newer: Option, + /// Limit candidate packages for specific packages to those that were uploaded prior to the given date. + /// + /// Accepts package-date pairs in a dictionary format. + #[option( + default = "None", + value_type = "dict", + example = r#" + exclude-newer-package = { tqdm = "2022-04-04T00:00:00Z" } + "# + )] + pub exclude_newer_package: 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 @@ -1386,7 +1402,18 @@ pub struct PipOptions { exclude-newer = "2006-12-02T02:07:43Z" "# )] - pub exclude_newer: Option, + pub exclude_newer: Option, + /// Limit candidate packages for specific packages to those that were uploaded prior to the given date. + /// + /// Accepts package-date pairs in a dictionary format. + #[option( + default = "None", + value_type = "dict", + example = r#" + exclude-newer-package = { tqdm = "2022-04-04T00:00:00Z" } + "# + )] + pub exclude_newer_package: Option>, /// Specify a package to omit from the output resolution. Its dependencies will still be /// included in the resolution. Equivalent to pip-compile's `--unsafe-package` option. #[option( @@ -1651,7 +1678,15 @@ impl From for ResolverOptions { fork_strategy: value.fork_strategy, dependency_metadata: value.dependency_metadata, config_settings: value.config_settings, - exclude_newer: value.exclude_newer, + exclude_newer: ExcludeNewer::from_args( + value.exclude_newer, + value + .exclude_newer_package + .unwrap_or_default() + .into_iter() + .map(Into::into) + .collect(), + ), link_mode: value.link_mode, upgrade: value.upgrade, upgrade_package: value.upgrade_package, @@ -1677,7 +1712,16 @@ impl From for InstallerOptions { index_strategy: value.index_strategy, keyring_provider: value.keyring_provider, config_settings: value.config_settings, - exclude_newer: value.exclude_newer, + exclude_newer: ExcludeNewer::from_args( + value.exclude_newer, + value + .exclude_newer_package + .unwrap_or_default() + .into_iter() + .map(Into::into) + .collect(), + ) + .global, link_mode: value.link_mode, compile_bytecode: value.compile_bytecode, reinstall: value.reinstall, @@ -1716,7 +1760,8 @@ pub struct ToolOptions { pub config_settings: Option, pub no_build_isolation: Option, pub no_build_isolation_package: Option>, - pub exclude_newer: Option, + pub exclude_newer: Option, + pub exclude_newer_package: Option>, pub link_mode: Option, pub compile_bytecode: Option, pub no_sources: Option, @@ -1744,6 +1789,7 @@ impl From for ToolOptions { no_build_isolation: value.no_build_isolation, no_build_isolation_package: value.no_build_isolation_package, exclude_newer: value.exclude_newer, + exclude_newer_package: value.exclude_newer_package, link_mode: value.link_mode, compile_bytecode: value.compile_bytecode, no_sources: value.no_sources, @@ -1773,6 +1819,7 @@ impl From for ResolverInstallerOptions { no_build_isolation: value.no_build_isolation, no_build_isolation_package: value.no_build_isolation_package, exclude_newer: value.exclude_newer, + exclude_newer_package: value.exclude_newer_package, link_mode: value.link_mode, compile_bytecode: value.compile_bytecode, no_sources: value.no_sources, @@ -1824,7 +1871,8 @@ pub struct OptionsWire { config_settings: Option, no_build_isolation: Option, no_build_isolation_package: Option>, - exclude_newer: Option, + exclude_newer: Option, + exclude_newer_package: Option>, link_mode: Option, compile_bytecode: Option, no_sources: Option, @@ -1914,6 +1962,7 @@ impl From for Options { no_build_isolation, no_build_isolation_package, exclude_newer, + exclude_newer_package, link_mode, compile_bytecode, no_sources, @@ -1980,6 +2029,7 @@ impl From for Options { no_build_isolation, no_build_isolation_package, exclude_newer, + exclude_newer_package, link_mode, compile_bytecode, no_sources, diff --git a/crates/uv/src/commands/build_frontend.rs b/crates/uv/src/commands/build_frontend.rs index 2cef9a4062a7c..147056e5c968d 100644 --- a/crates/uv/src/commands/build_frontend.rs +++ b/crates/uv/src/commands/build_frontend.rs @@ -346,7 +346,7 @@ async fn build_impl( no_build_isolation_package, *index_strategy, *keyring_provider, - *exclude_newer, + exclude_newer.clone(), *sources, concurrency, build_options, @@ -423,7 +423,7 @@ async fn build_package( no_build_isolation_package: &[PackageName], index_strategy: IndexStrategy, keyring_provider: KeyringProviderType, - exclude_newer: Option, + exclude_newer: ExcludeNewer, sources: SourceStrategy, concurrency: Concurrency, build_options: &BuildOptions, diff --git a/crates/uv/src/commands/pip/compile.rs b/crates/uv/src/commands/pip/compile.rs index a1846d4186e4b..712426452cabf 100644 --- a/crates/uv/src/commands/pip/compile.rs +++ b/crates/uv/src/commands/pip/compile.rs @@ -96,7 +96,7 @@ pub(crate) async fn pip_compile( mut python_version: Option, python_platform: Option, universal: bool, - exclude_newer: Option, + exclude_newer: ExcludeNewer, sources: SourceStrategy, annotation_style: AnnotationStyle, link_mode: LinkMode, @@ -480,7 +480,7 @@ pub(crate) async fn pip_compile( link_mode, &build_options, &build_hashes, - exclude_newer, + exclude_newer.clone(), sources, WorkspaceCache::default(), concurrency, @@ -492,7 +492,7 @@ pub(crate) async fn pip_compile( .prerelease_mode(prerelease_mode) .fork_strategy(fork_strategy) .dependency_mode(dependency_mode) - .exclude_newer(exclude_newer) + .exclude_newer(exclude_newer.clone()) .index_strategy(index_strategy) .torch_backend(torch_backend) .build_options(build_options.clone()) diff --git a/crates/uv/src/commands/pip/install.rs b/crates/uv/src/commands/pip/install.rs index aa6e6a6c97ccd..89fa0259fea9e 100644 --- a/crates/uv/src/commands/pip/install.rs +++ b/crates/uv/src/commands/pip/install.rs @@ -82,7 +82,7 @@ pub(crate) async fn pip_install( python_version: Option, python_platform: Option, strict: bool, - exclude_newer: Option, + exclude_newer: ExcludeNewer, sources: SourceStrategy, python: Option, system: bool, @@ -425,7 +425,7 @@ pub(crate) async fn pip_install( link_mode, &build_options, &build_hasher, - exclude_newer, + exclude_newer.clone(), sources, WorkspaceCache::default(), concurrency, diff --git a/crates/uv/src/commands/pip/latest.rs b/crates/uv/src/commands/pip/latest.rs index 25da8466c5f71..24b98ed828b7e 100644 --- a/crates/uv/src/commands/pip/latest.rs +++ b/crates/uv/src/commands/pip/latest.rs @@ -13,12 +13,12 @@ use uv_warnings::warn_user_once; /// /// The returned distribution is guaranteed to be compatible with the provided tags and Python /// requirement. -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone)] pub(crate) struct LatestClient<'env> { pub(crate) client: &'env RegistryClient, pub(crate) capabilities: &'env IndexCapabilities, pub(crate) prerelease: PrereleaseMode, - pub(crate) exclude_newer: Option, + pub(crate) exclude_newer: ExcludeNewer, pub(crate) tags: Option<&'env Tags>, pub(crate) requires_python: &'env RequiresPython, } @@ -70,17 +70,22 @@ impl LatestClient<'_> { for (filename, file) in files.all() { // Skip distributions uploaded after the cutoff. - if let Some(exclude_newer) = self.exclude_newer { + if !self.exclude_newer.is_empty() { match file.upload_time_utc_ms.as_ref() { Some(&upload_time) - if upload_time >= exclude_newer.timestamp_millis() => + if upload_time + >= self + .exclude_newer + .timestamp_millis(package) + .unwrap_or(0) => { continue; } None => { warn_user_once!( - "{} is missing an upload date, but user provided: {exclude_newer}", + "{} is missing an upload date, but user provided: {}", file.filename, + self.exclude_newer ); } _ => {} diff --git a/crates/uv/src/commands/pip/list.rs b/crates/uv/src/commands/pip/list.rs index 356574436e38a..6f7cdc1bc8b78 100644 --- a/crates/uv/src/commands/pip/list.rs +++ b/crates/uv/src/commands/pip/list.rs @@ -49,7 +49,7 @@ pub(crate) async fn pip_list( network_settings: &NetworkSettings, concurrency: Concurrency, strict: bool, - exclude_newer: Option, + exclude_newer: ExcludeNewer, python: Option<&str>, system: bool, cache: &Cache, diff --git a/crates/uv/src/commands/pip/sync.rs b/crates/uv/src/commands/pip/sync.rs index 8f26aaea2504b..d7ff1e34163f6 100644 --- a/crates/uv/src/commands/pip/sync.rs +++ b/crates/uv/src/commands/pip/sync.rs @@ -66,7 +66,7 @@ pub(crate) async fn pip_sync( python_version: Option, python_platform: Option, strict: bool, - exclude_newer: Option, + exclude_newer: ExcludeNewer, python: Option, system: bool, break_system_packages: bool, @@ -358,7 +358,7 @@ pub(crate) async fn pip_sync( link_mode, &build_options, &build_hasher, - exclude_newer, + exclude_newer.clone(), sources, WorkspaceCache::default(), concurrency, diff --git a/crates/uv/src/commands/pip/tree.rs b/crates/uv/src/commands/pip/tree.rs index b0ba44c350dee..bd7c61fb6ecfd 100644 --- a/crates/uv/src/commands/pip/tree.rs +++ b/crates/uv/src/commands/pip/tree.rs @@ -47,7 +47,7 @@ pub(crate) async fn pip_tree( network_settings: NetworkSettings, concurrency: Concurrency, strict: bool, - exclude_newer: Option, + exclude_newer: ExcludeNewer, python: Option<&str>, system: bool, cache: &Cache, diff --git a/crates/uv/src/commands/project/add.rs b/crates/uv/src/commands/project/add.rs index 04fd7d8222ef3..336df29174998 100644 --- a/crates/uv/src/commands/project/add.rs +++ b/crates/uv/src/commands/project/add.rs @@ -437,7 +437,7 @@ pub(crate) async fn add( settings.resolver.link_mode, &settings.resolver.build_options, &build_hasher, - settings.resolver.exclude_newer, + settings.resolver.exclude_newer.clone(), sources, // No workspace caching since `uv add` changes the workspace definition. WorkspaceCache::default(), diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index cd42428336e78..6bd9161cd4e27 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -630,7 +630,7 @@ async fn do_lock( .resolution_mode(*resolution) .prerelease_mode(*prerelease) .fork_strategy(*fork_strategy) - .exclude_newer(*exclude_newer) + .exclude_newer(exclude_newer.clone()) .index_strategy(*index_strategy) .build_options(build_options.clone()) .required_environments(required_environments.cloned().unwrap_or_default()) @@ -668,7 +668,7 @@ async fn do_lock( *link_mode, build_options, &build_hasher, - *exclude_newer, + exclude_newer.clone(), *sources, workspace_cache.clone(), concurrency, @@ -944,31 +944,37 @@ impl ValidatedLock { ); return Ok(Self::Unusable(lock)); } - match (lock.exclude_newer(), options.exclude_newer) { - (None, None) => (), - (Some(existing), Some(provided)) if existing == provided => (), - (Some(existing), Some(provided)) => { + let lock_exclude_newer = lock.exclude_newer(); + let options_exclude_newer = &options.exclude_newer; + + match ( + lock_exclude_newer.is_empty(), + options_exclude_newer.is_empty(), + ) { + (true, true) => (), + (false, false) if lock_exclude_newer == *options_exclude_newer => (), + (false, false) => { let _ = writeln!( printer.stderr(), "Ignoring existing lockfile due to change in timestamp cutoff: `{}` vs. `{}`", - existing.cyan(), - provided.cyan() + lock_exclude_newer.cyan(), + options_exclude_newer.cyan() ); return Ok(Self::Unusable(lock)); } - (Some(existing), None) => { + (false, true) => { let _ = writeln!( printer.stderr(), "Ignoring existing lockfile due to removal of timestamp cutoff: `{}`", - existing.cyan(), + lock_exclude_newer.cyan(), ); return Ok(Self::Unusable(lock)); } - (None, Some(provided)) => { + (true, false) => { let _ = writeln!( printer.stderr(), "Ignoring existing lockfile due to addition of timestamp cutoff: `{}`", - provided.cyan() + options_exclude_newer.cyan() ); return Ok(Self::Unusable(lock)); } diff --git a/crates/uv/src/commands/project/mod.rs b/crates/uv/src/commands/project/mod.rs index c327e8a44658e..22ba239383dd1 100644 --- a/crates/uv/src/commands/project/mod.rs +++ b/crates/uv/src/commands/project/mod.rs @@ -1707,7 +1707,7 @@ pub(crate) async fn resolve_names( *link_mode, build_options, &build_hasher, - *exclude_newer, + exclude_newer.clone(), *sources, workspace_cache.clone(), concurrency, @@ -1850,7 +1850,7 @@ pub(crate) async fn resolve_environment( .resolution_mode(*resolution) .prerelease_mode(*prerelease) .fork_strategy(*fork_strategy) - .exclude_newer(*exclude_newer) + .exclude_newer(exclude_newer.clone()) .index_strategy(*index_strategy) .build_options(build_options.clone()) .build(); @@ -1912,7 +1912,7 @@ pub(crate) async fn resolve_environment( *link_mode, build_options, &build_hasher, - *exclude_newer, + exclude_newer.clone(), *sources, workspace_cache, concurrency, @@ -2225,7 +2225,7 @@ pub(crate) async fn update_environment( .resolution_mode(*resolution) .prerelease_mode(*prerelease) .fork_strategy(*fork_strategy) - .exclude_newer(*exclude_newer) + .exclude_newer(exclude_newer.clone()) .index_strategy(*index_strategy) .build_options(build_options.clone()) .build(); @@ -2267,7 +2267,7 @@ pub(crate) async fn update_environment( *link_mode, build_options, &build_hasher, - *exclude_newer, + exclude_newer.clone(), *sources, workspace_cache, concurrency, diff --git a/crates/uv/src/commands/venv.rs b/crates/uv/src/commands/venv.rs index 9334d844dc433..645587a90f240 100644 --- a/crates/uv/src/commands/venv.rs +++ b/crates/uv/src/commands/venv.rs @@ -61,7 +61,7 @@ pub(crate) async fn venv( system_site_packages: bool, seed: bool, allow_existing: bool, - exclude_newer: Option, + exclude_newer: ExcludeNewer, concurrency: Concurrency, no_config: bool, no_project: bool, @@ -144,7 +144,7 @@ async fn venv_impl( python_preference: PythonPreference, python_downloads: PythonDownloads, allow_existing: bool, - exclude_newer: Option, + exclude_newer: ExcludeNewer, concurrency: Concurrency, no_config: bool, no_project: bool, diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 004ce50534bff..0a9dba98f4fcb 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -720,6 +720,7 @@ impl ToolUpgradeSettings { compile_bytecode, no_compile_bytecode, no_sources, + exclude_newer_package: _, build, } = args; @@ -750,6 +751,7 @@ impl ToolUpgradeSettings { no_build_isolation_package, build_isolation, exclude_newer, + exclude_newer_package: None, link_mode, compile_bytecode, no_compile_bytecode, @@ -2624,6 +2626,7 @@ impl VenvSettings { link_mode, refresh, compat_args: _, + exclude_newer_package: _, } = args; Self { @@ -2664,7 +2667,7 @@ pub(crate) struct InstallerSettingsRef<'a> { pub(crate) config_setting: &'a ConfigSettings, pub(crate) no_build_isolation: bool, pub(crate) no_build_isolation_package: &'a [PackageName], - pub(crate) exclude_newer: Option, + pub(crate) exclude_newer: ExcludeNewer, pub(crate) link_mode: LinkMode, pub(crate) compile_bytecode: bool, pub(crate) reinstall: &'a Reinstall, @@ -2681,7 +2684,7 @@ pub(crate) struct ResolverSettings { pub(crate) build_options: BuildOptions, pub(crate) config_setting: ConfigSettings, pub(crate) dependency_metadata: DependencyMetadata, - pub(crate) exclude_newer: Option, + pub(crate) exclude_newer: ExcludeNewer, pub(crate) fork_strategy: ForkStrategy, pub(crate) index_locations: IndexLocations, pub(crate) index_strategy: IndexStrategy, @@ -2820,7 +2823,15 @@ impl From for ResolverInstallerSettings { dependency_metadata: DependencyMetadata::from_entries( value.dependency_metadata.into_iter().flatten(), ), - exclude_newer: value.exclude_newer, + exclude_newer: ExcludeNewer::from_args( + value.exclude_newer, + value + .exclude_newer_package + .unwrap_or_default() + .into_iter() + .map(Into::into) + .collect(), + ), fork_strategy: value.fork_strategy.unwrap_or_default(), index_locations, index_strategy: value.index_strategy.unwrap_or_default(), @@ -2889,7 +2900,7 @@ pub(crate) struct PipSettings { pub(crate) python_version: Option, pub(crate) python_platform: Option, pub(crate) universal: bool, - pub(crate) exclude_newer: Option, + pub(crate) exclude_newer: ExcludeNewer, pub(crate) no_emit_package: Vec, pub(crate) emit_index_url: bool, pub(crate) emit_find_links: bool, @@ -2975,6 +2986,7 @@ impl PipSettings { upgrade_package, reinstall, reinstall_package, + exclude_newer_package, } = pip.unwrap_or_default(); let ResolverInstallerOptions { @@ -3004,6 +3016,7 @@ impl PipSettings { no_build_package: top_level_no_build_package, no_binary: top_level_no_binary, no_binary_package: top_level_no_binary_package, + exclude_newer_package: top_level_exclude_newer_package, } = top_level; // Merge the top-level options (`tool.uv`) with the pip-specific options (`tool.uv.pip`), @@ -3026,6 +3039,9 @@ impl PipSettings { let no_build_isolation_package = no_build_isolation_package.combine(top_level_no_build_isolation_package); let exclude_newer = exclude_newer.combine(top_level_exclude_newer); + let exclude_newer_package = exclude_newer_package + .combine(top_level_exclude_newer_package) + .unwrap_or_default(); let link_mode = link_mode.combine(top_level_link_mode); let compile_bytecode = compile_bytecode.combine(top_level_compile_bytecode); let no_sources = no_sources.combine(top_level_no_sources); @@ -3128,7 +3144,10 @@ impl PipSettings { python_version: args.python_version.combine(python_version), python_platform: args.python_platform.combine(python_platform), universal: args.universal.combine(universal).unwrap_or_default(), - exclude_newer: args.exclude_newer.combine(exclude_newer), + exclude_newer: ExcludeNewer::from_args( + exclude_newer, + exclude_newer_package.into_iter().map(Into::into).collect(), + ), no_emit_package: args .no_emit_package .combine(no_emit_package) @@ -3219,7 +3238,7 @@ impl<'a> From<&'a ResolverInstallerSettings> for InstallerSettingsRef<'a> { config_setting: &settings.resolver.config_setting, no_build_isolation: settings.resolver.no_build_isolation, no_build_isolation_package: &settings.resolver.no_build_isolation_package, - exclude_newer: settings.resolver.exclude_newer, + exclude_newer: settings.resolver.exclude_newer.clone(), link_mode: settings.resolver.link_mode, compile_bytecode: settings.compile_bytecode, reinstall: &settings.reinstall, diff --git a/crates/uv/tests/it/lock.rs b/crates/uv/tests/it/lock.rs index 5851022b831cc..46dc0d965494e 100644 --- a/crates/uv/tests/it/lock.rs +++ b/crates/uv/tests/it/lock.rs @@ -28744,3 +28744,145 @@ fn test_tilde_equals_python_version() -> Result<()> { Ok(()) } + +/// Test that exclude-newer-package is properly serialized in the lockfile. +#[test] +fn lock_exclude_newer_package() -> Result<()> { + let context = TestContext::new("3.12"); + + let pyproject_toml = context.temp_dir.child("pyproject.toml"); + pyproject_toml.write_str( + r#" + [project] + name = "project" + version = "0.1.0" + requires-python = ">=3.12" + dependencies = ["requests", "tqdm"] + "#, + )?; + + // Lock with both global exclude-newer and package-specific overrides + uv_snapshot!(context.filters(), context + .lock() + .env_remove(EnvVars::UV_EXCLUDE_NEWER) + .arg("--exclude-newer") + .arg("2022-04-04T12:00:00Z") + .arg("--exclude-newer-package") + .arg("tqdm=2022-09-04T00:00:00Z"), @r###" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 8 packages in [TIME] + "###); + + let lock = context.read("uv.lock"); + + insta::with_settings!({ + filters => context.filters(), + }, { + assert_snapshot!( + lock, @r#" + version = 1 + revision = 2 + requires-python = ">=3.12" + + [options] + exclude-newer = "2022-04-04T12:00:00Z" + + [options.exclude-newer-package] + tqdm = "2022-09-04T00:00:00Z" + + [[package]] + name = "certifi" + version = "2021.10.8" + source = { registry = "https://pypi.org/simple" } + sdist = { url = "https://files.pythonhosted.org/packages/6c/ae/d26450834f0acc9e3d1f74508da6df1551ceab6c2ce0766a593362d6d57f/certifi-2021.10.8.tar.gz", hash = "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872", size = 151214, upload-time = "2021-10-08T19:32:15.277Z" } + wheels = [ + { url = "https://files.pythonhosted.org/packages/37/45/946c02767aabb873146011e665728b680884cd8fe70dde973c640e45b775/certifi-2021.10.8-py2.py3-none-any.whl", hash = "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569", size = 149195, upload-time = "2021-10-08T19:32:10.712Z" }, + ] + + [[package]] + name = "charset-normalizer" + version = "2.0.12" + source = { registry = "https://pypi.org/simple" } + sdist = { url = "https://files.pythonhosted.org/packages/56/31/7bcaf657fafb3c6db8c787a865434290b726653c912085fbd371e9b92e1c/charset-normalizer-2.0.12.tar.gz", hash = "sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597", size = 79105, upload-time = "2022-02-12T14:33:13.788Z" } + wheels = [ + { url = "https://files.pythonhosted.org/packages/06/b3/24afc8868eba069a7f03650ac750a778862dc34941a4bebeb58706715726/charset_normalizer-2.0.12-py3-none-any.whl", hash = "sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df", size = 39623, upload-time = "2022-02-12T14:33:12.294Z" }, + ] + + [[package]] + name = "colorama" + version = "0.4.4" + source = { registry = "https://pypi.org/simple" } + sdist = { url = "https://files.pythonhosted.org/packages/1f/bb/5d3246097ab77fa083a61bd8d3d527b7ae063c7d8e8671b1cf8c4ec10cbe/colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b", size = 27813, upload-time = "2020-10-15T18:36:33.372Z" } + wheels = [ + { url = "https://files.pythonhosted.org/packages/44/98/5b86278fbbf250d239ae0ecb724f8572af1c91f4a11edf4d36a206189440/colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2", size = 16028, upload-time = "2020-10-13T02:42:26.463Z" }, + ] + + [[package]] + name = "idna" + version = "3.3" + source = { registry = "https://pypi.org/simple" } + sdist = { url = "https://files.pythonhosted.org/packages/62/08/e3fc7c8161090f742f504f40b1bccbfc544d4a4e09eb774bf40aafce5436/idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d", size = 286689, upload-time = "2021-10-12T23:33:41.312Z" } + wheels = [ + { url = "https://files.pythonhosted.org/packages/04/a2/d918dcd22354d8958fe113e1a3630137e0fc8b44859ade3063982eacd2a4/idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff", size = 61160, upload-time = "2021-10-12T23:33:38.02Z" }, + ] + + [[package]] + name = "project" + version = "0.1.0" + source = { virtual = "." } + dependencies = [ + { name = "requests" }, + { name = "tqdm" }, + ] + + [package.metadata] + requires-dist = [ + { name = "requests" }, + { name = "tqdm" }, + ] + + [[package]] + name = "requests" + version = "2.27.1" + source = { registry = "https://pypi.org/simple" } + dependencies = [ + { name = "certifi" }, + { name = "charset-normalizer" }, + { name = "idna" }, + { name = "urllib3" }, + ] + sdist = { url = "https://files.pythonhosted.org/packages/60/f3/26ff3767f099b73e0efa138a9998da67890793bfa475d8278f84a30fec77/requests-2.27.1.tar.gz", hash = "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61", size = 106758, upload-time = "2022-01-05T15:40:51.698Z" } + wheels = [ + { url = "https://files.pythonhosted.org/packages/2d/61/08076519c80041bc0ffa1a8af0cbd3bf3e2b62af10435d269a9d0f40564d/requests-2.27.1-py2.py3-none-any.whl", hash = "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d", size = 63133, upload-time = "2022-01-05T15:40:49.334Z" }, + ] + + [[package]] + name = "tqdm" + version = "4.64.1" + source = { registry = "https://pypi.org/simple" } + dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + ] + sdist = { url = "https://files.pythonhosted.org/packages/c1/c2/d8a40e5363fb01806870e444fc1d066282743292ff32a9da54af51ce36a2/tqdm-4.64.1.tar.gz", hash = "sha256:5f4f682a004951c1b450bc753c710e9280c5746ce6ffedee253ddbcbf54cf1e4", size = 169599, upload-time = "2022-09-03T11:10:30.943Z" } + wheels = [ + { url = "https://files.pythonhosted.org/packages/47/bb/849011636c4da2e44f1253cd927cfb20ada4374d8b3a4e425416e84900cc/tqdm-4.64.1-py2.py3-none-any.whl", hash = "sha256:6fee160d6ffcd1b1c68c65f14c829c22832bc401726335ce92c52d395944a6a1", size = 78468, upload-time = "2022-09-03T11:10:27.148Z" }, + ] + + [[package]] + name = "urllib3" + version = "1.26.9" + source = { registry = "https://pypi.org/simple" } + sdist = { url = "https://files.pythonhosted.org/packages/1b/a5/4eab74853625505725cefdf168f48661b2cd04e7843ab836f3f63abf81da/urllib3-1.26.9.tar.gz", hash = "sha256:aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e", size = 295258, upload-time = "2022-03-16T13:28:19.197Z" } + wheels = [ + { url = "https://files.pythonhosted.org/packages/ec/03/062e6444ce4baf1eac17a6a0ebfe36bb1ad05e1df0e20b110de59c278498/urllib3-1.26.9-py2.py3-none-any.whl", hash = "sha256:44ece4d53fb1706f667c9bd1c648f5469a2ec925fcf3a776667042d645472c14", size = 138990, upload-time = "2022-03-16T13:28:16.026Z" }, + ] + "# + ); + }); + + Ok(()) +} diff --git a/crates/uv/tests/it/pip_compile.rs b/crates/uv/tests/it/pip_compile.rs index b99be12967c5d..5f0b43fed959c 100644 --- a/crates/uv/tests/it/pip_compile.rs +++ b/crates/uv/tests/it/pip_compile.rs @@ -3438,6 +3438,190 @@ fn compile_exclude_newer() -> Result<()> { Ok(()) } +/// Test per-package exclude-newer functionality +#[test] +fn compile_exclude_newer_package() -> Result<()> { + let context = TestContext::new("3.12"); + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str("tqdm\nrequests")?; + + // First, establish baseline with global exclude-newer + // tqdm 4.64.0 was released on 2022-04-04, 4.64.1 on 2022-09-03 + // requests 2.27.1 was released on 2022-01-05, 2.28.0 on 2022-05-29 + uv_snapshot!(context + .pip_compile() + .env_remove(EnvVars::UV_EXCLUDE_NEWER) + .arg("requirements.in") + .arg("--exclude-newer") + .arg("2022-04-04T12:00:00Z"), @r" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv pip compile --cache-dir [CACHE_DIR] requirements.in --exclude-newer 2022-04-04T12:00:00Z + certifi==2021.10.8 + # via requests + charset-normalizer==2.0.12 + # via requests + idna==3.3 + # via requests + requests==2.27.1 + # via -r requirements.in + tqdm==4.64.0 + # via -r requirements.in + urllib3==1.26.9 + # via requests + + ----- stderr ----- + Resolved 6 packages in [TIME] + " + ); + + // Test override: allow tqdm to use newer versions while keeping requests pinned + uv_snapshot!(context + .pip_compile() + .env_remove(EnvVars::UV_EXCLUDE_NEWER) + .arg("requirements.in") + .arg("--exclude-newer") + .arg("2022-04-04T12:00:00Z") + .arg("--exclude-newer-package") + .arg("tqdm=2022-09-04T00:00:00Z"), @r" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv pip compile --cache-dir [CACHE_DIR] requirements.in --exclude-newer 2022-04-04T12:00:00Z --exclude-newer-package tqdm=2022-09-04T00:00:00Z + certifi==2021.10.8 + # via requests + charset-normalizer==2.0.12 + # via requests + idna==3.3 + # via requests + requests==2.27.1 + # via -r requirements.in + tqdm==4.64.0 + # via -r requirements.in + urllib3==1.26.9 + # via requests + + ----- stderr ----- + Resolved 6 packages in [TIME] + " + ); + + // Test multiple package overrides + uv_snapshot!(context + .pip_compile() + .env_remove(EnvVars::UV_EXCLUDE_NEWER) + .arg("requirements.in") + .arg("--exclude-newer") + .arg("2022-01-01T00:00:00Z") + .arg("--exclude-newer-package") + .arg("tqdm=2022-09-04T00:00:00Z") + .arg("--exclude-newer-package") + .arg("requests=2022-06-01T00:00:00Z"), @r" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv pip compile --cache-dir [CACHE_DIR] requirements.in --exclude-newer 2022-01-01T00:00:00Z --exclude-newer-package tqdm=2022-09-04T00:00:00Z --exclude-newer-package requests=2022-06-01T00:00:00Z + certifi==2021.10.8 + # via requests + charset-normalizer==2.0.9 + # via requests + idna==3.3 + # via requests + requests==2.26.0 + # via -r requirements.in + tqdm==4.62.3 + # via -r requirements.in + urllib3==1.26.7 + # via requests + + ----- stderr ----- + Resolved 6 packages in [TIME] + " + ); + + // Test exclude-newer-package without global exclude-newer + uv_snapshot!(context + .pip_compile() + .env_remove(EnvVars::UV_EXCLUDE_NEWER) + .arg("requirements.in") + .arg("--exclude-newer-package") + .arg("tqdm=2022-04-04T12:00:00Z"), @r" + success: true + exit_code: 0 + ----- stdout ----- + # This file was autogenerated by uv via the following command: + # uv pip compile --cache-dir [CACHE_DIR] requirements.in --exclude-newer-package tqdm=2022-04-04T12:00:00Z + certifi==2025.6.15 + # via requests + charset-normalizer==3.4.2 + # via requests + idna==3.10 + # via requests + requests==2.32.4 + # via -r requirements.in + tqdm==4.67.1 + # via -r requirements.in + urllib3==2.5.0 + # via requests + + ----- stderr ----- + Resolved 6 packages in [TIME] + " + ); + + Ok(()) +} + +/// Test error handling for malformed --exclude-newer-package +#[test] +fn compile_exclude_newer_package_errors() -> Result<()> { + let context = TestContext::new("3.12"); + let requirements_in = context.temp_dir.child("requirements.in"); + requirements_in.write_str("tqdm")?; + + // Test invalid format (missing =) + uv_snapshot!(context + .pip_compile() + .env_remove(EnvVars::UV_EXCLUDE_NEWER) + .arg("requirements.in") + .arg("--exclude-newer-package") + .arg("tqdm"), @r" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: invalid value 'tqdm' for '--exclude-newer-package ': Invalid `exclude-newer-package` value `tqdm`: expected format `PACKAGE=DATE` + + For more information, try '--help'. + " + ); + + // Test invalid date format + uv_snapshot!(context + .pip_compile() + .env_remove(EnvVars::UV_EXCLUDE_NEWER) + .arg("requirements.in") + .arg("--exclude-newer-package") + .arg("tqdm=invalid-date"), @r#" + success: false + exit_code: 2 + ----- stdout ----- + + ----- stderr ----- + error: invalid value 'tqdm=invalid-date' for '--exclude-newer-package ': Invalid `exclude-newer-package` timestamp `invalid-date`: `invalid-date` could not be parsed as a valid date: failed to parse year in date "invalid-date": failed to parse "inva" as year (a four digit integer): invalid digit, expected 0-9 but got i + + For more information, try '--help'. + "# + ); + + Ok(()) +} + /// Resolve a local path dependency on a specific wheel. #[test] fn compile_wheel_path_dependency() -> Result<()> { diff --git a/crates/uv/tests/it/sync.rs b/crates/uv/tests/it/sync.rs index f9a71fe82e3ba..4b0ffaff9ed8d 100644 --- a/crates/uv/tests/it/sync.rs +++ b/crates/uv/tests/it/sync.rs @@ -9976,6 +9976,157 @@ fn sync_url_with_query_parameters() -> Result<()> { Ok(()) } +/// Test uv sync with --exclude-newer-package +#[test] +fn sync_exclude_newer_package() -> Result<()> { + let context = TestContext::new("3.12"); + + let pyproject_toml = context.temp_dir.child("pyproject.toml"); + pyproject_toml.write_str( + r#" +[project] +name = "project" +version = "0.1.0" +requires-python = ">=3.12" +dependencies = [ + "tqdm", + "requests", +] +"#, + )?; + + // First sync with only the global exclude-newer to show the baseline + uv_snapshot!(context.filters(), context + .sync() + .env_remove(EnvVars::UV_EXCLUDE_NEWER) + .arg("--exclude-newer") + .arg("2022-04-04T12:00:00Z"), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 8 packages in [TIME] + Prepared 6 packages in [TIME] + Installed 6 packages in [TIME] + + certifi==2021.10.8 + + charset-normalizer==2.0.12 + + idna==3.3 + + requests==2.27.1 + + tqdm==4.64.0 + + urllib3==1.26.9 + " + ); + + // Now sync with --exclude-newer-package to allow tqdm to use a newer version + uv_snapshot!(context.filters(), context + .sync() + .env_remove(EnvVars::UV_EXCLUDE_NEWER) + .arg("--exclude-newer") + .arg("2022-04-04T12:00:00Z") + .arg("--exclude-newer-package") + .arg("tqdm=2022-09-04T00:00:00Z"), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Ignoring existing lockfile due to change in timestamp cutoff: `global: 2022-04-04T12:00:00Z` vs. `global: 2022-04-04T12:00:00Z, tqdm: 2022-09-04T00:00:00Z` + Resolved 8 packages in [TIME] + Prepared 1 package in [TIME] + Uninstalled 1 package in [TIME] + Installed 1 package in [TIME] + - tqdm==4.64.0 + + tqdm==4.64.1 + " + ); + + Ok(()) +} + +/// Test exclude-newer-package in pyproject.toml configuration +#[test] +fn sync_exclude_newer_package_config() -> Result<()> { + let context = TestContext::new("3.12"); + + let pyproject_toml = context.temp_dir.child("pyproject.toml"); + pyproject_toml.write_str( + r#" +[project] +name = "project" +version = "0.1.0" +requires-python = ">=3.12" +dependencies = [ + "tqdm", + "requests", +] + +[tool.uv] +exclude-newer = "2022-04-04T12:00:00Z" +"#, + )?; + + // First sync with only the global exclude-newer from the config + uv_snapshot!(context.filters(), context + .sync() + .env_remove(EnvVars::UV_EXCLUDE_NEWER), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Resolved 8 packages in [TIME] + Prepared 6 packages in [TIME] + Installed 6 packages in [TIME] + + certifi==2021.10.8 + + charset-normalizer==2.0.12 + + idna==3.3 + + requests==2.27.1 + + tqdm==4.64.0 + + urllib3==1.26.9 + " + ); + + // Now add the package-specific exclude-newer to the config + pyproject_toml.write_str( + r#" +[project] +name = "project" +version = "0.1.0" +requires-python = ">=3.12" +dependencies = [ + "tqdm", + "requests", +] + +[tool.uv] +exclude-newer = "2022-04-04T12:00:00Z" +exclude-newer-package = { tqdm = "2022-09-04T00:00:00Z" } +"#, + )?; + + // Sync again with the package-specific override + uv_snapshot!(context.filters(), context + .sync() + .env_remove(EnvVars::UV_EXCLUDE_NEWER), @r" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Ignoring existing lockfile due to change in timestamp cutoff: `global: 2022-04-04T12:00:00Z` vs. `global: 2022-04-04T12:00:00Z, tqdm: 2022-09-04T00:00:00Z` + Resolved 8 packages in [TIME] + Prepared 1 package in [TIME] + Uninstalled 1 package in [TIME] + Installed 1 package in [TIME] + - tqdm==4.64.0 + + tqdm==4.64.1 + " + ); + + Ok(()) +} + #[test] #[cfg(unix)] fn read_only() -> Result<()> { diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 82fe0fa3de5f6..722b129a81fb0 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -96,7 +96,10 @@ uv run [OPTIONS] [COMMAND]

When enabled, uv will remove any extraneous packages from the environment. By default, uv run will make the minimum necessary changes to satisfy the requirements.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra extra

Include optional dependencies from the specified extra name.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for specific packages to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra extra

Include optional dependencies from the specified extra name.

May be provided more than once.

Optional dependencies are defined via project.optional-dependencies in a pyproject.toml.

This option is only available when running in a project.

@@ -456,7 +459,10 @@ uv add [OPTIONS] >
--editable

Add the requirements as editable

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra extra

Extras to enable for the dependency.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for specific packages to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra extra

Extras to enable for the dependency.

May be provided more than once.

To add this dependency to an optional extra instead, see --optional.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

@@ -645,7 +651,10 @@ uv remove [OPTIONS] ...

See --project to only change the project root directory.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for specific packages to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

May also be set with the UV_EXTRA_INDEX_URL environment variable.

Locations to search for candidate distributions, in addition to those found in the registry indexes.

@@ -816,7 +825,10 @@ uv version [OPTIONS] [VALUE]

Instead, the version will be displayed.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for specific packages to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

May also be set with the UV_EXTRA_INDEX_URL environment variable.

Locations to search for candidate distributions, in addition to those found in the registry indexes.

@@ -1000,7 +1012,10 @@ uv sync [OPTIONS]

In dry-run mode, uv will resolve the project's dependencies and report on the resulting changes to both the lockfile and the project environment, but will not modify either.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra extra

Include optional dependencies from the specified extra name.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for specific packages to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra extra

Include optional dependencies from the specified extra name.

May be provided more than once.

When multiple extras or groups are specified that appear in tool.uv.conflicts, uv will report an error.

Note that all optional dependencies are always included in the resolution; this option only affects the selection of packages to install.

@@ -1198,7 +1213,10 @@ uv lock [OPTIONS]

In dry-run mode, uv will resolve the project's dependencies and report on the resulting changes, but will not write the lockfile to disk.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for a specific package to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

May also be set with the UV_EXTRA_INDEX_URL environment variable.

Locations to search for candidate distributions, in addition to those found in the registry indexes.

@@ -1359,7 +1377,10 @@ uv export [OPTIONS]

See --project to only change the project root directory.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra extra

Include optional dependencies from the specified extra name.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for a specific package to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra extra

Include optional dependencies from the specified extra name.

May be provided more than once.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

@@ -1554,7 +1575,10 @@ uv tree [OPTIONS]

See --project to only change the project root directory.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for a specific package to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

May also be set with the UV_EXTRA_INDEX_URL environment variable.

Locations to search for candidate distributions, in addition to those found in the registry indexes.

@@ -1816,7 +1840,10 @@ uv tool run [OPTIONS] [COMMAND]

Can be provided multiple times, with subsequent files overriding values defined in previous files.

May also be set with the UV_ENV_FILE environment variable.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for specific packages to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

May also be set with the UV_EXTRA_INDEX_URL environment variable.

Locations to search for candidate distributions, in addition to those found in the registry indexes.

@@ -1987,7 +2014,10 @@ uv tool install [OPTIONS]
--editable, -e

Install the target package in editable mode, such that changes in the package's source directory are reflected without reinstallation

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for specific packages to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

May also be set with the UV_EXTRA_INDEX_URL environment variable.

Locations to search for candidate distributions, in addition to those found in the registry indexes.

@@ -2150,7 +2180,10 @@ uv tool upgrade [OPTIONS] ...

See --project to only change the project root directory.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for specific packages to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

May also be set with the UV_EXTRA_INDEX_URL environment variable.

Locations to search for candidate distributions, in addition to those found in the registry indexes.

@@ -3233,7 +3266,10 @@ uv pip compile [OPTIONS] >
--emit-index-url

Include --index-url and --extra-index-url entries in the generated output file

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra extra

Include optional dependencies from the specified extra name; may be provided more than once.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for a specific package to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra extra

Include optional dependencies from the specified extra name; may be provided more than once.

Only applies to pyproject.toml, setup.py, and setup.cfg sources.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

@@ -3533,7 +3569,10 @@ uv pip sync [OPTIONS] ...
--dry-run

Perform a dry run, i.e., don't actually install anything but resolve the dependencies and print the resulting plan

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for specific packages to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

May also be set with the UV_EXTRA_INDEX_URL environment variable.

Locations to search for candidate distributions, in addition to those found in the registry indexes.

@@ -3786,7 +3825,10 @@ uv pip install [OPTIONS] |--editable By default, installing will make the minimum necessary changes to satisfy the requirements. When enabled, uv will update the environment to exactly match the requirements, removing packages that are not included in the requirements.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra extra

Include optional dependencies from the specified extra name; may be provided more than once.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for specific packages to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra extra

Include optional dependencies from the specified extra name; may be provided more than once.

Only applies to pyproject.toml, setup.py, and setup.cfg sources.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

@@ -4580,7 +4622,10 @@ uv venv [OPTIONS] [PATH]

See --project to only change the project root directory.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for a specific package to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

May also be set with the UV_EXTRA_INDEX_URL environment variable.

Locations to search for candidate distributions, in addition to those found in the registry indexes.

@@ -4722,7 +4767,10 @@ uv build [OPTIONS] [SRC]

See --project to only change the project root directory.

--exclude-newer exclude-newer

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 local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.

-

May also be set with the UV_EXCLUDE_NEWER environment variable.

--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

+

May also be set with the UV_EXCLUDE_NEWER environment variable.

--exclude-newer-package exclude-newer-package

Limit candidate packages for a specific package to those that were uploaded prior to the given date.

+

Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.

+

Can be provided multiple times for different packages.

+
--extra-index-url extra-index-url

(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.

Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.

All indexes provided via this flag take priority over the index specified by --index-url (which defaults to PyPI). When multiple --extra-index-url flags are provided, earlier values take priority.

May also be set with the UV_EXTRA_INDEX_URL environment variable.

Locations to search for candidate distributions, in addition to those found in the registry indexes.

diff --git a/docs/reference/settings.md b/docs/reference/settings.md index 58948c80e59ce..3825619594c97 100644 --- a/docs/reference/settings.md +++ b/docs/reference/settings.md @@ -1070,6 +1070,32 @@ behave consistently across timezones. --- +### [`exclude-newer-package`](#exclude-newer-package) {: #exclude-newer-package } + +Limit candidate packages for specific packages to those that were uploaded prior to the given date. + +Accepts package-date pairs in a dictionary format. + +**Default value**: `None` + +**Type**: `dict` + +**Example usage**: + +=== "pyproject.toml" + + ```toml + [tool.uv] + exclude-newer-package = { tqdm = "2022-04-04T00:00:00Z" } + ``` +=== "uv.toml" + + ```toml + exclude-newer-package = { tqdm = "2022-04-04T00:00:00Z" } + ``` + +--- + ### [`extra-index-url`](#extra-index-url) {: #extra-index-url } Extra URLs of package indexes to use, in addition to `--index-url`. @@ -2476,6 +2502,34 @@ behave consistently across timezones. --- +#### [`exclude-newer-package`](#pip_exclude-newer-package) {: #pip_exclude-newer-package } + + +Limit candidate packages for specific packages to those that were uploaded prior to the given date. + +Accepts package-date pairs in a dictionary format. + +**Default value**: `None` + +**Type**: `dict` + +**Example usage**: + +=== "pyproject.toml" + + ```toml + [tool.uv.pip] + exclude-newer-package = { tqdm = "2022-04-04T00:00:00Z" } + ``` +=== "uv.toml" + + ```toml + [pip] + exclude-newer-package = { tqdm = "2022-04-04T00:00:00Z" } + ``` + +--- + #### [`extra`](#pip_extra) {: #pip_extra } diff --git a/uv.schema.json b/uv.schema.json index dbc4f11689e8f..8e7086729906b 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -196,13 +196,23 @@ "description": "Limit candidate packages to those that were uploaded prior to a given point in time.\n\nAccepts a superset of [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339.html) (e.g.,\n`2006-12-02T02:07:43Z`). A full timestamp is required to ensure that the resolver will\nbehave consistently across timezones.", "anyOf": [ { - "$ref": "#/definitions/ExcludeNewer" + "$ref": "#/definitions/ExcludeNewerTimestamp" }, { "type": "null" } ] }, + "exclude-newer-package": { + "description": "Limit candidate packages for specific packages to those that were uploaded prior to the given date.\n\nAccepts package-date pairs in a dictionary format.", + "type": [ + "object", + "null" + ], + "additionalProperties": { + "$ref": "#/definitions/ExcludeNewerTimestamp" + } + }, "extra-index-url": { "description": "Extra URLs of package indexes to use, in addition to `--index-url`.\n\nAccepts either a repository compliant with [PEP 503](https://peps.python.org/pep-0503/)\n(the simple repository API), or a local directory laid out in the same format.\n\nAll indexes provided via this flag take priority over the index specified by\n[`index_url`](#index-url) or [`index`](#index) with `default = true`. When multiple indexes\nare provided, earlier values take priority.\n\nTo control uv's resolution strategy when multiple indexes are present, see\n[`index_strategy`](#index-strategy).\n\n(Deprecated: use `index` instead.)", "type": [ @@ -836,7 +846,7 @@ "type": "string", "format": "uri" }, - "ExcludeNewer": { + "ExcludeNewerTimestamp": { "description": "Exclude distributions uploaded after the given timestamp.\n\nAccepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same format (e.g., `2006-12-02`).", "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(Z|[+-]\\d{2}:\\d{2}))?$" @@ -1189,13 +1199,23 @@ "description": "Limit candidate packages to those that were uploaded prior to a given point in time.\n\nAccepts a superset of [RFC 3339](https://www.rfc-editor.org/rfc/rfc3339.html) (e.g.,\n`2006-12-02T02:07:43Z`). A full timestamp is required to ensure that the resolver will\nbehave consistently across timezones.", "anyOf": [ { - "$ref": "#/definitions/ExcludeNewer" + "$ref": "#/definitions/ExcludeNewerTimestamp" }, { "type": "null" } ] }, + "exclude-newer-package": { + "description": "Limit candidate packages for specific packages to those that were uploaded prior to the given date.\n\nAccepts package-date pairs in a dictionary format.", + "type": [ + "object", + "null" + ], + "additionalProperties": { + "$ref": "#/definitions/ExcludeNewerTimestamp" + } + }, "extra": { "description": "Include optional dependencies from the specified extra; may be provided more than once.\n\nOnly applies to `pyproject.toml`, `setup.py`, and `setup.cfg` sources.", "type": [