Add support for relative durations in exclude-newer (#16814)
Adds support for "friendly" durations like, 1 week, 7 days, 24 hours using Jiff's parser. During resolution, we calculate this relative to the current time and resolve it into a concrete timestamp for the lockfile. If the span has not changed, e.g., to another relative value, then locking again will not change the lockfile. The locked timestamp will only be updated when the lockfile is invalidated, e.g., with `--upgrade`. This prevents the lockfile from repeatedly churning when a relative value is used.
This commit is contained in:
+120
-44
@@ -28,7 +28,7 @@ use uv_pypi_types::VerbatimParsedUrl;
|
||||
use uv_python::{PythonDownloads, PythonPreference, PythonVersion};
|
||||
use uv_redacted::DisplaySafeUrl;
|
||||
use uv_resolver::{
|
||||
AnnotationStyle, ExcludeNewerPackageEntry, ExcludeNewerTimestamp, ForkStrategy, PrereleaseMode,
|
||||
AnnotationStyle, ExcludeNewerPackageEntry, ExcludeNewerValue, ForkStrategy, PrereleaseMode,
|
||||
ResolutionMode,
|
||||
};
|
||||
use uv_settings::PythonInstallMirrors;
|
||||
@@ -3083,15 +3083,29 @@ pub struct VenvArgs {
|
||||
|
||||
/// 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.
|
||||
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER)]
|
||||
pub exclude_newer: Option<ExcludeNewerTimestamp>,
|
||||
|
||||
/// Limit candidate packages for a specific package to those that were uploaded prior to the given date.
|
||||
/// Accepts RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`), local dates in the same format
|
||||
/// (e.g., `2006-12-02`) resolved based on your system's configured time zone, a "friendly"
|
||||
/// duration (e.g., `24 hours`, `1 week`, `30 days`), or an ISO 8601 duration (e.g., `PT24H`,
|
||||
/// `P7D`, `P30D`).
|
||||
///
|
||||
/// 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.
|
||||
/// Durations do not respect semantics of the local time zone and are always resolved to a fixed
|
||||
/// number of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).
|
||||
/// Calendar units such as months and years are not allowed.
|
||||
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER)]
|
||||
pub exclude_newer: Option<ExcludeNewerValue>,
|
||||
|
||||
/// 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`), a local date in the same format (e.g.,
|
||||
/// `2006-12-02`) resolved based on your system's configured time zone, a "friendly" duration
|
||||
/// (e.g., `24 hours`, `1 week`, `30 days`), or a ISO 8601 duration (e.g., `PT24H`, `P7D`,
|
||||
/// `P30D`).
|
||||
///
|
||||
/// Durations do not respect semantics of the local time zone and are always resolved to a fixed
|
||||
/// number of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).
|
||||
/// Calendar units such as months and years are not allowed.
|
||||
///
|
||||
/// Can be provided multiple times for different packages.
|
||||
#[arg(long)]
|
||||
@@ -5579,15 +5593,29 @@ pub struct ToolUpgradeArgs {
|
||||
|
||||
/// 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.
|
||||
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
|
||||
pub exclude_newer: Option<ExcludeNewerTimestamp>,
|
||||
|
||||
/// Limit candidate packages for specific packages to those that were uploaded prior to the given date.
|
||||
/// Accepts RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`), local dates in the same format
|
||||
/// (e.g., `2006-12-02`) resolved based on your system's configured time zone, a "friendly"
|
||||
/// duration (e.g., `24 hours`, `1 week`, `30 days`), or an ISO 8601 duration (e.g., `PT24H`,
|
||||
/// `P7D`, `P30D`).
|
||||
///
|
||||
/// 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.
|
||||
/// Durations do not respect semantics of the local time zone and are always resolved to a fixed
|
||||
/// number of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).
|
||||
/// Calendar units such as months and years are not allowed.
|
||||
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
|
||||
pub exclude_newer: Option<ExcludeNewerValue>,
|
||||
|
||||
/// 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`), a local date in the same format (e.g.,
|
||||
/// `2006-12-02`) resolved based on your system's configured time zone, a "friendly" duration
|
||||
/// (e.g., `24 hours`, `1 week`, `30 days`), or an ISO 8601 duration (e.g., `PT24H`, `P7D`,
|
||||
/// `P30D`).
|
||||
///
|
||||
/// Durations do not respect semantics of the local time zone and are always resolved to a fixed
|
||||
/// number of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).
|
||||
/// Calendar units such as months and years are not allowed.
|
||||
///
|
||||
/// Can be provided multiple times for different packages.
|
||||
#[arg(long, help_heading = "Resolver options")]
|
||||
@@ -6537,15 +6565,29 @@ pub struct InstallerArgs {
|
||||
|
||||
/// 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.
|
||||
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
|
||||
pub exclude_newer: Option<ExcludeNewerTimestamp>,
|
||||
|
||||
/// Limit candidate packages for specific packages to those that were uploaded prior to the given date.
|
||||
/// Accepts RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`), local dates in the same format
|
||||
/// (e.g., `2006-12-02`) resolved based on your system's configured time zone, a "friendly"
|
||||
/// duration (e.g., `24 hours`, `1 week`, `30 days`), or an ISO 8601 duration (e.g., `PT24H`,
|
||||
/// `P7D`, `P30D`).
|
||||
///
|
||||
/// 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.
|
||||
/// Durations do not respect semantics of the local time zone and are always resolved to a fixed
|
||||
/// number of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).
|
||||
/// Calendar units such as months and years are not allowed.
|
||||
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
|
||||
pub exclude_newer: Option<ExcludeNewerValue>,
|
||||
|
||||
/// 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`), a local date in the same format (e.g.,
|
||||
/// `2006-12-02`) resolved based on your system's configured time zone, a "friendly" duration
|
||||
/// (e.g., `24 hours`, `1 week`, `30 days`), or an ISO 8601 duration (e.g., `PT24H`, `P7D`,
|
||||
/// `P30D`).
|
||||
///
|
||||
/// Durations do not respect semantics of the local time zone and are always resolved to a fixed
|
||||
/// number of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).
|
||||
/// Calendar units such as months and years are not allowed.
|
||||
///
|
||||
/// Can be provided multiple times for different packages.
|
||||
#[arg(long, help_heading = "Resolver options")]
|
||||
@@ -6757,15 +6799,29 @@ pub struct ResolverArgs {
|
||||
|
||||
/// 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.
|
||||
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
|
||||
pub exclude_newer: Option<ExcludeNewerTimestamp>,
|
||||
|
||||
/// Limit candidate packages for a specific package to those that were uploaded prior to the given date.
|
||||
/// Accepts RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`), local dates in the same format
|
||||
/// (e.g., `2006-12-02`) resolved based on your system's configured time zone, a "friendly"
|
||||
/// duration (e.g., `24 hours`, `1 week`, `30 days`), or an ISO 8601 duration (e.g., `PT24H`,
|
||||
/// `P7D`, `P30D`).
|
||||
///
|
||||
/// 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.
|
||||
/// Durations do not respect semantics of the local time zone and are always resolved to a fixed
|
||||
/// number of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).
|
||||
/// Calendar units such as months and years are not allowed.
|
||||
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
|
||||
pub exclude_newer: Option<ExcludeNewerValue>,
|
||||
|
||||
/// 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`), a local date in the same format (e.g.,
|
||||
/// `2006-12-02`) resolved based on your system's configured time zone, a "friendly" duration
|
||||
/// (e.g., `24 hours`, `1 week`, `30 days`), or an ISO 8601 duration (e.g., `PT24H`, `P7D`,
|
||||
/// `P30D`).
|
||||
///
|
||||
/// Durations do not respect semantics of the local time zone and are always resolved to a fixed
|
||||
/// number of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).
|
||||
/// Calendar units such as months and years are not allowed.
|
||||
///
|
||||
/// Can be provided multiple times for different packages.
|
||||
#[arg(long, help_heading = "Resolver options")]
|
||||
@@ -6973,15 +7029,29 @@ pub struct ResolverInstallerArgs {
|
||||
|
||||
/// 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.
|
||||
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
|
||||
pub exclude_newer: Option<ExcludeNewerTimestamp>,
|
||||
|
||||
/// Limit candidate packages for specific packages to those that were uploaded prior to the given date.
|
||||
/// Accepts RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`), local dates in the same format
|
||||
/// (e.g., `2006-12-02`) resolved based on your system's configured time zone, a "friendly"
|
||||
/// duration (e.g., `24 hours`, `1 week`, `30 days`), or an ISO 8601 duration (e.g., `PT24H`,
|
||||
/// `P7D`, `P30D`).
|
||||
///
|
||||
/// 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.
|
||||
/// Durations do not respect semantics of the local time zone and are always resolved to a fixed
|
||||
/// number of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).
|
||||
/// Calendar units such as months and years are not allowed.
|
||||
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
|
||||
pub exclude_newer: Option<ExcludeNewerValue>,
|
||||
|
||||
/// 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`), a local date in the same format (e.g.,
|
||||
/// `2006-12-02`) resolved based on your system's configured time zone, a "friendly" duration
|
||||
/// (e.g., `24 hours`, `1 week`, `30 days`), or an ISO 8601 duration (e.g., `PT24H`, `P7D`,
|
||||
/// `P30D`).
|
||||
///
|
||||
/// Durations do not respect semantics of the local time zone and are always resolved to a fixed
|
||||
/// number of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).
|
||||
/// Calendar units such as months and years are not allowed.
|
||||
///
|
||||
/// Can be provided multiple times for different packages.
|
||||
#[arg(long, help_heading = "Resolver options")]
|
||||
@@ -7081,10 +7151,16 @@ pub struct FetchArgs {
|
||||
|
||||
/// 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.
|
||||
/// Accepts RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`), local dates in the same format
|
||||
/// (e.g., `2006-12-02`) resolved based on your system's configured time zone, a "friendly"
|
||||
/// duration (e.g., `24 hours`, `1 week`, `30 days`), or an ISO 8601 duration (e.g., `PT24H`,
|
||||
/// `P7D`, `P30D`).
|
||||
///
|
||||
/// Durations do not respect semantics of the local time zone and are always resolved to a fixed
|
||||
/// number of seconds assuming that a day is 24 hours (e.g., DST transitions are ignored).
|
||||
/// Calendar units such as months and years are not allowed.
|
||||
#[arg(long, env = EnvVars::UV_EXCLUDE_NEWER, help_heading = "Resolver options")]
|
||||
pub exclude_newer: Option<ExcludeNewerTimestamp>,
|
||||
pub exclude_newer: Option<ExcludeNewerValue>,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
|
||||
Reference in New Issue
Block a user