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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 115 additions and 14 deletions

View file

@ -43,6 +43,7 @@ fn write_cfg(f: &mut impl Write, data: &[(String, String)]) -> io::Result<()> {
}
/// Create a [`VirtualEnvironment`] at the given location.
#[allow(clippy::fn_params_excessive_bools)]
pub(crate) fn create(
location: &Path,
interpreter: &Interpreter,
@ -50,6 +51,7 @@ pub(crate) fn create(
system_site_packages: bool,
allow_existing: bool,
relocatable: bool,
seed: bool,
) -> Result<VirtualEnvironment, Error> {
// Determine the base Python executable; that is, the Python executable that should be
// considered the "base" for the virtual environment. This is typically the Python executable
@ -350,16 +352,16 @@ pub(crate) fn create(
"false".to_string()
},
),
(
"relocatable".to_string(),
if relocatable {
"true".to_string()
} else {
"false".to_string()
},
),
];
if relocatable {
pyvenv_cfg_data.push(("relocatable".to_string(), "true".to_string()));
}
if seed {
pyvenv_cfg_data.push(("seed".to_string(), "true".to_string()));
}
if let Some(prompt) = prompt {
pyvenv_cfg_data.push(("prompt".to_string(), prompt));
}