diff --git a/.vscode/settings.json b/.vscode/settings.json index 0b79e8a23..ee3c3388b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,5 @@ }, "search.exclude": { "out": true // set this to false to include "out" folder in search results - } - // Turn off tsc task auto detection since we have the necessary tasks as npm scripts + }, } diff --git a/package.json b/package.json index a0f2375df..cf34e246e 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,9 @@ "publisher": "__PUBLISHER__", "instrumentationKey": "__AIKEY__", "icon": "assets/icon.png", + "featureFlags": { + "usingNewPythonInterpreterPathApi": true + }, "engines": { "vscode": "^1.43.0" }, diff --git a/src/service/setupService.ts b/src/service/setupService.ts index 04c757a72..d80b043dd 100644 --- a/src/service/setupService.ts +++ b/src/service/setupService.ts @@ -171,7 +171,20 @@ export class SetupService { : GLOBAL_ENV_VARS.PYTHON; // try to get name from interpreter try { - originalPythonExecutablePath = getConfig(CONFIG.PYTHON_PATH); + const extension = vscode.extensions.getExtension("ms-python.python"); + const usingNewInterpreterStorage = extension.packageJSON?.featureFlags?.usingNewInterpreterStorage; + if (usingNewInterpreterStorage) { + if (!extension.isActive) { + await extension.activate(); + } + const execCommand = extension.exports.settings.getExecutionDetails ? + extension.exports.settings.getExecutionDetails().execCommand : + extension.exports.settings.getExecutionCommand(); + originalPythonExecutablePath = execCommand.join(" "); + } + else { + originalPythonExecutablePath = getConfig(CONFIG.PYTHON_PATH); + } } catch (err) { originalPythonExecutablePath = systemPythonVar; }