File tree Expand file tree Collapse file tree
pet-virtualenvwrapper/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// Copyright (c) Microsoft Corporation.
22// Licensed under the MIT License.
33
4- use std:: path:: Path ;
4+ use std:: path:: { Path , PathBuf } ;
55
66use pet_core:: {
77 env:: PythonEnv ,
@@ -40,6 +40,19 @@ pub fn is_virtualenv_dir(path: &Path) -> bool {
4040 path = path. join ( "bin" ) ;
4141 }
4242 }
43+
44+ // Never consider global locations to be virtualenvs
45+ // in case there is a false positive match from checks below.
46+ if [
47+ PathBuf :: from ( r"/bin" ) ,
48+ PathBuf :: from ( r"/usr/bin" ) ,
49+ PathBuf :: from ( r"/usr/local/bin" ) ,
50+ ]
51+ . contains ( & path)
52+ {
53+ return false ;
54+ }
55+
4356 // Check if there are any activate.* files in the same directory as the interpreter.
4457 //
4558 // env
@@ -62,7 +75,7 @@ pub fn is_virtualenv_dir(path: &Path) -> bool {
6275 . unwrap_or_default ( )
6376 . to_str ( )
6477 . unwrap_or_default ( )
65- . starts_with ( "activate" )
78+ . starts_with ( "activate. " )
6679 {
6780 return true ;
6881 }
Original file line number Diff line number Diff line change @@ -49,12 +49,15 @@ impl Locator for VirtualEnvWrapper {
4949 } ,
5050 } ;
5151 let mut symlinks = vec ! [ ] ;
52+ let mut name = None ;
5253 if let Some ( ref prefix) = env. prefix {
5354 symlinks. append ( & mut find_executables ( prefix) ) ;
55+ name = prefix. file_name ( ) . and_then ( |f| f. to_str ( ) ) ;
5456 }
5557
5658 Some (
5759 PythonEnvironmentBuilder :: new ( Some ( PythonEnvironmentKind :: VirtualEnvWrapper ) )
60+ . name ( name. map ( String :: from) )
5861 . executable ( Some ( env. executable . clone ( ) ) )
5962 . version ( version)
6063 . prefix ( env. prefix . clone ( ) )
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ version = "0.1.0"
44edition = " 2021"
55
66[target .'cfg(windows)' .dependencies ]
7- winreg = " 0.52 .0"
7+ winreg = " 0.55 .0"
88
99[target .'cfg(target_os = "windows")' .dependencies ]
1010msvc_spectre_libs = { version = " 0.1.1" , features = [" error" ] }
@@ -18,4 +18,4 @@ pet-fs = { path = "../pet-fs" }
1818pet-conda = { path = " ../pet-conda" }
1919log = " 0.4.21"
2020lazy_static = " 1.4.0"
21- regex = " 1.10.4"
21+ regex = " 1.10.4"
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ version = "0.1.0"
44edition = " 2021"
55
66[target .'cfg(windows)' .dependencies ]
7- winreg = " 0.52 .0"
7+ winreg = " 0.55 .0"
88
99[target .'cfg(target_os = "windows")' .dependencies ]
1010msvc_spectre_libs = { version = " 0.1.1" , features = [" error" ] }
Original file line number Diff line number Diff line change @@ -161,6 +161,7 @@ fn check_if_virtualenvwrapper_exists() {
161161 |env| env. kind == Some ( PythonEnvironmentKind :: VirtualEnvWrapper )
162162 && env. executable. is_some( )
163163 && env. prefix. is_some( )
164+ && env. name == Some ( "venv_wrapper_env1" . to_string( ) )
164165 && env
165166 . executable
166167 . clone( )
You can’t perform that action at this time.
0 commit comments