File tree Expand file tree Collapse file tree 4 files changed +34
-14
lines changed
pet-virtualenvwrapper/src Expand file tree Collapse file tree 4 files changed +34
-14
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright (c) Microsoft Corporation.
2
2
// Licensed under the MIT License.
3
3
4
- use std:: {
5
- fs,
6
- path:: { Path , PathBuf } ,
7
- } ;
4
+ use std:: path:: { Path , PathBuf } ;
8
5
9
6
// Similar to fs::canonicalize, but ignores UNC paths and returns the path as is (for windows).
10
7
pub fn normalize < P : AsRef < Path > > ( path : P ) -> PathBuf {
11
8
// On unix do not use canonicalize, results in weird issues with homebrew paths
12
- if cfg ! ( unix) {
13
- return path. as_ref ( ) . to_path_buf ( ) ;
14
- }
9
+ #[ cfg( unix) ]
10
+ return path. as_ref ( ) . to_path_buf ( ) ;
11
+
12
+ #[ cfg( windows) ]
13
+ use std:: fs;
15
14
15
+ #[ cfg( windows) ]
16
16
if let Ok ( resolved) = fs:: canonicalize ( & path) {
17
17
if cfg ! ( unix) {
18
18
return resolved;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use pet_core::{
5
5
python_environment:: { PythonEnvironment , PythonEnvironmentBuilder , PythonEnvironmentCategory } ,
6
6
Locator , LocatorResult ,
7
7
} ;
8
- use pet_utils:: { env:: PythonEnv , pyvenv_cfg:: PyVenvCfg } ;
8
+ use pet_utils:: { env:: PythonEnv , headers :: Headers , pyvenv_cfg:: PyVenvCfg } ;
9
9
10
10
fn is_venv_internal ( env : & PythonEnv ) -> Option < bool > {
11
11
// env path cannot be empty.
@@ -40,12 +40,18 @@ impl Locator for Venv {
40
40
if let Some ( filename) = & env. prefix {
41
41
name = filename. to_str ( ) . map ( |f| f. to_string ( ) ) ;
42
42
}
43
-
43
+ let version = match env. version {
44
+ Some ( ref v) => Some ( v. clone ( ) ) ,
45
+ None => match & env. prefix {
46
+ Some ( prefix) => Headers :: get_version ( prefix) ,
47
+ None => None ,
48
+ } ,
49
+ } ;
44
50
Some (
45
51
PythonEnvironmentBuilder :: new ( PythonEnvironmentCategory :: Venv )
46
52
. name ( name)
47
53
. executable ( Some ( env. executable . clone ( ) ) )
48
- . version ( env . version . clone ( ) )
54
+ . version ( version)
49
55
. prefix ( env. prefix . clone ( ) )
50
56
. build ( ) ,
51
57
)
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use pet_core::{
7
7
python_environment:: { PythonEnvironment , PythonEnvironmentBuilder , PythonEnvironmentCategory } ,
8
8
Locator , LocatorResult ,
9
9
} ;
10
- use pet_utils:: env:: PythonEnv ;
10
+ use pet_utils:: { env:: PythonEnv , headers :: Headers } ;
11
11
12
12
pub fn is_virtualenv ( env : & PythonEnv ) -> bool {
13
13
if env. prefix . is_none ( ) {
@@ -70,12 +70,19 @@ impl Locator for VirtualEnv {
70
70
if let Some ( filename) = & env. prefix {
71
71
name = filename. to_str ( ) . map ( |f| f. to_string ( ) ) ;
72
72
}
73
+ let version = match env. version {
74
+ Some ( ref v) => Some ( v. clone ( ) ) ,
75
+ None => match & env. prefix {
76
+ Some ( prefix) => Headers :: get_version ( prefix) ,
77
+ None => None ,
78
+ } ,
79
+ } ;
73
80
74
81
Some (
75
82
PythonEnvironmentBuilder :: new ( PythonEnvironmentCategory :: VirtualEnv )
76
83
. name ( name)
77
84
. executable ( Some ( env. executable . clone ( ) ) )
78
- . version ( env . version . clone ( ) )
85
+ . version ( version)
79
86
. prefix ( env. prefix . clone ( ) )
80
87
. build ( ) ,
81
88
)
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use pet_core::{
9
9
python_environment:: { PythonEnvironment , PythonEnvironmentBuilder , PythonEnvironmentCategory } ,
10
10
Locator , LocatorResult ,
11
11
} ;
12
- use pet_utils:: env:: PythonEnv ;
12
+ use pet_utils:: { env:: PythonEnv , headers :: Headers } ;
13
13
14
14
mod env_variables;
15
15
mod environment_locations;
@@ -36,12 +36,19 @@ impl Locator for VirtualEnvWrapper {
36
36
if let Some ( filename) = & env. prefix {
37
37
name = filename. to_str ( ) . map ( |f| f. to_string ( ) ) ;
38
38
}
39
+ let version = match env. version {
40
+ Some ( ref v) => Some ( v. clone ( ) ) ,
41
+ None => match & env. prefix {
42
+ Some ( prefix) => Headers :: get_version ( prefix) ,
43
+ None => None ,
44
+ } ,
45
+ } ;
39
46
40
47
Some (
41
48
PythonEnvironmentBuilder :: new ( PythonEnvironmentCategory :: VirtualEnvWrapper )
42
49
. name ( name)
43
50
. executable ( Some ( env. executable . clone ( ) ) )
44
- . version ( env . version . clone ( ) )
51
+ . version ( version)
45
52
. prefix ( env. prefix . clone ( ) )
46
53
. project ( get_project ( env) )
47
54
. build ( ) ,
You can’t perform that action at this time.
0 commit comments