Skip to content

Commit afc44e2

Browse files
author
Kartik Raj
committed
Use conda run for debugging when in experiment
1 parent ebc7b1e commit afc44e2

File tree

2 files changed

+27
-3
lines changed
  • src/client

2 files changed

+27
-3
lines changed

src/client/debugger/extension/adapter/factory.ts

+22-2
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ import {
1616
import { EXTENSION_ROOT_DIR } from '../../../constants';
1717
import { IInterpreterService } from '../../../interpreter/contracts';
1818
import { traceLog, traceVerbose } from '../../../logging';
19-
import { PythonEnvironment } from '../../../pythonEnvironments/info';
19+
import { EnvironmentType, PythonEnvironment } from '../../../pythonEnvironments/info';
2020
import { sendTelemetryEvent } from '../../../telemetry';
2121
import { EventName } from '../../../telemetry/constants';
2222
import { AttachRequestArguments, LaunchRequestArguments } from '../../types';
2323
import { IDebugAdapterDescriptorFactory } from '../types';
2424
import { showErrorMessage } from '../../../common/vscodeApis/windowApis';
2525
import { Common, Interpreters } from '../../../common/utils/localize';
26-
import { IPersistentStateFactory } from '../../../common/types';
26+
import { IExperimentService, IPersistentStateFactory } from '../../../common/types';
2727
import { Commands } from '../../../common/constants';
2828
import { ICommandManager } from '../../../common/application/types';
29+
import { inTerminalEnvVarExperiment } from '../../../common/experiments/helpers';
30+
import { Conda } from '../../../pythonEnvironments/common/environmentManagers/conda';
2931

3032
// persistent state names, exported to make use of in testing
3133
export enum debugStateKeys {
@@ -38,6 +40,7 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
3840
@inject(ICommandManager) private readonly commandManager: ICommandManager,
3941
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService,
4042
@inject(IPersistentStateFactory) private persistentState: IPersistentStateFactory,
43+
@inject(IExperimentService) private experimentService: IExperimentService,
4144
) {}
4245

4346
public async createDebugAdapterDescriptor(
@@ -186,6 +189,23 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac
186189
if ((interpreter.version?.major ?? 0) < 3 || (interpreter.version?.minor ?? 0) <= 6) {
187190
this.showDeprecatedPythonMessage();
188191
}
192+
if (interpreter.envType === EnvironmentType.Conda && inTerminalEnvVarExperiment(this.experimentService)) {
193+
const conda = await Conda.getConda();
194+
if (conda) {
195+
const args = await conda.getRunPythonArgs(
196+
{
197+
prefix: interpreter.envPath ?? '',
198+
name: interpreter.envName,
199+
},
200+
false,
201+
false,
202+
false,
203+
);
204+
if (args) {
205+
return args;
206+
}
207+
}
208+
}
189209
return interpreter.path.length > 0 ? [interpreter.path] : [];
190210
}
191211
return [];

src/client/pythonEnvironments/common/environmentManagers/conda.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ export class Conda {
508508
env: CondaEnvInfo,
509509
forShellExecution?: boolean,
510510
isolatedFlag = false,
511+
useOutputMarker = true,
511512
): Promise<string[] | undefined> {
512513
const condaVersion = await this.getCondaVersion();
513514
if (condaVersion && lt(condaVersion, CONDA_RUN_VERSION)) {
@@ -530,7 +531,10 @@ export class Conda {
530531
if (isolatedFlag) {
531532
python.push('-I');
532533
}
533-
return [...python, OUTPUT_MARKER_SCRIPT];
534+
if (useOutputMarker) {
535+
python.push(OUTPUT_MARKER_SCRIPT);
536+
}
537+
return python;
534538
}
535539

536540
/**

0 commit comments

Comments
 (0)