File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,7 @@ pub fn find_executables<T: AsRef<Path>>(env_path: T) -> Vec<PathBuf> {
180180 python_executables
181181}
182182
183- fn is_python_executable_name ( exe : & Path ) -> bool {
183+ pub fn is_python_executable_name ( exe : & Path ) -> bool {
184184 let name = exe
185185 . file_name ( )
186186 . unwrap_or_default ( )
Original file line number Diff line number Diff line change @@ -12,7 +12,10 @@ use pet_core::{
1212 Locator ,
1313} ;
1414use pet_env_var_path:: get_search_paths_from_env_variables;
15- use pet_python_utils:: { env:: ResolvedPythonEnv , executable:: find_executable} ;
15+ use pet_python_utils:: {
16+ env:: ResolvedPythonEnv ,
17+ executable:: { find_executable, is_python_executable_name} ,
18+ } ;
1619
1720use crate :: locators:: identify_python_environment_using_locators;
1821
@@ -49,6 +52,16 @@ pub fn resolve_environment(
4952 executable
5053 ) ;
5154 }
55+ // Validate that the executable filename looks like a Python executable
56+ // before proceeding with the locator chain or spawning.
57+ if executable. is_file ( ) && !is_python_executable_name ( & executable) {
58+ warn ! (
59+ "Path {:?} does not look like a Python executable, skipping resolve" ,
60+ executable
61+ ) ;
62+ return None ;
63+ }
64+
5265 // First check if this is a known environment
5366 let env = PythonEnv :: new ( executable. to_owned ( ) , None , None ) ;
5467 trace ! (
You can’t perform that action at this time.
0 commit comments