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:
@@ -46,6 +46,7 @@ impl Prompt {
|
||||
}
|
||||
|
||||
/// Create a virtualenv.
|
||||
#[allow(clippy::fn_params_excessive_bools)]
|
||||
pub fn create_venv(
|
||||
location: &Path,
|
||||
interpreter: Interpreter,
|
||||
@@ -53,6 +54,7 @@ pub fn create_venv(
|
||||
system_site_packages: bool,
|
||||
allow_existing: bool,
|
||||
relocatable: bool,
|
||||
seed: bool,
|
||||
) -> Result<PythonEnvironment, Error> {
|
||||
// Create the virtualenv at the given location.
|
||||
let virtualenv = virtualenv::create(
|
||||
@@ -62,6 +64,7 @@ pub fn create_venv(
|
||||
system_site_packages,
|
||||
allow_existing,
|
||||
relocatable,
|
||||
seed,
|
||||
)?;
|
||||
|
||||
// Create the corresponding `PythonEnvironment`.
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user