@@ -10,13 +10,8 @@ import { isWindows } from '../../../../common/platform/platformService';
10
10
import { EXTENSION_ROOT_DIR } from '../../../../constants' ;
11
11
import { createDeferred , createDeferredFrom } from '../../../../common/utils/async' ;
12
12
import { DisposableBase , DisposableStore } from '../../../../common/utils/resourceLifecycle' ;
13
- import { DEFAULT_INTERPRETER_PATH_SETTING_KEY } from '../lowLevel/customWorkspaceLocator' ;
14
13
import { noop } from '../../../../common/utils/misc' ;
15
- import {
16
- getConfiguration ,
17
- getWorkspaceFolderPaths ,
18
- getWorkspaceFolders ,
19
- } from '../../../../common/vscodeApis/workspaceApis' ;
14
+ import { getConfiguration , getWorkspaceFolderPaths } from '../../../../common/vscodeApis/workspaceApis' ;
20
15
import { CONDAPATH_SETTING_KEY } from '../../../common/environmentManagers/conda' ;
21
16
import { VENVFOLDERS_SETTING_KEY , VENVPATH_SETTING_KEY } from '../lowLevel/customVirtualEnvLocator' ;
22
17
import { getUserHomeDir } from '../../../../common/utils/platform' ;
@@ -76,14 +71,11 @@ class NativeGlobalPythonFinderImpl extends DisposableBase implements NativeGloba
76
71
}
77
72
78
73
public async resolve ( executable : string ) : Promise < NativeEnvInfo > {
79
- const { environment, duration } = await this . connection . sendRequest < {
80
- duration : number ;
81
- environment : NativeEnvInfo ;
82
- } > ( 'resolve' , {
74
+ const environment = await this . connection . sendRequest < NativeEnvInfo > ( 'resolve' , {
83
75
executable,
84
76
} ) ;
85
77
86
- this . outputChannel . info ( `Resolved Python Environment ${ environment . executable } in ${ duration } ms ` ) ;
78
+ this . outputChannel . info ( `Resolved Python Environment ${ environment . executable } ` ) ;
87
79
return environment ;
88
80
}
89
81
@@ -93,30 +85,29 @@ class NativeGlobalPythonFinderImpl extends DisposableBase implements NativeGloba
93
85
return PythonEnvKind . Conda ;
94
86
case 'system' :
95
87
case 'homebrew' :
96
- case 'mac-python-org ' :
97
- case 'mac-command-line-tools ' :
98
- case 'mac-xcode ' :
99
- case 'windows-registry ' :
100
- case 'linux-global ' :
88
+ case 'macpythonorg ' :
89
+ case 'maccommandlinetools ' :
90
+ case 'macxcode ' :
91
+ case 'windowsregistry ' :
92
+ case 'linuxglobal ' :
101
93
return PythonEnvKind . System ;
102
- case 'global-paths ' :
94
+ case 'globalpaths ' :
103
95
return PythonEnvKind . OtherGlobal ;
104
96
case 'pyenv' :
105
- case 'pyenv-other' :
106
97
return PythonEnvKind . Pyenv ;
107
98
case 'poetry' :
108
99
return PythonEnvKind . Poetry ;
109
100
case 'pipenv' :
110
101
return PythonEnvKind . Pipenv ;
111
- case 'pyenv-virtualenv ' :
102
+ case 'pyenvvirtualenv ' :
112
103
return PythonEnvKind . VirtualEnv ;
113
104
case 'venv' :
114
105
return PythonEnvKind . Venv ;
115
106
case 'virtualenv' :
116
107
return PythonEnvKind . VirtualEnv ;
117
108
case 'virtualenvwrapper' :
118
109
return PythonEnvKind . VirtualEnvWrapper ;
119
- case 'windows-store ' :
110
+ case 'windowsstore ' :
120
111
return PythonEnvKind . MicrosoftStore ;
121
112
case 'unknown' :
122
113
return PythonEnvKind . Unknown ;
@@ -309,11 +300,11 @@ class NativeGlobalPythonFinderImpl extends DisposableBase implements NativeGloba
309
300
// HACK = TEMPORARY WORK AROUND, TO GET STUFF WORKING
310
301
// HACK = TEMPORARY WORK AROUND, TO GET STUFF WORKING
311
302
const promise = this . connection
312
- . sendRequest < { duration : number ; environment : NativeEnvInfo } > ( 'resolve' , {
303
+ . sendRequest < NativeEnvInfo > ( 'resolve' , {
313
304
executable : data . executable ,
314
305
} )
315
- . then ( ( { environment, duration } ) => {
316
- this . outputChannel . info ( `Resolved ${ environment . executable } in ${ duration } ms ` ) ;
306
+ . then ( ( environment ) => {
307
+ this . outputChannel . info ( `Resolved ${ environment . executable } ` ) ;
317
308
this . outputChannel . trace ( `Environment resolved:\n ${ JSON . stringify ( data , undefined , 4 ) } ` ) ;
318
309
discovered . fire ( environment ) ;
319
310
} )
@@ -326,7 +317,20 @@ class NativeGlobalPythonFinderImpl extends DisposableBase implements NativeGloba
326
317
) ;
327
318
328
319
trackPromiseAndNotifyOnCompletion (
329
- this . sendRefreshRequest ( )
320
+ this . connection
321
+ . sendRequest < { duration : number } > (
322
+ 'refresh' ,
323
+ // Send configuration information to the Python finder.
324
+ {
325
+ // This has a special meaning in locator, its lot a low priority
326
+ // as we treat this as workspace folders that can contain a large number of files.
327
+ project_directories : getWorkspaceFolderPaths ( ) ,
328
+ // We do not want to mix this with `search_paths`
329
+ environment_directories : getCustomVirtualEnvDirs ( ) ,
330
+ conda_executable : getPythonSettingAndUntildify < string > ( CONDAPATH_SETTING_KEY ) ,
331
+ poetry_executable : getPythonSettingAndUntildify < string > ( 'poetryPath' ) ,
332
+ } ,
333
+ )
330
334
. then ( ( { duration } ) => this . outputChannel . info ( `Refresh completed in ${ duration } ms` ) )
331
335
. catch ( ( ex ) => this . outputChannel . error ( 'Refresh error' , ex ) ) ,
332
336
) ;
@@ -337,47 +341,12 @@ class NativeGlobalPythonFinderImpl extends DisposableBase implements NativeGloba
337
341
discovered : discovered . event ,
338
342
} ;
339
343
}
340
-
341
- private sendRefreshRequest ( ) {
342
- const pythonPathSettings = ( getWorkspaceFolders ( ) || [ ] ) . map ( ( w ) =>
343
- getPythonSettingAndUntildify < string > ( DEFAULT_INTERPRETER_PATH_SETTING_KEY , w . uri ) ,
344
- ) ;
345
- pythonPathSettings . push ( getPythonSettingAndUntildify < string > ( DEFAULT_INTERPRETER_PATH_SETTING_KEY ) ) ;
346
- // We can have multiple workspaces, each with its own setting.
347
- const pythonSettings = Array . from (
348
- new Set (
349
- pythonPathSettings
350
- . filter ( ( item ) => ! ! item )
351
- // We only want the parent directories.
352
- . map ( ( p ) => path . dirname ( p ! ) )
353
- /// If setting value is 'python', then `path.dirname('python')` will yield `.`
354
- . filter ( ( item ) => item !== '.' ) ,
355
- ) ,
356
- ) ;
357
-
358
- return this . connection . sendRequest < { duration : number } > (
359
- 'refresh' ,
360
- // Send configuration information to the Python finder.
361
- {
362
- // This has a special meaning in locator, its lot a low priority
363
- // as we treat this as workspace folders that can contain a large number of files.
364
- search_paths : getWorkspaceFolderPaths ( ) ,
365
- // Also send the python paths that are configured in the settings.
366
- python_interpreter_paths : pythonSettings ,
367
- // We do not want to mix this with `search_paths`
368
- virtual_env_paths : getCustomVirtualEnvDirs ( ) ,
369
- conda_executable : getPythonSettingAndUntildify < string > ( CONDAPATH_SETTING_KEY ) ,
370
- poetry_executable : getPythonSettingAndUntildify < string > ( 'poetryPath' ) ,
371
- pipenv_executable : getPythonSettingAndUntildify < string > ( 'pipenvPath' ) ,
372
- } ,
373
- ) ;
374
- }
375
344
}
376
345
377
346
/**
378
347
* Gets all custom virtual environment locations to look for environments.
379
348
*/
380
- async function getCustomVirtualEnvDirs ( ) : Promise < string [ ] > {
349
+ function getCustomVirtualEnvDirs ( ) : string [ ] {
381
350
const venvDirs : string [ ] = [ ] ;
382
351
const venvPath = getPythonSettingAndUntildify < string > ( VENVPATH_SETTING_KEY ) ;
383
352
if ( venvPath ) {
0 commit comments