Skip to content

make sure we use our resource to get interpreter details #11474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/11469.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When using a kernelspec without a fully qualified python path make sure we use the resource to get the active interpreter.
2 changes: 1 addition & 1 deletion src/client/common/process/pythonExecutionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class PythonExecutionFactory implements IPythonExecutionFactory {
const interpreterService = this.serviceContainer.get<IInterpreterService>(IInterpreterService);
const logger = this.serviceContainer.get<IProcessLogger>(IProcessLogger);

const interpreter = await interpreterService.getInterpreterDetails(pythonPath);
const interpreter = await interpreterService.getInterpreterDetails(pythonPath, options.resource);
Copy link
Member Author

@IanMatthewHuff IanMatthewHuff Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per discussion on teams I think this is the change we need. This should cover cases where the full pythonPath is specified in the spec, and if it's just "python" it will use the resource to calculate the interpreter.

const activatedProcPromise = this.createActivatedEnvironment({
allowEnvironmentFetchExceptions: true,
interpreter: interpreter,
Expand Down
10 changes: 3 additions & 7 deletions src/client/datascience/kernel-launcher/kernelFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,14 @@ export class KernelFinder implements IKernelFinder {
this.activeInterpreter = await this.interpreterService.getActiveInterpreter(resource);
}

// This creates a default kernel spec. When launched, 'python' argument will map to using the interpreter
// associated with the current resource for launching.
const defaultSpec: Kernel.ISpecModel = {
name: `python_defaultSpec_${Date.now()}`,
language: 'python',
display_name: this.activeInterpreter?.displayName ? this.activeInterpreter.displayName : 'Python 3',
metadata: {},
argv: [
this.activeInterpreter?.path || 'python',
'-m',
'ipykernel_launcher',
'-f',
connectionFilePlaceholder
],
argv: ['python', '-m', 'ipykernel_launcher', '-f', connectionFilePlaceholder],
env: {},
resources: {}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ suite('Process - PythonExecutionFactory', () => {
when(pythonSettings.pythonPath).thenReturn('HELLO');
when(configService.getSettings(anything())).thenReturn(instance(pythonSettings));
reset(interpreterService);
when(interpreterService.getInterpreterDetails(anything())).thenResolve({
when(interpreterService.getInterpreterDetails(anything(), anything())).thenResolve({
version: parse('2.7.14')
} as any);
factory.createActivatedEnvironment = () => Promise.resolve(executionService.object);
Expand Down