Skip to content

Add exclude-newer-package #14489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions crates/uv-bench/benches/uv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand All @@ -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();
Expand Down
62 changes: 55 additions & 7 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ExcludeNewer>,
pub exclude_newer: Option<ExcludeNewerTimestamp>,

/// 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<Vec<ExcludeNewerPackageEntry>>,

/// The method to use when installing packages from the global cache.
///
Expand Down Expand Up @@ -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<ExcludeNewer>,
pub exclude_newer: Option<ExcludeNewerTimestamp>,

/// 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<Vec<ExcludeNewerPackageEntry>>,

/// The method to use when installing packages from the global cache.
///
Expand Down Expand Up @@ -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<ExcludeNewer>,
pub exclude_newer: Option<ExcludeNewerTimestamp>,

/// 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<Vec<ExcludeNewerPackageEntry>>,

/// The method to use when installing packages from the global cache.
///
Expand Down Expand Up @@ -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<ExcludeNewer>,
pub exclude_newer: Option<ExcludeNewerTimestamp>,

/// 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<Vec<ExcludeNewerPackageEntry>>,

/// The method to use when installing packages from the global cache.
///
Expand Down Expand Up @@ -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<ExcludeNewer>,
pub exclude_newer: Option<ExcludeNewerTimestamp>,

/// 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<Vec<ExcludeNewerPackageEntry>>,

/// The method to use when installing packages from the global cache.
///
Expand Down Expand Up @@ -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<ExcludeNewer>,
pub exclude_newer: Option<ExcludeNewerTimestamp>,
}

#[derive(Args)]
Expand Down
30 changes: 28 additions & 2 deletions crates/uv-cli/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -68,6 +68,7 @@ impl From<ResolverArgs> for PipOptions {
exclude_newer,
link_mode,
no_sources,
exclude_newer_package,
} = args;

Self {
Expand All @@ -87,6 +88,12 @@ impl From<ResolverArgs> 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)
Expand All @@ -111,6 +118,7 @@ impl From<InstallerArgs> for PipOptions {
compile_bytecode,
no_compile_bytecode,
no_sources,
exclude_newer_package: _,
} = args;

Self {
Expand Down Expand Up @@ -155,6 +163,7 @@ impl From<ResolverInstallerArgs> for PipOptions {
compile_bytecode,
no_compile_bytecode,
no_sources,
exclude_newer_package,
} = args;

Self {
Expand All @@ -176,6 +185,12 @@ impl From<ResolverInstallerArgs> 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 },
Expand Down Expand Up @@ -266,6 +281,7 @@ pub fn resolver_options(
exclude_newer,
link_mode,
no_sources,
exclude_newer_package,
} = resolver_args;

let BuildOptionsArgs {
Expand Down Expand Up @@ -323,7 +339,10 @@ pub fn resolver_options(
.map(|config_settings| config_settings.into_iter().collect::<ConfigSettings>()),
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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down
6 changes: 3 additions & 3 deletions crates/uv-dispatch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub struct BuildDispatch<'a> {
build_options: &'a BuildOptions,
config_settings: &'a ConfigSettings,
hasher: &'a HashStrategy,
exclude_newer: Option<ExcludeNewer>,
exclude_newer: ExcludeNewer,
source_build_context: SourceBuildContext,
build_extra_env_vars: FxHashMap<OsString, OsString>,
sources: SourceStrategy,
Expand All @@ -117,7 +117,7 @@ impl<'a> BuildDispatch<'a> {
link_mode: uv_install_wheel::LinkMode,
build_options: &'a BuildOptions,
hasher: &'a HashStrategy,
exclude_newer: Option<ExcludeNewer>,
exclude_newer: ExcludeNewer,
sources: SourceStrategy,
workspace_cache: WorkspaceCache,
concurrency: Concurrency,
Expand Down Expand Up @@ -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)
Expand Down
Loading
Loading