Skip to content

Commit 0e1e1b2

Browse files
authored
Ensure we match envs and python extensions (#74)
1 parent 306a01f commit 0e1e1b2

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/common/extVersion.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { PYTHON_EXTENSION_ID } from './constants';
2+
import { getExtension } from './extension.apis';
3+
import { traceError } from './logging';
4+
5+
export function ensureCorrectVersion() {
6+
const extension = getExtension(PYTHON_EXTENSION_ID);
7+
if (!extension) {
8+
return;
9+
}
10+
11+
const version = extension.packageJSON.version;
12+
const parts = version.split('.');
13+
const major = parseInt(parts[0]);
14+
const minor = parseInt(parts[1]);
15+
if (major >= 2024 && minor >= 23) {
16+
return;
17+
}
18+
traceError('Incompatible Python extension. Please update `ms-python.python` to version 2024.23 or later.');
19+
throw new Error('Incompatible Python extension. Please update `ms-python.python` to version 2024.23 or later.');
20+
}

src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { EnvVarManager, PythonEnvVariableManager } from './features/execution/en
5555
import { StopWatch } from './common/stopWatch';
5656
import { sendTelemetryEvent } from './common/telemetry/sender';
5757
import { EventNames } from './common/telemetry/constants';
58+
import { ensureCorrectVersion } from './common/extVersion';
5859

5960
export async function activate(context: ExtensionContext): Promise<PythonEnvironmentApi> {
6061
const start = new StopWatch();
@@ -63,6 +64,8 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
6364
const outputChannel: LogOutputChannel = createLogOutputChannel('Python Environments');
6465
context.subscriptions.push(outputChannel, registerLogger(outputChannel));
6566

67+
ensureCorrectVersion();
68+
6669
// Setup the persistent state for the extension.
6770
setPersistentState(context);
6871

0 commit comments

Comments
 (0)