From 94e873b30dbf23bdcdb153b5cdbf5d3c99c1fe99 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 21 Oct 2021 17:00:07 -0700 Subject: [PATCH 1/3] Support environment variable substitution in `python` property for `launch.json` --- src/client/common/configSettings.ts | 3 ++- .../debugger/extension/configuration/resolvers/base.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index 73c2ac56a96c..409c5ff3efb8 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -595,11 +595,12 @@ export class PythonSettings implements IPythonSettings { */ const inExperiment = this.experimentsManager?.inExperimentSync(DeprecatePythonPath.experiment); // Use the interpreter path service if in the experiment otherwise use the normal settings - this.pythonPath = systemVariables.resolveAny( + const p = systemVariables.resolveAny( inExperiment && this.interpreterPathService ? this.interpreterPathService.get(this.workspaceRoot) : pythonSettings.get('pythonPath'), )!; + this.pythonPath = p; if ( !process.env.CI_DISABLE_AUTO_SELECTION && (this.pythonPath.length === 0 || this.pythonPath === 'python') && diff --git a/src/client/debugger/extension/configuration/resolvers/base.ts b/src/client/debugger/extension/configuration/resolvers/base.ts index c2e8139b7a05..e64ee25c3eee 100644 --- a/src/client/debugger/extension/configuration/resolvers/base.ts +++ b/src/client/debugger/extension/configuration/resolvers/base.ts @@ -112,13 +112,20 @@ export abstract class BaseConfigurationResolver if (!debugConfiguration) { return; } + const systemVariables: SystemVariables = new SystemVariables( + undefined, + workspaceFolder?.fsPath, + this.workspaceService, + ); if (debugConfiguration.pythonPath === '${command:python.interpreterPath}' || !debugConfiguration.pythonPath) { const pythonPath = this.configurationService.getSettings(workspaceFolder).pythonPath; debugConfiguration.pythonPath = pythonPath; this.pythonPathSource = PythonPathSource.settingsJson; } else { + debugConfiguration.pythonPath = systemVariables.resolveAny(debugConfiguration.pythonPath); this.pythonPathSource = PythonPathSource.launchJson; } + debugConfiguration.python = systemVariables.resolveAny(debugConfiguration.python); } protected debugOption(debugOptions: DebugOptions[], debugOption: DebugOptions) { From f73e83b725d44ea4cc397ab0ae264b2431fae2ee Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 21 Oct 2021 17:00:51 -0700 Subject: [PATCH 2/3] News entry --- news/1 Enhancements/12289.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/1 Enhancements/12289.md diff --git a/news/1 Enhancements/12289.md b/news/1 Enhancements/12289.md new file mode 100644 index 000000000000..a102068c118e --- /dev/null +++ b/news/1 Enhancements/12289.md @@ -0,0 +1 @@ +Support environment variable substitution in `python` property for `launch.json`. From 2b2705cbc0132601d509eb2bb60d609b52e69362 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 21 Oct 2021 17:05:49 -0700 Subject: [PATCH 3/3] Undo --- src/client/common/configSettings.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index 409c5ff3efb8..73c2ac56a96c 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -595,12 +595,11 @@ export class PythonSettings implements IPythonSettings { */ const inExperiment = this.experimentsManager?.inExperimentSync(DeprecatePythonPath.experiment); // Use the interpreter path service if in the experiment otherwise use the normal settings - const p = systemVariables.resolveAny( + this.pythonPath = systemVariables.resolveAny( inExperiment && this.interpreterPathService ? this.interpreterPathService.get(this.workspaceRoot) : pythonSettings.get('pythonPath'), )!; - this.pythonPath = p; if ( !process.env.CI_DISABLE_AUTO_SELECTION && (this.pythonPath.length === 0 || this.pythonPath === 'python') &&