44use log:: { info, trace, warn} ;
55use pet_conda:: CondaLocator ;
66use pet_core:: os_environment:: { Environment , EnvironmentApi } ;
7- use pet_core:: python_environment:: PythonEnvironmentCategory ;
87use pet_core:: reporter:: Reporter ;
98use pet_core:: { Configuration , Locator } ;
109use pet_env_var_path:: get_search_paths_from_env_variables;
@@ -97,18 +96,19 @@ pub fn find_and_report_envs(
9796 s. spawn ( || {
9897 let start = std:: time:: Instant :: now ( ) ;
9998 let environment = EnvironmentApi :: new ( ) ;
100- let search_paths: Vec < PathBuf > = get_search_paths_from_env_variables ( & environment) ;
99+ let global_env_search_paths: Vec < PathBuf > =
100+ get_search_paths_from_env_variables ( & environment) ;
101101
102102 trace ! (
103103 "Searching for environments in global folders: {:?}" ,
104- search_paths
104+ global_env_search_paths
105105 ) ;
106106 find_python_environments (
107- search_paths ,
107+ global_env_search_paths . clone ( ) ,
108108 reporter,
109109 locators,
110110 false ,
111- Some ( PythonEnvironmentCategory :: GlobalPaths ) ,
111+ & global_env_search_paths ,
112112 ) ;
113113 summary. lock ( ) . unwrap ( ) . find_path_time = start. elapsed ( ) ;
114114 } ) ;
@@ -124,13 +124,21 @@ pub fn find_and_report_envs(
124124 environment_paths,
125125 ]
126126 . concat ( ) ;
127+ let global_env_search_paths: Vec < PathBuf > =
128+ get_search_paths_from_env_variables ( & environment) ;
127129
128130 trace ! (
129131 "Searching for environments in global venv folders: {:?}" ,
130132 search_paths
131133 ) ;
132134
133- find_python_environments ( search_paths, reporter, locators, false , None ) ;
135+ find_python_environments (
136+ search_paths,
137+ reporter,
138+ locators,
139+ false ,
140+ & global_env_search_paths,
141+ ) ;
134142 summary. lock ( ) . unwrap ( ) . find_global_virtual_envs_time = start. elapsed ( ) ;
135143 } ) ;
136144 // Step 4: Find in workspace folders too.
@@ -175,7 +183,7 @@ fn find_python_environments_in_workspace_folders_recursive(
175183 // Find in cwd
176184 let paths1 = paths. clone ( ) ;
177185 s. spawn ( || {
178- find_python_environments ( paths1, reporter, locators, true , None ) ;
186+ find_python_environments ( paths1, reporter, locators, true , & [ ] ) ;
179187
180188 if depth >= max_depth {
181189 return ;
@@ -233,7 +241,7 @@ fn find_python_environments(
233241 reporter : & dyn Reporter ,
234242 locators : & Arc < Vec < Arc < dyn Locator > > > ,
235243 is_workspace_folder : bool ,
236- fallback_category : Option < PythonEnvironmentCategory > ,
244+ global_env_search_paths : & [ PathBuf ] ,
237245) {
238246 if paths. is_empty ( ) {
239247 return ;
@@ -249,7 +257,7 @@ fn find_python_environments(
249257 & locators,
250258 reporter,
251259 is_workspace_folder,
252- fallback_category ,
260+ global_env_search_paths ,
253261 ) ;
254262 } ) ;
255263 }
@@ -261,7 +269,7 @@ fn find_python_environments_in_paths_with_locators(
261269 locators : & Arc < Vec < Arc < dyn Locator > > > ,
262270 reporter : & dyn Reporter ,
263271 is_workspace_folder : bool ,
264- fallback_category : Option < PythonEnvironmentCategory > ,
272+ global_env_search_paths : & [ PathBuf ] ,
265273) {
266274 let executables = if is_workspace_folder {
267275 // If we're in a workspace folder, then we only need to look for bin/python or bin/python.exe
@@ -291,20 +299,25 @@ fn find_python_environments_in_paths_with_locators(
291299 . collect :: < Vec < PathBuf > > ( )
292300 } ;
293301
294- identify_python_executables_using_locators ( executables, locators, reporter, fallback_category) ;
302+ identify_python_executables_using_locators (
303+ executables,
304+ locators,
305+ reporter,
306+ global_env_search_paths,
307+ ) ;
295308}
296309
297310fn identify_python_executables_using_locators (
298311 executables : Vec < PathBuf > ,
299312 locators : & Arc < Vec < Arc < dyn Locator > > > ,
300313 reporter : & dyn Reporter ,
301- fallback_category : Option < PythonEnvironmentCategory > ,
314+ global_env_search_paths : & [ PathBuf ] ,
302315) {
303316 for exe in executables. into_iter ( ) {
304317 let executable = exe. clone ( ) ;
305318 let env = PythonEnv :: new ( exe. to_owned ( ) , None , None ) ;
306319 if let Some ( env) =
307- identify_python_environment_using_locators ( & env, locators, fallback_category )
320+ identify_python_environment_using_locators ( & env, locators, global_env_search_paths )
308321 {
309322 reporter. report_environment ( & env) ;
310323 if let Some ( manager) = env. manager {
0 commit comments