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

Don't treat setuptools and wheel as seed packages in uv sync on Python 3.12 #10572

Merged
merged 1 commit into from
Jan 13, 2025
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
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
Loading