@@ -20,8 +20,12 @@ pub fn from_creator_for_virtual_env(prefix: &Path) -> Option<String> {
2020 if let Some ( version) = Headers :: get_version ( prefix) {
2121 return Some ( version) ;
2222 }
23- let bin = if cfg ! ( windows) { "Scripts" } else { "bin" } ;
24- let executable = & prefix. join ( bin) . join ( "python" ) ;
23+ let mut bin = "bin" ;
24+ let mut executable = prefix. join ( bin) . join ( "python" ) ;
25+ if cfg ! ( windows) && !executable. exists ( ) {
26+ bin = "Scripts" ;
27+ executable = prefix. join ( bin) . join ( "python.exe" ) ;
28+ }
2529
2630 // Determine who created this virtual environment, and get version of that environment.
2731 // Note, its unlikely conda envs were used to create virtual envs, thats a very bad idea (known to cause issues and not reccomended).
@@ -67,8 +71,14 @@ pub fn from_prefix(prefix: &Path) -> Option<String> {
6771/// Using this information its possible to determine the version of the Python environment used to create the env.
6872fn get_python_exe_used_to_create_venv < T : AsRef < Path > > ( executable : T ) -> Option < PathBuf > {
6973 let parent_dir = executable. as_ref ( ) . parent ( ) ?;
70- let bin = if cfg ! ( windows) { "Scripts" } else { "bin" } ;
71- if parent_dir. file_name ( ) . unwrap_or_default ( ) != bin {
74+ if cfg ! ( windows) {
75+ if parent_dir. file_name ( ) . unwrap_or_default ( ) != "bin"
76+ && parent_dir. file_name ( ) . unwrap_or_default ( ) != "Scripts"
77+ {
78+ warn ! ( "Attempted to determine creator of virtual environment, but the env executable ({:?}) is not in the expected location." , executable. as_ref( ) ) ;
79+ return None ;
80+ }
81+ } else if parent_dir. file_name ( ) . unwrap_or_default ( ) != "bin" {
7282 warn ! ( "Attempted to determine creator of virtual environment, but the env executable ({:?}) is not in the expected location." , executable. as_ref( ) ) ;
7383 return None ;
7484 }
@@ -93,7 +103,11 @@ fn get_version_from_pyvenv_if_pyvenv_cfg_and_exe_created_same_time(
93103 return None ;
94104 }
95105 let cfg_metadata = pyvenv_cfg. metadata ( ) . ok ( ) ?;
96- let exe_metadata = prefix. join ( "Scripts" ) . join ( "python.exe" ) . metadata ( ) . ok ( ) ?;
106+ let mut bin = prefix. join ( "Scripts" ) ;
107+ if !bin. exists ( ) {
108+ bin = prefix. join ( "bin" ) ;
109+ }
110+ let exe_metadata = bin. join ( "python.exe" ) . metadata ( ) . ok ( ) ?;
97111 let cfg_modified = cfg_metadata
98112 . modified ( )
99113 . ok ( ) ?
0 commit comments