Invert the logic for determining if a path is a base conda environment (#15679)
Closes https://github.com/astral-sh/uv/issues/15604 The previous logic does not match the discussion in the original issue about this feature, nor does it match the comment for the function. I'm confused because I know this logic is working for some people? I'm consequently a little wary of making this change. I'm following up with some additional changes that should ensure this is robust, e.g., #15680
This commit is contained in:
+35
-31
@@ -1200,7 +1200,7 @@ mod tests {
|
||||
"We should allow the active conda python"
|
||||
);
|
||||
|
||||
let baseenv = context.tempdir.child("base");
|
||||
let baseenv = context.tempdir.child("conda");
|
||||
TestContext::mock_conda_prefix(&baseenv, "3.12.1")?;
|
||||
|
||||
// But not if it's a base environment
|
||||
@@ -1226,21 +1226,23 @@ mod tests {
|
||||
);
|
||||
|
||||
// Unless, system interpreters are included...
|
||||
let python = context.run_with_vars(
|
||||
&[
|
||||
("CONDA_PREFIX", Some(baseenv.as_os_str())),
|
||||
("CONDA_DEFAULT_ENV", Some(&OsString::from("base"))),
|
||||
],
|
||||
|| {
|
||||
find_python_installation(
|
||||
&PythonRequest::Default,
|
||||
EnvironmentPreference::OnlySystem,
|
||||
PythonPreference::OnlySystem,
|
||||
&context.cache,
|
||||
Preview::default(),
|
||||
)
|
||||
},
|
||||
)??;
|
||||
let python = context
|
||||
.run_with_vars(
|
||||
&[
|
||||
("CONDA_PREFIX", Some(baseenv.as_os_str())),
|
||||
("CONDA_DEFAULT_ENV", Some(&OsString::from("base"))),
|
||||
],
|
||||
|| {
|
||||
find_python_installation(
|
||||
&PythonRequest::Default,
|
||||
EnvironmentPreference::OnlySystem,
|
||||
PythonPreference::OnlySystem,
|
||||
&context.cache,
|
||||
Preview::default(),
|
||||
)
|
||||
},
|
||||
)?
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
python.interpreter().python_full_version().to_string(),
|
||||
@@ -1249,21 +1251,23 @@ mod tests {
|
||||
);
|
||||
|
||||
// If the environment name doesn't match the default, we should not treat it as system
|
||||
let python = context.run_with_vars(
|
||||
&[
|
||||
("CONDA_PREFIX", Some(condaenv.as_os_str())),
|
||||
("CONDA_DEFAULT_ENV", Some(&OsString::from("base"))),
|
||||
],
|
||||
|| {
|
||||
find_python_installation(
|
||||
&PythonRequest::Default,
|
||||
EnvironmentPreference::OnlyVirtual,
|
||||
PythonPreference::OnlySystem,
|
||||
&context.cache,
|
||||
Preview::default(),
|
||||
)
|
||||
},
|
||||
)??;
|
||||
let python = context
|
||||
.run_with_vars(
|
||||
&[
|
||||
("CONDA_PREFIX", Some(condaenv.as_os_str())),
|
||||
("CONDA_DEFAULT_ENV", Some(&OsString::from("condaenv"))),
|
||||
],
|
||||
|| {
|
||||
find_python_installation(
|
||||
&PythonRequest::Default,
|
||||
EnvironmentPreference::OnlyVirtual,
|
||||
PythonPreference::OnlySystem,
|
||||
&context.cache,
|
||||
Preview::default(),
|
||||
)
|
||||
},
|
||||
)?
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
python.interpreter().python_full_version().to_string(),
|
||||
|
||||
Reference in New Issue
Block a user