Skip to content

Commit 00b7726

Browse files
committed
Add exclude-newer-package
1 parent 1d20530 commit 00b7726

File tree

33 files changed

+1132
-119
lines changed

33 files changed

+1132
-119
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/uv-bench/benches/uv.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ mod resolver {
9999
use uv_pypi_types::{Conflicts, ResolverMarkerEnvironment};
100100
use uv_python::Interpreter;
101101
use uv_resolver::{
102-
FlatIndex, InMemoryIndex, Manifest, OptionsBuilder, PythonRequirement, Resolver,
103-
ResolverEnvironment, ResolverOutput,
102+
ExcludeNewer, FlatIndex, InMemoryIndex, Manifest, OptionsBuilder, PythonRequirement,
103+
Resolver, ResolverEnvironment, ResolverOutput,
104104
};
105105
use uv_types::{BuildIsolation, EmptyInstalledPackages, HashStrategy};
106106
use uv_workspace::WorkspaceCache;
@@ -144,7 +144,7 @@ mod resolver {
144144
let build_options = BuildOptions::default();
145145
let concurrency = Concurrency::default();
146146
let config_settings = ConfigSettings::default();
147-
let exclude_newer = Some(
147+
let exclude_newer = ExcludeNewer::global(
148148
jiff::civil::date(2024, 9, 1)
149149
.to_zoned(jiff::tz::TimeZone::UTC)
150150
.unwrap()
@@ -158,7 +158,9 @@ mod resolver {
158158
let index = InMemoryIndex::default();
159159
let index_locations = IndexLocations::default();
160160
let installed_packages = EmptyInstalledPackages;
161-
let options = OptionsBuilder::new().exclude_newer(exclude_newer).build();
161+
let options = OptionsBuilder::new()
162+
.exclude_newer(exclude_newer.clone())
163+
.build();
162164
let sources = SourceStrategy::default();
163165
let dependency_metadata = DependencyMetadata::default();
164166
let conflicts = Conflicts::empty();

crates/uv-cli/src/lib.rs

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ use uv_pep508::{MarkerTree, Requirement};
1919
use uv_pypi_types::VerbatimParsedUrl;
2020
use uv_python::{PythonDownloads, PythonPreference, PythonVersion};
2121
use uv_redacted::DisplaySafeUrl;
22-
use uv_resolver::{AnnotationStyle, ExcludeNewer, ForkStrategy, PrereleaseMode, ResolutionMode};
22+
use uv_resolver::{
23+
AnnotationStyle, ExcludeNewerPackageEntry, ExcludeNewerTimestamp, ForkStrategy, PrereleaseMode,
24+
ResolutionMode,
25+
};
2326
use uv_static::EnvVars;
2427
use uv_torch::TorchMode;
2528
use uv_workspace::pyproject_mut::AddBoundsKind;
@@ -2644,7 +2647,16 @@ pub struct VenvArgs {
26442647
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
26452648
/// format (e.g., `2006-12-02`) in your system's configured time zone.
26462649
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER)]
2647-
pub exclude_newer: Option<ExcludeNewer>,
2650+
pub exclude_newer: Option<ExcludeNewerTimestamp>,
2651+
2652+
/// Limit candidate packages for a specific package to those that were uploaded prior to the given date.
2653+
///
2654+
/// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp
2655+
/// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone.
2656+
///
2657+
/// Can be provided multiple times for different packages.
2658+
#[arg(long)]
2659+
pub exclude_newer_package: Option<Vec<ExcludeNewerPackageEntry>>,
26482660

26492661
/// The method to use when installing packages from the global cache.
26502662
///
@@ -4626,7 +4638,16 @@ pub struct ToolUpgradeArgs {
46264638
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
46274639
/// format (e.g., `2006-12-02`) in your system's configured time zone.
46284640
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
4629-
pub exclude_newer: Option<ExcludeNewer>,
4641+
pub exclude_newer: Option<ExcludeNewerTimestamp>,
4642+
4643+
/// Limit candidate packages for specific packages to those that were uploaded prior to the given date.
4644+
///
4645+
/// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp
4646+
/// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone.
4647+
///
4648+
/// Can be provided multiple times for different packages.
4649+
#[arg(long, help_heading = "Resolver options")]
4650+
pub exclude_newer_package: Option<Vec<ExcludeNewerPackageEntry>>,
46304651

46314652
/// The method to use when installing packages from the global cache.
46324653
///
@@ -5367,7 +5388,16 @@ pub struct InstallerArgs {
53675388
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
53685389
/// format (e.g., `2006-12-02`) in your system's configured time zone.
53695390
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
5370-
pub exclude_newer: Option<ExcludeNewer>,
5391+
pub exclude_newer: Option<ExcludeNewerTimestamp>,
5392+
5393+
/// Limit candidate packages for specific packages to those that were uploaded prior to the given date.
5394+
///
5395+
/// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp
5396+
/// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone.
5397+
///
5398+
/// Can be provided multiple times for different packages.
5399+
#[arg(long, help_heading = "Resolver options")]
5400+
pub exclude_newer_package: Option<Vec<ExcludeNewerPackageEntry>>,
53715401

53725402
/// The method to use when installing packages from the global cache.
53735403
///
@@ -5560,7 +5590,16 @@ pub struct ResolverArgs {
55605590
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
55615591
/// format (e.g., `2006-12-02`) in your system's configured time zone.
55625592
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
5563-
pub exclude_newer: Option<ExcludeNewer>,
5593+
pub exclude_newer: Option<ExcludeNewerTimestamp>,
5594+
5595+
/// Limit candidate packages for a specific package to those that were uploaded prior to the given date.
5596+
///
5597+
/// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp
5598+
/// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone.
5599+
///
5600+
/// Can be provided multiple times for different packages.
5601+
#[arg(long, help_heading = "Resolver options")]
5602+
pub exclude_newer_package: Option<Vec<ExcludeNewerPackageEntry>>,
55645603

55655604
/// The method to use when installing packages from the global cache.
55665605
///
@@ -5749,7 +5788,16 @@ pub struct ResolverInstallerArgs {
57495788
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
57505789
/// format (e.g., `2006-12-02`) in your system's configured time zone.
57515790
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
5752-
pub exclude_newer: Option<ExcludeNewer>,
5791+
pub exclude_newer: Option<ExcludeNewerTimestamp>,
5792+
5793+
/// Limit candidate packages for specific packages to those that were uploaded prior to the given date.
5794+
///
5795+
/// Accepts package-date pairs in the format `PACKAGE=DATE`, where `DATE` is an RFC 3339 timestamp
5796+
/// (e.g., `2006-12-02T02:07:43Z`) or local date (e.g., `2006-12-02`) in your system's configured time zone.
5797+
///
5798+
/// Can be provided multiple times for different packages.
5799+
#[arg(long, help_heading = "Resolver options")]
5800+
pub exclude_newer_package: Option<Vec<ExcludeNewerPackageEntry>>,
57535801

57545802
/// The method to use when installing packages from the global cache.
57555803
///
@@ -5838,7 +5886,7 @@ pub struct FetchArgs {
58385886
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same
58395887
/// format (e.g., `2006-12-02`) in your system's configured time zone.
58405888
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
5841-
pub exclude_newer: Option<ExcludeNewer>,
5889+
pub exclude_newer: Option<ExcludeNewerTimestamp>,
58425890
}
58435891

58445892
#[derive(Args)]

crates/uv-cli/src/options.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anstream::eprintln;
22

33
use uv_cache::Refresh;
44
use uv_configuration::ConfigSettings;
5-
use uv_resolver::PrereleaseMode;
5+
use uv_resolver::{ExcludeNewer, PrereleaseMode};
66
use uv_settings::{Combine, PipOptions, ResolverInstallerOptions, ResolverOptions};
77
use uv_warnings::owo_colors::OwoColorize;
88

@@ -68,6 +68,7 @@ impl From<ResolverArgs> for PipOptions {
6868
exclude_newer,
6969
link_mode,
7070
no_sources,
71+
exclude_newer_package,
7172
} = args;
7273

7374
Self {
@@ -87,6 +88,12 @@ impl From<ResolverArgs> for PipOptions {
8788
no_build_isolation: flag(no_build_isolation, build_isolation, "build-isolation"),
8889
no_build_isolation_package: Some(no_build_isolation_package),
8990
exclude_newer,
91+
exclude_newer_package: exclude_newer_package.map(|entries| {
92+
entries
93+
.into_iter()
94+
.map(|e| (e.package, e.timestamp))
95+
.collect()
96+
}),
9097
link_mode,
9198
no_sources: if no_sources { Some(true) } else { None },
9299
..PipOptions::from(index_args)
@@ -111,6 +118,7 @@ impl From<InstallerArgs> for PipOptions {
111118
compile_bytecode,
112119
no_compile_bytecode,
113120
no_sources,
121+
exclude_newer_package: _,
114122
} = args;
115123

116124
Self {
@@ -155,6 +163,7 @@ impl From<ResolverInstallerArgs> for PipOptions {
155163
compile_bytecode,
156164
no_compile_bytecode,
157165
no_sources,
166+
exclude_newer_package,
158167
} = args;
159168

160169
Self {
@@ -176,6 +185,12 @@ impl From<ResolverInstallerArgs> for PipOptions {
176185
no_build_isolation: flag(no_build_isolation, build_isolation, "build-isolation"),
177186
no_build_isolation_package: Some(no_build_isolation_package),
178187
exclude_newer,
188+
exclude_newer_package: exclude_newer_package.map(|entries| {
189+
entries
190+
.into_iter()
191+
.map(|e| (e.package, e.timestamp))
192+
.collect()
193+
}),
179194
link_mode,
180195
compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"),
181196
no_sources: if no_sources { Some(true) } else { None },
@@ -266,6 +281,7 @@ pub fn resolver_options(
266281
exclude_newer,
267282
link_mode,
268283
no_sources,
284+
exclude_newer_package,
269285
} = resolver_args;
270286

271287
let BuildOptionsArgs {
@@ -323,7 +339,10 @@ pub fn resolver_options(
323339
.map(|config_settings| config_settings.into_iter().collect::<ConfigSettings>()),
324340
no_build_isolation: flag(no_build_isolation, build_isolation, "build-isolation"),
325341
no_build_isolation_package: Some(no_build_isolation_package),
326-
exclude_newer,
342+
exclude_newer: ExcludeNewer::from_args(
343+
exclude_newer,
344+
exclude_newer_package.unwrap_or_default(),
345+
),
327346
link_mode,
328347
no_build: flag(no_build, build, "build"),
329348
no_build_package: Some(no_build_package),
@@ -357,6 +376,7 @@ pub fn resolver_installer_options(
357376
no_build_isolation_package,
358377
build_isolation,
359378
exclude_newer,
379+
exclude_newer_package,
360380
link_mode,
361381
compile_bytecode,
362382
no_compile_bytecode,
@@ -435,6 +455,12 @@ pub fn resolver_installer_options(
435455
Some(no_build_isolation_package)
436456
},
437457
exclude_newer,
458+
exclude_newer_package: exclude_newer_package.map(|entries| {
459+
entries
460+
.into_iter()
461+
.map(|e| (e.package, e.timestamp))
462+
.collect()
463+
}),
438464
link_mode,
439465
compile_bytecode: flag(compile_bytecode, no_compile_bytecode, "compile-bytecode"),
440466
no_build: flag(no_build, build, "build"),

crates/uv-dispatch/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub struct BuildDispatch<'a> {
9292
build_options: &'a BuildOptions,
9393
config_settings: &'a ConfigSettings,
9494
hasher: &'a HashStrategy,
95-
exclude_newer: Option<ExcludeNewer>,
95+
exclude_newer: ExcludeNewer,
9696
source_build_context: SourceBuildContext,
9797
build_extra_env_vars: FxHashMap<OsString, OsString>,
9898
sources: SourceStrategy,
@@ -117,7 +117,7 @@ impl<'a> BuildDispatch<'a> {
117117
link_mode: uv_install_wheel::LinkMode,
118118
build_options: &'a BuildOptions,
119119
hasher: &'a HashStrategy,
120-
exclude_newer: Option<ExcludeNewer>,
120+
exclude_newer: ExcludeNewer,
121121
sources: SourceStrategy,
122122
workspace_cache: WorkspaceCache,
123123
concurrency: Concurrency,
@@ -224,7 +224,7 @@ impl BuildContext for BuildDispatch<'_> {
224224
let resolver = Resolver::new(
225225
Manifest::simple(requirements.to_vec()).with_constraints(self.constraints.clone()),
226226
OptionsBuilder::new()
227-
.exclude_newer(self.exclude_newer)
227+
.exclude_newer(self.exclude_newer.clone())
228228
.index_strategy(self.index_strategy)
229229
.build_options(self.build_options.clone())
230230
.flexibility(Flexibility::Fixed)

0 commit comments

Comments
 (0)