Skip to content

Commit bdedb0a

Browse files
committed
Revised native conda locator (#23416)
**Fixes** * #23413 * & the fact that we always use the same conda exe to manage all conda envs, even if multiple are installed. * Step 1: * Look for conda install folders in known locations such as `/<user home>/miniconda3`, `<user profile>/Anaconda3` * Step 2: * For each install location identified, inspect that folder and extract the * Conda executable * All environments belonging to that conda installation * Step 3: * Old approach, * 1. find any conda in sys path or other locations and find conda installation via that mechanism * 2. Get all envs from environments.txt file (any remaining conda envs not discovered in 1 & 2 will be discoverred here and use some the global conda exe) Once we have step 1 and 2, I do not expect anything new to show up in step 3, Even if users install conda into some custom locations (the solution would be to run step 1 with the custom location provided by user in settings.json file) **How to find environments?** * Look in the `envs` folder of the conda installation * Look at the entries in the `environments.txt` file * Look at the `env_dirs` in the `.condarc` file With these two, we should be able to eliminate the need to ever spawn conda to get the env directories. **How do we know whether a conda environment belongs to a specific conda installation** * If it is in the `envs` sub directory of the conda installation * Else, have a look at `<env folder>/conda-meta/history` file to look at the conda installation that was used to create this environment
1 parent 50fd008 commit bdedb0a

32 files changed

+1237
-301
lines changed

native_locator/src/common_python.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Locator for PythonOnPath<'_> {
5050
})
5151
}
5252

53-
fn find(&self) -> Option<LocatorResult> {
53+
fn find(&mut self) -> Option<LocatorResult> {
5454
let paths = self.environment.get_env_var("PATH".to_string())?;
5555
let bin = if cfg!(windows) {
5656
"python.exe"

0 commit comments

Comments
 (0)