Skip to content

Commit

Permalink
Don't treat setuptools and wheel as seed packages in uv sync on P…
Browse files Browse the repository at this point in the history
…ython 3.12 (#10572)

## Summary

Closes #10566.
  • Loading branch information
charliermarsh authored Jan 13, 2025
1 parent b38d3fe commit c946e47
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
20 changes: 14 additions & 6 deletions crates/uv-installer/src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,7 @@ impl<'a> Planner<'a> {
// (2) the `--seed` argument was not passed to `uv venv`.
let seed_packages = !venv.cfg().is_ok_and(|cfg| cfg.is_uv() && !cfg.is_seed());
for dist_info in site_packages {
if seed_packages
&& matches!(
dist_info.name().as_ref(),
"pip" | "setuptools" | "wheel" | "uv"
)
{
if seed_packages && is_seed_package(&dist_info, venv) {
debug!("Preserving seed package: {dist_info}");
continue;
}
Expand All @@ -375,6 +370,19 @@ impl<'a> Planner<'a> {
}
}

/// Returns `true` if the given distribution is a seed package.
fn is_seed_package(dist_info: &InstalledDist, venv: &PythonEnvironment) -> bool {
if venv.interpreter().python_tuple() >= (3, 12) {
matches!(dist_info.name().as_ref(), "uv" | "pip")
} else {
// Include `setuptools` and `wheel` on Python <3.12.
matches!(
dist_info.name().as_ref(),
"pip" | "setuptools" | "wheel" | "uv"
)
}
}

#[derive(Debug, Default)]
pub struct Plan {
/// The distributions that are not already installed in the current environment, but are
Expand Down
12 changes: 6 additions & 6 deletions crates/uv/src/commands/venv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,17 @@ async fn venv_impl(
);

// Resolve the seed packages.
let requirements = if interpreter.python_tuple() < (3, 12) {
// Only include `setuptools` and `wheel` on Python <3.12
let requirements = if interpreter.python_tuple() >= (3, 12) {
vec![Requirement::from(
uv_pep508::Requirement::from_str("pip").unwrap(),
)]
} else {
// Include `setuptools` and `wheel` on Python <3.12.
vec![
Requirement::from(uv_pep508::Requirement::from_str("pip").unwrap()),
Requirement::from(uv_pep508::Requirement::from_str("setuptools").unwrap()),
Requirement::from(uv_pep508::Requirement::from_str("wheel").unwrap()),
]
} else {
vec![Requirement::from(
uv_pep508::Requirement::from_str("pip").unwrap(),
)]
};

let build_stack = BuildStack::default();
Expand Down

0 comments on commit c946e47

Please sign in to comment.