Skip to content
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

Remove setuptools & wheel from seed packages (#1602) #1613

Merged
Merged
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
14 changes: 9 additions & 5 deletions crates/uv/src/commands/venv.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::fmt::Write;
use std::path::Path;
use std::str::FromStr;
use std::vec;

use anstream::eprint;
use anyhow::Result;
Expand Down Expand Up @@ -160,12 +161,15 @@ async fn venv_impl(
.with_options(OptionsBuilder::new().exclude_newer(exclude_newer).build());

// Resolve the seed packages.
let mut requirements = vec![Requirement::from_str("pip").unwrap()];

// Only include `setuptools` and `wheel` on Python <3.12
if interpreter.python_tuple() < (3, 12) {
requirements.push(Requirement::from_str("setuptools").unwrap());
requirements.push(Requirement::from_str("wheel").unwrap());
}
let resolution = build_dispatch
.resolve(&[
Requirement::from_str("wheel").unwrap(),
Requirement::from_str("pip").unwrap(),
Requirement::from_str("setuptools").unwrap(),
])
.resolve(&requirements)
.await
.map_err(VenvError::Seed)?;

Expand Down
44 changes: 44 additions & 0 deletions crates/uv/tests/venv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,50 @@ fn seed() -> Result<()> {
exit_code: 0
----- stdout -----
----- stderr -----
Using Python [VERSION] interpreter at [PATH]
Creating virtualenv at: /home/ferris/project/.venv
+ pip==23.3.1
"###
);

venv.assert(predicates::path::is_dir());

Ok(())
}

#[test]
fn seed_older_python_version() -> Result<()> {
let temp_dir = assert_fs::TempDir::new()?;
let cache_dir = assert_fs::TempDir::new()?;
let bin = create_bin_with_executables(&temp_dir, &["3.10"]).expect("Failed to create bin dir");
let venv = temp_dir.child(".venv");

let filter_venv = regex::escape(&venv.normalized_display().to_string());
let filters = &[
(
r"Using Python 3\.\d+\.\d+ interpreter at .+",
"Using Python [VERSION] interpreter at [PATH]",
),
(&filter_venv, "/home/ferris/project/.venv"),
];
uv_snapshot!(filters, Command::new(get_bin())
.arg("venv")
.arg(venv.as_os_str())
.arg("--seed")
.arg("--python")
.arg("3.10")
.arg("--cache-dir")
.arg(cache_dir.path())
.arg("--exclude-newer")
.arg(EXCLUDE_NEWER)
.env("UV_NO_WRAP", "1")
.env("UV_TEST_PYTHON_PATH", bin)
.current_dir(&temp_dir), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Using Python [VERSION] interpreter at [PATH]
Creating virtualenv at: /home/ferris/project/.venv
Expand Down