mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-13 17:25:41 +00:00
Option to resolve at a fixed timestamp with pip-compile --exclude-newer YYYY-MM-DD (#434)
This works by filtering out files with a more recent upload time, so if
the index you use does not provide upload times, the results might be
inaccurate. pypi provides upload times for all files. This is, the field
is non-nullable in the warehouse schema, but the simple API PEP does not
know this field.
If you have only pypi dependencies, this means deterministic,
reproducible(!) resolution. We could try doing the same for git repos
but it doesn't seem worth the effort, i'd recommend pinning commits
since git histories are arbitrarily malleable and also if you care about
reproducibility and such you such not use git dependencies but a custom
index.
Timestamps are given either as RFC 3339 timestamps such as
`2006-12-02T02:07:43Z` or as UTC dates in the same format such as
`2006-12-02`. Dates are interpreted as including this day, i.e. until
midnight UTC that day. Date only is required to make this ergonomic and
midnight seems like an ergonomic choice.
In action for `pandas`:
```console
$ target/debug/puffin pip-compile --exclude-newer 2023-11-16 target/pandas.in
Resolved 6 packages in 679ms
# This file was autogenerated by Puffin v0.0.1 via the following command:
# target/debug/puffin pip-compile --exclude-newer 2023-11-16 target/pandas.in
numpy==1.26.2
# via pandas
pandas==2.1.3
python-dateutil==2.8.2
# via pandas
pytz==2023.3.post1
# via pandas
six==1.16.0
# via python-dateutil
tzdata==2023.3
# via pandas
$ target/debug/puffin pip-compile --exclude-newer 2022-11-16 target/pandas.in
Resolved 5 packages in 655ms
# This file was autogenerated by Puffin v0.0.1 via the following command:
# target/debug/puffin pip-compile --exclude-newer 2022-11-16 target/pandas.in
numpy==1.23.4
# via pandas
pandas==1.5.1
python-dateutil==2.8.2
# via pandas
pytz==2022.6
# via pandas
six==1.16.0
# via python-dateutil
$ target/debug/puffin pip-compile --exclude-newer 2021-11-16 target/pandas.in
Resolved 5 packages in 594ms
# This file was autogenerated by Puffin v0.0.1 via the following command:
# target/debug/puffin pip-compile --exclude-newer 2021-11-16 target/pandas.in
numpy==1.21.4
# via pandas
pandas==1.3.4
python-dateutil==2.8.2
# via pandas
pytz==2021.3
# via pandas
six==1.16.0
# via python-dateutil
```
This commit is contained in:
parent
0d455ebd06
commit
e41ec12239
14 changed files with 218 additions and 38 deletions
|
|
@ -2,6 +2,9 @@ use std::collections::btree_map::Entry;
|
|||
use std::collections::BTreeMap;
|
||||
use std::str::FromStr;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use tracing::warn;
|
||||
|
||||
use distribution_filename::{SourceDistFilename, WheelFilename};
|
||||
use pep440_rs::Version;
|
||||
use platform_tags::{TagPriority, Tags};
|
||||
|
|
@ -22,6 +25,7 @@ impl VersionMap {
|
|||
package_name: &PackageName,
|
||||
tags: &Tags,
|
||||
python_version: &Version,
|
||||
exclude_newer: Option<&DateTime<Utc>>,
|
||||
) -> Self {
|
||||
let mut map = BTreeMap::default();
|
||||
|
||||
|
|
@ -42,6 +46,25 @@ impl VersionMap {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Support resolving as if it were an earlier timestamp, at least as long files have
|
||||
// upload time information
|
||||
if let Some(exclude_newer) = exclude_newer {
|
||||
match file.upload_time.as_ref() {
|
||||
Some(upload_time) if upload_time >= exclude_newer => {
|
||||
continue;
|
||||
}
|
||||
None => {
|
||||
// TODO(konstin): Implement and use `warn_once` here.
|
||||
warn!(
|
||||
"{} is missing an upload date, but user provided {}",
|
||||
file.filename, exclude_newer,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
// When resolving, exclude yanked files.
|
||||
// TODO(konstin): When we fail resolving due to a dependency locked to yanked version,
|
||||
// we should tell the user.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue