Skip to content
Merged
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
26 changes: 22 additions & 4 deletions src/client/pythonEnvironments/base/info/environmentInfoService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createDeferred, Deferred, sleep } from '../../../common/utils/async';
import { createRunningWorkerPool, IWorkerPool, QueuePosition } from '../../../common/utils/workerPool';
import { getInterpreterInfo, InterpreterInformation } from './interpreter';
import { buildPythonExecInfo } from '../../exec';
import { traceError, traceInfo } from '../../../logging';
import { traceError, traceInfo, traceWarn } from '../../../logging';
import { Conda, CONDA_ACTIVATION_TIMEOUT, isCondaEnvironment } from '../../common/environmentManagers/conda';
import { PythonEnvInfo, PythonEnvKind } from '.';
import { normCasePath } from '../../common/externalDependencies';
Expand Down Expand Up @@ -37,8 +37,16 @@ export interface IEnvironmentInfoService {
resetInfo(searchLocation: Uri): void;
}

async function buildEnvironmentInfo(env: PythonEnvInfo): Promise<InterpreterInformation | undefined> {
const python = [env.executable.filename, '-I', OUTPUT_MARKER_SCRIPT];
async function buildEnvironmentInfo(
env: PythonEnvInfo,
useIsolated = true,
): Promise<InterpreterInformation | undefined> {
const python = [env.executable.filename];
if (useIsolated) {
python.push(...['-I', OUTPUT_MARKER_SCRIPT]);
} else {
python.push(...[OUTPUT_MARKER_SCRIPT]);
}
const interpreterInfo = await getInterpreterInfo(buildPythonExecInfo(python, undefined, env.executable.filename));
return interpreterInfo;
}
Expand Down Expand Up @@ -134,7 +142,7 @@ class EnvironmentInfoService implements IEnvironmentInfoService {
);
}

let reason: unknown;
let reason: Error | undefined;
let r = await addToQueue(this.workerPool, env, priority).catch((err) => {
reason = err;
return undefined;
Expand All @@ -161,6 +169,16 @@ class EnvironmentInfoService implements IEnvironmentInfoService {
return undefined;
});
} else if (reason) {
if (reason.message.includes('Unknown option: -I')) {
traceWarn(reason);
traceError(
'Support for Python 2.7 has been dropped by the Python extension so certain features may not work, upgrade to using Python 3.',
);
return buildEnvironmentInfo(env, false).catch((err) => {
traceError(err);
return undefined;
});
}
traceError(reason);
}
}
Expand Down