Skip to content

Commit 9f6735e

Browse files
authored
Prioritize conda handler over pixi handler (#24198)
Related #24087
1 parent 710d3c8 commit 9f6735e

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/client/common/process/pythonExecutionFactory.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ export class PythonExecutionFactory implements IPythonExecutionFactory {
8080
}
8181
const processService: IProcessService = await this.processServiceFactory.create(options.resource);
8282

83-
const pixiExecutionService = await this.createPixiExecutionService(pythonPath, processService);
84-
if (pixiExecutionService) {
85-
return pixiExecutionService;
86-
}
87-
8883
const condaExecutionService = await this.createCondaExecutionService(pythonPath, processService);
8984
if (condaExecutionService) {
9085
return condaExecutionService;
9186
}
9287

88+
const pixiExecutionService = await this.createPixiExecutionService(pythonPath, processService);
89+
if (pixiExecutionService) {
90+
return pixiExecutionService;
91+
}
92+
9393
const windowsStoreInterpreterCheck = this.pyenvs.isMicrosoftStoreInterpreter.bind(this.pyenvs);
9494

9595
const env = (await windowsStoreInterpreterCheck(pythonPath))
@@ -122,15 +122,16 @@ export class PythonExecutionFactory implements IPythonExecutionFactory {
122122
processService.on('exec', this.logger.logProcess.bind(this.logger));
123123
this.disposables.push(processService);
124124

125+
const condaExecutionService = await this.createCondaExecutionService(pythonPath, processService);
126+
if (condaExecutionService) {
127+
return condaExecutionService;
128+
}
129+
125130
const pixiExecutionService = await this.createPixiExecutionService(pythonPath, processService);
126131
if (pixiExecutionService) {
127132
return pixiExecutionService;
128133
}
129134

130-
const condaExecutionService = await this.createCondaExecutionService(pythonPath, processService);
131-
if (condaExecutionService) {
132-
return condaExecutionService;
133-
}
134135
const env = createPythonEnv(pythonPath, processService, this.fileSystem);
135136
return createPythonService(processService, env);
136137
}
@@ -161,11 +162,11 @@ export class PythonExecutionFactory implements IPythonExecutionFactory {
161162
}
162163

163164
const env = await createPixiEnv(pixiEnvironment, processService, this.fileSystem);
164-
if (!env) {
165-
return undefined;
165+
if (env) {
166+
return createPythonService(processService, env);
166167
}
167168

168-
return createPythonService(processService, env);
169+
return undefined;
169170
}
170171
}
171172

src/test/common/process/pythonExecutionFactory.unit.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { ServiceContainer } from '../../../client/ioc/container';
3636
import { EnvironmentType, PythonEnvironment } from '../../../client/pythonEnvironments/info';
3737
import { IInterpreterAutoSelectionService } from '../../../client/interpreter/autoSelection/types';
3838
import { Conda, CONDA_RUN_VERSION } from '../../../client/pythonEnvironments/common/environmentManagers/conda';
39+
import * as pixi from '../../../client/pythonEnvironments/common/environmentManagers/pixi';
3940

4041
const pythonInterpreter: PythonEnvironment = {
4142
path: '/foo/bar/python.exe',
@@ -87,10 +88,15 @@ suite('Process - PythonExecutionFactory', () => {
8788
let executionService: typemoq.IMock<IPythonExecutionService>;
8889
let autoSelection: IInterpreterAutoSelectionService;
8990
let interpreterPathExpHelper: IInterpreterPathService;
91+
let getPixiEnvironmentFromInterpreterStub: sinon.SinonStub;
9092
const pythonPath = 'path/to/python';
9193
setup(() => {
9294
sinon.stub(Conda, 'getConda').resolves(new Conda('conda'));
9395
sinon.stub(Conda.prototype, 'getInterpreterPathForEnvironment').resolves(pythonPath);
96+
97+
getPixiEnvironmentFromInterpreterStub = sinon.stub(pixi, 'getPixiEnvironmentFromInterpreter');
98+
getPixiEnvironmentFromInterpreterStub.resolves(undefined);
99+
94100
activationHelper = mock(EnvironmentActivationService);
95101
processFactory = mock(ProcessServiceFactory);
96102
configService = mock(ConfigurationService);
@@ -336,6 +342,7 @@ suite('Process - PythonExecutionFactory', () => {
336342
} else {
337343
verify(pyenvs.getCondaEnvironment(interpreter!.path)).once();
338344
}
345+
expect(getPixiEnvironmentFromInterpreterStub.notCalled).to.be.equal(true);
339346
});
340347

341348
test('Ensure `createActivatedEnvironment` returns a PythonExecutionService instance if createCondaExecutionService() returns undefined', async () => {

0 commit comments

Comments
 (0)