@@ -128,6 +128,7 @@ export class KernelService {
128
128
* @returns {(Promise<PythonInterpreter | undefined>) }
129
129
* @memberof KernelService
130
130
*/
131
+ // tslint:disable-next-line: cyclomatic-complexity
131
132
public async findMatchingInterpreter (
132
133
kernelSpec : IJupyterKernelSpec | LiveKernelModel ,
133
134
cancelToken ?: CancellationToken
@@ -159,11 +160,35 @@ export class KernelService {
159
160
`KernelSpec has interpreter information, however a matching interepter could not be found for ${ kernelSpec . metadata ?. interpreter ?. path } `
160
161
) ;
161
162
}
163
+
164
+ // 2. Check if we have a fully qualified path in `argv`
165
+ const pathInArgv =
166
+ Array . isArray ( kernelSpec . argv ) && kernelSpec . argv . length > 0 ? kernelSpec . argv [ 0 ] : undefined ;
167
+ if ( pathInArgv && path . basename ( pathInArgv ) !== pathInArgv ) {
168
+ const interpreter = await this . interpreterService . getInterpreterDetails ( pathInArgv ) . catch ( ( ex ) => {
169
+ traceError (
170
+ `Failed to get interpreter information for python defined in kernel ${ kernelSpec . name } , ${
171
+ kernelSpec . display_name
172
+ } with argv: ${ ( kernelSpec . argv || [ ] ) ?. join ( ',' ) } `,
173
+ ex
174
+ ) ;
175
+ return ;
176
+ } ) ;
177
+ if ( interpreter ) {
178
+ traceInfo (
179
+ `Found matching interpreter based on metadata, for the kernel ${ kernelSpec . name } , ${ kernelSpec . display_name } `
180
+ ) ;
181
+ return interpreter ;
182
+ }
183
+ traceError (
184
+ `KernelSpec has interpreter information, however a matching interepter could not be found for ${ kernelSpec . metadata ?. interpreter ?. path } `
185
+ ) ;
186
+ }
162
187
if ( Cancellation . isCanceled ( cancelToken ) ) {
163
188
return ;
164
189
}
165
190
166
- // 2 . Check if current interpreter has the same display name
191
+ // 3 . Check if current interpreter has the same display name
167
192
const activeInterpreter = await activeInterpreterPromise ;
168
193
// If the display name matches the active interpreter then use that.
169
194
if ( kernelSpec . display_name === activeInterpreter ?. displayName ) {
@@ -200,7 +225,7 @@ export class KernelService {
200
225
) ;
201
226
return activeInterpreter ;
202
227
} else {
203
- // 4 . Look for interpreter with same display name across all interpreters.
228
+ // 5 . Look for interpreter with same display name across all interpreters.
204
229
205
230
// If the display name matches the active interpreter then use that.
206
231
// Look in all of our interpreters if we have somethign that matches this.
0 commit comments