@@ -32,6 +32,7 @@ import { showErrorMessage } from '../../common/errors/utils';
32
32
import { showInputBox , showQuickPick , withProgress } from '../../common/window.apis' ;
33
33
import { Installable , selectFromCommonPackagesToInstall } from '../common/pickers' ;
34
34
import { quoteArgs } from '../../features/execution/execUtils' ;
35
+ import { traceInfo } from '../../common/logging' ;
35
36
36
37
export const CONDA_PATH_KEY = `${ ENVS_EXTENSION_ID } :conda:CONDA_PATH` ;
37
38
export const CONDA_PREFIXES_KEY = `${ ENVS_EXTENSION_ID } :conda:CONDA_PREFIXES` ;
@@ -55,7 +56,7 @@ async function setConda(conda: string): Promise<void> {
55
56
export function getCondaPathSetting ( ) : string | undefined {
56
57
const config = getConfiguration ( 'python' ) ;
57
58
const value = config . get < string > ( 'condaPath' ) ;
58
- return ( value && typeof value === 'string' ) ? untildify ( value ) : value ;
59
+ return value && typeof value === 'string' ? untildify ( value ) : value ;
59
60
}
60
61
61
62
export async function getCondaForWorkspace ( fsPath : string ) : Promise < string | undefined > {
@@ -113,29 +114,47 @@ async function findConda(): Promise<readonly string[] | undefined> {
113
114
}
114
115
}
115
116
116
- export async function getConda ( ) : Promise < string > {
117
+ export async function getConda ( native ?: NativePythonFinder ) : Promise < string > {
117
118
const conda = getCondaPathSetting ( ) ;
118
119
if ( conda ) {
120
+ traceInfo ( `Using conda from settings: ${ conda } ` ) ;
119
121
return conda ;
120
122
}
121
123
122
124
if ( condaPath ) {
125
+ traceInfo ( `Using conda from cache: ${ condaPath } ` ) ;
123
126
return untildify ( condaPath ) ;
124
127
}
125
128
126
129
const state = await getWorkspacePersistentState ( ) ;
127
130
condaPath = await state . get < string > ( CONDA_PATH_KEY ) ;
128
131
if ( condaPath ) {
132
+ traceInfo ( `Using conda from persistent state: ${ condaPath } ` ) ;
129
133
return untildify ( condaPath ) ;
130
134
}
131
135
132
136
const paths = await findConda ( ) ;
133
137
if ( paths && paths . length > 0 ) {
134
138
condaPath = paths [ 0 ] ;
139
+ traceInfo ( `Using conda from PATH: ${ condaPath } ` ) ;
135
140
await state . set ( CONDA_PATH_KEY , condaPath ) ;
136
141
return condaPath ;
137
142
}
138
143
144
+ if ( native ) {
145
+ const data = await native . refresh ( false ) ;
146
+ const managers = data
147
+ . filter ( ( e ) => ! isNativeEnvInfo ( e ) )
148
+ . map ( ( e ) => e as NativeEnvManagerInfo )
149
+ . filter ( ( e ) => e . tool . toLowerCase ( ) === 'conda' ) ;
150
+ if ( managers . length > 0 ) {
151
+ condaPath = managers [ 0 ] . executable ;
152
+ traceInfo ( `Using conda from native finder: ${ condaPath } ` ) ;
153
+ await state . set ( CONDA_PATH_KEY , condaPath ) ;
154
+ return condaPath ;
155
+ }
156
+ }
157
+
139
158
throw new Error ( 'Conda not found' ) ;
140
159
}
141
160
0 commit comments