Skip to content

Commit 29e9695

Browse files
make sure we use our resource to get interpreter details (#11474)
1 parent ad7022d commit 29e9695

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

news/2 Fixes/11469.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
When using a kernelspec without a fully qualified python path make sure we use the resource to get the active interpreter.

src/client/common/process/pythonExecutionFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class PythonExecutionFactory implements IPythonExecutionFactory {
7676
const interpreterService = this.serviceContainer.get<IInterpreterService>(IInterpreterService);
7777
const logger = this.serviceContainer.get<IProcessLogger>(IProcessLogger);
7878

79-
const interpreter = await interpreterService.getInterpreterDetails(pythonPath);
79+
const interpreter = await interpreterService.getInterpreterDetails(pythonPath, options.resource);
8080
const activatedProcPromise = this.createActivatedEnvironment({
8181
allowEnvironmentFetchExceptions: true,
8282
interpreter: interpreter,

src/client/datascience/kernel-launcher/kernelFinder.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,14 @@ export class KernelFinder implements IKernelFinder {
224224
this.activeInterpreter = await this.interpreterService.getActiveInterpreter(resource);
225225
}
226226

227+
// This creates a default kernel spec. When launched, 'python' argument will map to using the interpreter
228+
// associated with the current resource for launching.
227229
const defaultSpec: Kernel.ISpecModel = {
228230
name: `python_defaultSpec_${Date.now()}`,
229231
language: 'python',
230232
display_name: this.activeInterpreter?.displayName ? this.activeInterpreter.displayName : 'Python 3',
231233
metadata: {},
232-
argv: [
233-
this.activeInterpreter?.path || 'python',
234-
'-m',
235-
'ipykernel_launcher',
236-
'-f',
237-
connectionFilePlaceholder
238-
],
234+
argv: ['python', '-m', 'ipykernel_launcher', '-f', connectionFilePlaceholder],
239235
env: {},
240236
resources: {}
241237
};

src/test/common/process/pythonExecutionFactory.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ suite('Process - PythonExecutionFactory', () => {
431431
when(pythonSettings.pythonPath).thenReturn('HELLO');
432432
when(configService.getSettings(anything())).thenReturn(instance(pythonSettings));
433433
reset(interpreterService);
434-
when(interpreterService.getInterpreterDetails(anything())).thenResolve({
434+
when(interpreterService.getInterpreterDetails(anything(), anything())).thenResolve({
435435
version: parse('2.7.14')
436436
} as any);
437437
factory.createActivatedEnvironment = () => Promise.resolve(executionService.object);

0 commit comments

Comments
 (0)