Skip to content

Commit 2d4f34a

Browse files
author
Kartik Raj
authored
Use isolated flag when gathering environment information (microsoft#20403)
Closes microsoft#20382
1 parent 5b7e040 commit 2d4f34a

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/client/pythonEnvironments/base/info/environmentInfoService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface IEnvironmentInfoService {
3838
}
3939

4040
async function buildEnvironmentInfo(env: PythonEnvInfo): Promise<InterpreterInformation | undefined> {
41-
const python = [env.executable.filename, OUTPUT_MARKER_SCRIPT];
41+
const python = [env.executable.filename, '-I', OUTPUT_MARKER_SCRIPT];
4242
const interpreterInfo = await getInterpreterInfo(buildPythonExecInfo(python, undefined, env.executable.filename));
4343
return interpreterInfo;
4444
}
@@ -50,7 +50,7 @@ async function buildEnvironmentInfoUsingCondaRun(env: PythonEnvInfo): Promise<In
5050
if (!condaEnv) {
5151
return undefined;
5252
}
53-
const python = await conda?.getRunPythonArgs(condaEnv, true);
53+
const python = await conda?.getRunPythonArgs(condaEnv, true, true);
5454
if (!python) {
5555
return undefined;
5656
}

src/client/pythonEnvironments/common/environmentManagers/conda.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,11 @@ export class Conda {
506506
return 'python';
507507
}
508508

509-
public async getRunPythonArgs(env: CondaEnvInfo, forShellExecution?: boolean): Promise<string[] | undefined> {
509+
public async getRunPythonArgs(
510+
env: CondaEnvInfo,
511+
forShellExecution?: boolean,
512+
isolatedFlag = false,
513+
): Promise<string[] | undefined> {
510514
const condaVersion = await this.getCondaVersion();
511515
if (condaVersion && lt(condaVersion, CONDA_RUN_VERSION)) {
512516
traceError('`conda run` is not supported for conda version', condaVersion.raw);
@@ -518,14 +522,17 @@ export class Conda {
518522
} else {
519523
args.push('-p', env.prefix);
520524
}
521-
return [
525+
const python = [
522526
forShellExecution ? this.shellCommand : this.command,
523527
'run',
524528
...args,
525529
'--no-capture-output',
526530
'python',
527-
OUTPUT_MARKER_SCRIPT,
528531
];
532+
if (isolatedFlag) {
533+
python.push('-I');
534+
}
535+
return [...python, OUTPUT_MARKER_SCRIPT];
529536
}
530537

531538
/**

0 commit comments

Comments
 (0)