Avoid removing seed packages for uv venv --seed environments (#7410)

## Summary

Closes https://github.com/astral-sh/uv/issues/7121.
This commit is contained in:
Charlie Marsh
2024-09-15 18:27:52 -04:00
committed by GitHub
parent 8d4b6ca971
commit f895c40a4e
12 changed files with 115 additions and 14 deletions
+3 -3
View File
@@ -412,9 +412,9 @@ impl<'a> Planner<'a> {
// Remove any unnecessary packages.
if site_packages.any() {
// If uv created the virtual environment, then remove all packages, regardless of
// whether they're considered "seed" packages.
let seed_packages = !venv.cfg().is_ok_and(|cfg| cfg.is_uv());
// Retain seed packages unless: (1) the virtual environment was created by uv and
// (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!(