Skip to content

Commit

Permalink
Fix activated conda env vars from PythonApi (#15526)
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne committed Apr 9, 2024
1 parent cd2ec9c commit 3b57423
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/platform/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Event, Uri } from 'vscode';
import { Resource } from '../common/types';
import type { SemVer } from 'semver';
import { PythonVersion } from '../pythonEnvironments/info/pythonVersion';
import { PythonExtension } from '@vscode/python-extension';
import { PythonExtension, type Environment } from '@vscode/python-extension';

export const IPythonApiProvider = Symbol('IPythonApi');
export interface IPythonApiProvider {
Expand Down Expand Up @@ -64,7 +64,7 @@ export interface PythonApi {
*/
getActivatedEnvironmentVariables(
resource: Resource,
interpreter: PythonEnvironment_PythonApi,
interpreter: Environment,
allowExceptions?: boolean
): Promise<NodeJS.ProcessEnv | undefined>;
/**
Expand Down
27 changes: 10 additions & 17 deletions src/platform/interpreter/environmentActivationService.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { KernelProgressReporter } from '../progress/kernelProgressReporter';
import { Telemetry } from '../common/constants';
import { ignoreLogging, logValue, traceDecoratorVerbose, traceError, traceVerbose, traceWarning } from '../logging';
import { TraceOptions } from '../logging/types';
import { pythonEnvToJupyterEnv, serializePythonEnvironment } from '../api/pythonApi';
import { GlobalPythonExecutablePathService } from './globalPythonExePathService.node';
import { noop } from '../common/utils/misc';
import { CancellationToken, workspace } from 'vscode';
Expand Down Expand Up @@ -166,22 +165,16 @@ export class EnvironmentActivationService implements IEnvironmentActivationServi
let failureEx: Error | undefined;

let env = await this.apiProvider.getApi().then((api) =>
api
.getActivatedEnvironmentVariables(
resource,
serializePythonEnvironment(pythonEnvToJupyterEnv(environment))!,
false
)
.catch((ex) => {
traceError(
`Failed to get activated env variables from Python Extension for ${getDisplayPath(
environment.path
)}`,
ex
);
reasonForFailure = 'failedToGetActivatedEnvVariablesFromPython';
return undefined;
})
api.getActivatedEnvironmentVariables(resource, environment, false).catch((ex) => {
traceError(
`Failed to get activated env variables from Python Extension for ${getDisplayPath(
environment.path
)}`,
ex
);
reasonForFailure = 'failedToGetActivatedEnvVariablesFromPython';
return undefined;
})
);
if (token?.isCancellationRequested) {
return;
Expand Down

0 comments on commit 3b57423

Please sign in to comment.