@@ -10,6 +10,9 @@ import { PythonEnvsChangedEvent } from '../../watcher';
10
10
import { createDeferred } from '../../../../common/utils/async' ;
11
11
import { PythonEnvKind , PythonVersion } from '../../info' ;
12
12
import { Conda } from '../../../common/environmentManagers/conda' ;
13
+ import { traceError } from '../../../../logging' ;
14
+ import type { KnownEnvironmentTools } from '../../../../api/types' ;
15
+ import { setPyEnvBinary } from '../../../common/environmentManagers/pyenv' ;
13
16
14
17
const NATIVE_LOCATOR = isWindows ( )
15
18
? path . join ( EXTENSION_ROOT_DIR , 'native_locator' , 'bin' , 'python-finder.exe' )
@@ -25,15 +28,38 @@ interface NativeEnvInfo {
25
28
}
26
29
27
30
interface EnvManager {
31
+ tool : string ;
28
32
executablePath : string [ ] ;
29
33
version ?: string ;
30
34
}
31
35
32
36
function categoryToKind ( category : string ) : PythonEnvKind {
33
- if ( category === 'conda' ) {
34
- return PythonEnvKind . Conda ;
37
+ switch ( category . toLowerCase ( ) ) {
38
+ case 'conda' :
39
+ return PythonEnvKind . Conda ;
40
+ case 'system' :
41
+ return PythonEnvKind . System ;
42
+ case 'pyenv' :
43
+ return PythonEnvKind . Pyenv ;
44
+ case 'windowsstore' :
45
+ return PythonEnvKind . MicrosoftStore ;
46
+ default : {
47
+ traceError ( `Unknown Python Environment category '${ category } ' from Native Locator.` ) ;
48
+ return PythonEnvKind . Unknown ;
49
+ }
50
+ }
51
+ }
52
+ function toolToKnownEnvironmentTool ( tool : string ) : KnownEnvironmentTools {
53
+ switch ( tool . toLowerCase ( ) ) {
54
+ case 'conda' :
55
+ return 'Conda' ;
56
+ case 'pyenv' :
57
+ return 'Pyenv' ;
58
+ default : {
59
+ traceError ( `Unknown Python Tool '${ tool } ' from Native Locator.` ) ;
60
+ return 'Unknown' ;
61
+ }
35
62
}
36
- return PythonEnvKind . Unknown ;
37
63
}
38
64
39
65
function parseVersion ( version ?: string ) : PythonVersion | undefined {
@@ -92,7 +118,19 @@ export class NativeLocator implements ILocator<BasicEnvInfo>, IDisposable {
92
118
} ) ;
93
119
} ) ;
94
120
connection . onNotification ( 'envManager' , ( data : EnvManager ) => {
95
- Conda . setConda ( data . executablePath [ 0 ] ) ;
121
+ switch ( toolToKnownEnvironmentTool ( data . tool ) ) {
122
+ case 'Conda' : {
123
+ Conda . setConda ( data . executablePath [ 0 ] ) ;
124
+ break ;
125
+ }
126
+ case 'Pyenv' : {
127
+ setPyEnvBinary ( data . executablePath [ 0 ] ) ;
128
+ break ;
129
+ }
130
+ default : {
131
+ break ;
132
+ }
133
+ }
96
134
} ) ;
97
135
connection . onNotification ( 'exit' , ( ) => {
98
136
deferred . resolve ( ) ;
0 commit comments