Set an exclude cutoff for virtualenv tests (#1280)

## Summary

This test is failing since a new version of one of the seed packages was
uploaded.
This commit is contained in:
Charlie Marsh 2024-02-11 21:21:05 -05:00 committed by GitHub
parent a37b08808e
commit a16ec45d1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 57 additions and 32 deletions

View file

@ -4,6 +4,7 @@ use std::str::FromStr;
use anstream::eprint;
use anyhow::Result;
use chrono::{DateTime, Utc};
use miette::{Diagnostic, IntoDiagnostic};
use owo_colors::OwoColorize;
use thiserror::Error;
@ -17,7 +18,7 @@ use puffin_dispatch::BuildDispatch;
use puffin_fs::Normalized;
use puffin_installer::NoBinary;
use puffin_interpreter::{find_default_python, find_requested_python, Error};
use puffin_resolver::InMemoryIndex;
use puffin_resolver::{InMemoryIndex, OptionsBuilder};
use puffin_traits::{BuildContext, InFlight, NoBuild, SetupPyStrategy};
use crate::commands::ExitStatus;
@ -30,10 +31,21 @@ pub(crate) async fn venv(
python_request: Option<&str>,
index_locations: &IndexLocations,
seed: bool,
exclude_newer: Option<DateTime<Utc>>,
cache: &Cache,
printer: Printer,
) -> Result<ExitStatus> {
match venv_impl(path, python_request, index_locations, seed, cache, printer).await {
match venv_impl(
path,
python_request,
index_locations,
seed,
exclude_newer,
cache,
printer,
)
.await
{
Ok(status) => Ok(status),
Err(err) => {
eprint!("{err:?}");
@ -67,6 +79,7 @@ async fn venv_impl(
python_request: Option<&str>,
index_locations: &IndexLocations,
seed: bool,
exclude_newer: Option<DateTime<Utc>>,
cache: &Cache,
mut printer: Printer,
) -> miette::Result<ExitStatus> {
@ -125,6 +138,7 @@ async fn venv_impl(
let in_flight = InFlight::default();
// Prep the build context.
let options = OptionsBuilder::new().exclude_newer(exclude_newer).build();
let build_dispatch = BuildDispatch::new(
&client,
cache,
@ -137,7 +151,8 @@ async fn venv_impl(
SetupPyStrategy::default(),
&NoBuild::All,
&NoBinary::None,
);
)
.with_options(options);
// Resolve the seed packages.
let resolution = build_dispatch

View file

@ -283,16 +283,11 @@ struct PipCompileArgs {
#[arg(long, short)]
python_version: Option<PythonVersion>,
/// Try to resolve at a past time.
/// Limit candidate packages to those that were uploaded prior to the given date.
///
/// 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.
///
/// 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.
#[arg(long, value_parser = date_or_datetime)]
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and UTC dates in the same
/// format (e.g., `2006-12-02`).
#[arg(long, value_parser = date_or_datetime, hide = true)]
exclude_newer: Option<DateTime<Utc>>,
/// Include `--index-url` and `--extra-index-url` entries in the generated output file.
@ -545,15 +540,10 @@ struct PipInstallArgs {
#[clap(long)]
strict: bool,
/// Try to resolve at a past time.
/// Limit candidate packages to those that were uploaded prior to the given date.
///
/// 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.
///
/// 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.
/// Accepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and UTC dates in the same
/// format (e.g., `2006-12-02`).
#[arg(long, value_parser = date_or_datetime, hide = true)]
exclude_newer: Option<DateTime<Utc>>,
}
@ -628,6 +618,13 @@ struct VenvArgs {
/// discovered via `--find-links`.
#[clap(long, conflicts_with = "index_url", conflicts_with = "extra_index_url")]
no_index: bool,
/// 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 UTC dates in the same
/// format (e.g., `2006-12-02`).
#[arg(long, value_parser = date_or_datetime, hide = true)]
exclude_newer: Option<DateTime<Utc>>,
}
#[derive(Args)]
@ -943,6 +940,7 @@ async fn run() -> Result<ExitStatus> {
args.python.as_deref(),
&index_locations,
args.seed,
args.exclude_newer,
&cache,
printer,
)

View file

@ -1324,17 +1324,17 @@ optional-dependencies.bar = [
.arg("--extra")
.arg("foo"),
@r###"
success: false
exit_code: 2
----- stdout -----
success: false
exit_code: 2
----- stdout -----
----- stderr -----
error: the argument '--all-extras' cannot be used with '--extra <EXTRA>'
----- stderr -----
error: the argument '--all-extras' cannot be used with '--extra <EXTRA>'
Usage: puffin pip compile --cache-dir [CACHE_DIR] --exclude-newer <EXCLUDE_NEWER> --all-extras <SRC_FILE>...
Usage: puffin pip compile --cache-dir [CACHE_DIR] --all-extras <SRC_FILE>...
For more information, try '--help'.
"###
For more information, try '--help'.
"###
);
Ok(())

View file

@ -7,7 +7,7 @@ use assert_fs::prelude::*;
use puffin_fs::Normalized;
use crate::common::{create_bin_with_executables, get_bin, puffin_snapshot};
use crate::common::{create_bin_with_executables, get_bin, puffin_snapshot, EXCLUDE_NEWER};
mod common;
@ -33,6 +33,8 @@ fn create_venv() -> Result<()> {
.arg("3.12")
.arg("--cache-dir")
.arg(cache_dir.path())
.arg("--exclude-newer")
.arg(EXCLUDE_NEWER)
.env("PUFFIN_TEST_PYTHON_PATH", bin)
.current_dir(&temp_dir), @r###"
success: true
@ -71,6 +73,8 @@ fn create_venv_defaults_to_cwd() -> Result<()> {
.arg("3.12")
.arg("--cache-dir")
.arg(cache_dir.path())
.arg("--exclude-newer")
.arg(EXCLUDE_NEWER)
.env("PUFFIN_TEST_PYTHON_PATH", bin)
.current_dir(&temp_dir), @r###"
success: true
@ -111,6 +115,8 @@ fn seed() -> Result<()> {
.arg("3.12")
.arg("--cache-dir")
.arg(cache_dir.path())
.arg("--exclude-newer")
.arg(EXCLUDE_NEWER)
.env("PUFFIN_TEST_PYTHON_PATH", bin)
.current_dir(&temp_dir), @r###"
success: true
@ -120,9 +126,9 @@ fn seed() -> Result<()> {
----- stderr -----
Using Python [VERSION] interpreter at [PATH]
Creating virtualenv at: /home/ferris/project/.venv
+ setuptools==69.0.3
+ pip==24.0
+ wheel==0.42.0
+ setuptools==68.2.2
+ pip==23.3.1
+ wheel==0.41.3
"###
);
@ -146,6 +152,8 @@ fn create_venv_unknown_python_minor() -> Result<()> {
.arg("3.15")
.arg("--cache-dir")
.arg(cache_dir.path())
.arg("--exclude-newer")
.arg(EXCLUDE_NEWER)
.env("PUFFIN_TEST_PYTHON_PATH", bin)
.current_dir(&temp_dir);
if cfg!(windows) {
@ -198,6 +206,8 @@ fn create_venv_unknown_python_patch() -> Result<()> {
.arg("3.8.0")
.arg("--cache-dir")
.arg(cache_dir.path())
.arg("--exclude-newer")
.arg(EXCLUDE_NEWER)
.env("PUFFIN_TEST_PYTHON_PATH", bin)
.current_dir(&temp_dir), @r###"
success: false
@ -236,6 +246,8 @@ fn create_venv_python_patch() -> Result<()> {
.arg("3.12.1")
.arg("--cache-dir")
.arg(cache_dir.path())
.arg("--exclude-newer")
.arg(EXCLUDE_NEWER)
.env("PUFFIN_TEST_PYTHON_PATH", bin)
.current_dir(&temp_dir), @r###"
success: true