Skip to content

Commit

Permalink
Fix activated Conda Envs vars in Jupyter Ext API (#23222)
Browse files Browse the repository at this point in the history
For microsoft/vscode-jupyter#15524

Co-authored-by: Don Jayamanne <[email protected]>
  • Loading branch information
karthiknadig and DonJayamanne authored Apr 10, 2024
1 parent c92ec71 commit 0a5b179
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/client/jupyter/jupyterIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,23 @@ import { GLOBAL_MEMENTO, IExtensions, IMemento, Resource } from '../common/types
import { getDebugpyPackagePath } from '../debugger/extension/adapter/remoteLaunchers';
import { IEnvironmentActivationService } from '../interpreter/activation/types';
import { IInterpreterQuickPickItem, IInterpreterSelector } from '../interpreter/configuration/types';
import { ICondaService, IInterpreterDisplay, IInterpreterStatusbarVisibilityFilter } from '../interpreter/contracts';
import { PythonEnvironment } from '../pythonEnvironments/info';
import {
ICondaService,
IInterpreterDisplay,
IInterpreterService,
IInterpreterStatusbarVisibilityFilter,
} from '../interpreter/contracts';
import { PylanceApi } from '../activation/node/pylanceApi';
import { ExtensionContextKey } from '../common/application/contextKeys';
import type { Environment } from '../api/types';

type PythonApiForJupyterExtension = {
/**
* IEnvironmentActivationService
*/
getActivatedEnvironmentVariables(
resource: Resource,
interpreter?: PythonEnvironment,
interpreter: Environment,
allowExceptions?: boolean,
): Promise<NodeJS.ProcessEnv | undefined>;
getKnownSuggestions(resource: Resource): IInterpreterQuickPickItem[];
Expand Down Expand Up @@ -82,6 +87,7 @@ export class JupyterExtensionIntegration {
@inject(IWorkspaceService) private workspaceService: IWorkspaceService,
@inject(ICondaService) private readonly condaService: ICondaService,
@inject(IContextKeyManager) private readonly contextManager: IContextKeyManager,
@inject(IInterpreterService) private interpreterService: IInterpreterService,
) {}

public registerApi(jupyterExtensionApi: JupyterExtensionApi): JupyterExtensionApi | undefined {
Expand All @@ -94,9 +100,12 @@ export class JupyterExtensionIntegration {
jupyterExtensionApi.registerPythonApi({
getActivatedEnvironmentVariables: async (
resource: Resource,
interpreter?: PythonEnvironment,
env: Environment,
allowExceptions?: boolean,
) => this.envActivation.getActivatedEnvironmentVariables(resource, interpreter, allowExceptions),
) => {
const interpreter = await this.interpreterService.getInterpreterDetails(env.path);
return this.envActivation.getActivatedEnvironmentVariables(resource, interpreter, allowExceptions);
},
getSuggestions: async (resource: Resource): Promise<IInterpreterQuickPickItem[]> =>
this.interpreterSelector.getAllSuggestions(resource),
getKnownSuggestions: (resource: Resource): IInterpreterQuickPickItem[] =>
Expand Down

0 comments on commit 0a5b179

Please sign in to comment.