Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions src/extension/debugger/adapter/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
): Promise<string[]> {
if (configuration.debugAdapterPython !== undefined) {
return this.getExecutableCommand(await resolveEnvironment(configuration.debugAdapterPython));
} else if (configuration.pythonPath) {
return this.getExecutableCommand(await resolveEnvironment(configuration.pythonPath));
}

const resourceUri = workspaceFolder ? workspaceFolder.uri : undefined;
Expand Down
48 changes: 8 additions & 40 deletions src/extension/debugger/configuration/resolvers/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
}

/**
* Resolves Python interpreter paths and handles the legacy pythonPath deprecation.
* Resolves Python interpreter paths.
*
* @param workspaceFolder The workspace folder URI for variable resolution and interpreter detection
* @param debugConfiguration The launch configuration to update with resolved Python paths
Expand All @@ -145,37 +145,18 @@ export abstract class BaseConfigurationResolver<T extends DebugConfiguration>

traceLog(
`resolveAndUpdatePythonPath - Initial state: ` +
`pythonPath='${debugConfiguration.pythonPath}', ` +
`python='${debugConfiguration.python}', ` +
`debugAdapterPython='${debugConfiguration.debugAdapterPython}', ` +
`debugLauncherPython='${debugConfiguration.debugLauncherPython}', ` +
`workspaceFolder='${workspaceFolder?.fsPath}'` +
`resolvedInterpreterPath='${resolvedInterpreterPath}'`,
);

// STEP 1: Resolve legacy pythonPath property (DEPRECATED)
// pythonPath will equal user set value, or getInterpreterDetails if undefined or set to command
if (debugConfiguration.pythonPath === '${command:python.interpreterPath}' || !debugConfiguration.pythonPath) {
this.pythonPathSource = PythonPathSource.settingsJson;
debugConfiguration.pythonPath = resolvedInterpreterPath;
} else {
// User provided explicit pythonPath in launch.json
debugConfiguration.pythonPath = resolveWorkspaceVariables(
debugConfiguration.pythonPath,
workspaceFolder?.fsPath,
undefined,
);
}

// STEP 2: Resolve current python property (CURRENT STANDARD)
if (debugConfiguration.python === '${command:python.interpreterPath}') {
// if python is set to the command, resolve it
// Resolve current python property
if (debugConfiguration.python === '${command:python.interpreterPath}' || !debugConfiguration.python) {
// if python is set to the command or undefined, resolve it
this.pythonPathSource = PythonPathSource.settingsJson;
debugConfiguration.python = resolvedInterpreterPath;
} else if (!debugConfiguration.python) {
// fallback to pythonPath if python undefined
this.pythonPathSource = PythonPathSource.settingsJson;
debugConfiguration.python = debugConfiguration.pythonPath;
} else {
// User provided explicit python path in launch.json
this.pythonPathSource = PythonPathSource.launchJson;
Expand All @@ -186,16 +167,12 @@ export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
);
}

// STEP 3: Set debug adapter and launcher Python paths (backwards compatible)
// Set debug adapter and launcher Python paths
this.setDebugComponentPythonPaths(debugConfiguration);

// STEP 4: Clean up - remove the deprecated pythonPath property
delete debugConfiguration.pythonPath;
}

/**
* Sets debugAdapterPython and debugLauncherPython with backwards compatibility.
* Prefers pythonPath over python for these internal properties.
* Sets debugAdapterPython and debugLauncherPython.
*
* @param debugConfiguration The debug configuration to update
*/
Expand All @@ -208,20 +185,11 @@ export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
debugConfiguration.debugLauncherPython === '${command:python.interpreterPath}' ||
debugConfiguration.debugLauncherPython === undefined;

// Default fallback path (prefer pythonPath for backwards compatibility)
const fallbackPath = debugConfiguration.pythonPath ?? debugConfiguration.python;

if (debugConfiguration.pythonPath !== debugConfiguration.python) {
sendTelemetryEvent(EventName.DEPRECATED_CODE_PATH_USAGE, undefined, {
codePath: 'different_python_paths_in_debug_config',
});
}

if (shouldSetDebugAdapter) {
debugConfiguration.debugAdapterPython = fallbackPath;
debugConfiguration.debugAdapterPython = debugConfiguration.python;
}
if (shouldSetDebugLauncher) {
debugConfiguration.debugLauncherPython = fallbackPath;
debugConfiguration.debugLauncherPython = debugConfiguration.python;
}
}

Expand Down
11 changes: 0 additions & 11 deletions src/extension/debugger/configuration/resolvers/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,6 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
workspaceFolder: Uri | undefined,
debugConfiguration: LaunchRequestArguments,
): Promise<void> {
if (debugConfiguration.python === undefined) {
debugConfiguration.python = debugConfiguration.pythonPath;
}
if (debugConfiguration.debugAdapterPython === undefined) {
debugConfiguration.debugAdapterPython = debugConfiguration.pythonPath;
}
if (debugConfiguration.debugLauncherPython === undefined) {
debugConfiguration.debugLauncherPython = debugConfiguration.pythonPath;
}
delete debugConfiguration.pythonPath;

if (typeof debugConfiguration.cwd !== 'string' && workspaceFolder) {
debugConfiguration.cwd = workspaceFolder.fsPath;
}
Expand Down
Loading