Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritize conda handler over pixi handler #24198

Merged
merged 2 commits into from
Sep 26, 2024
Merged
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
25 changes: 13 additions & 12 deletions src/client/common/process/pythonExecutionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ export class PythonExecutionFactory implements IPythonExecutionFactory {
}
const processService: IProcessService = await this.processServiceFactory.create(options.resource);

const pixiExecutionService = await this.createPixiExecutionService(pythonPath, processService);
if (pixiExecutionService) {
return pixiExecutionService;
}

const condaExecutionService = await this.createCondaExecutionService(pythonPath, processService);
if (condaExecutionService) {
return condaExecutionService;
}

const pixiExecutionService = await this.createPixiExecutionService(pythonPath, processService);
if (pixiExecutionService) {
return pixiExecutionService;
}

const windowsStoreInterpreterCheck = this.pyenvs.isMicrosoftStoreInterpreter.bind(this.pyenvs);

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

const condaExecutionService = await this.createCondaExecutionService(pythonPath, processService);
if (condaExecutionService) {
return condaExecutionService;
}

const pixiExecutionService = await this.createPixiExecutionService(pythonPath, processService);
if (pixiExecutionService) {
return pixiExecutionService;
}

const condaExecutionService = await this.createCondaExecutionService(pythonPath, processService);
if (condaExecutionService) {
return condaExecutionService;
}
const env = createPythonEnv(pythonPath, processService, this.fileSystem);
return createPythonService(processService, env);
}
Expand Down Expand Up @@ -161,11 +162,11 @@ export class PythonExecutionFactory implements IPythonExecutionFactory {
}

const env = await createPixiEnv(pixiEnvironment, processService, this.fileSystem);
if (!env) {
return undefined;
if (env) {
return createPythonService(processService, env);
}

return createPythonService(processService, env);
return undefined;
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/test/common/process/pythonExecutionFactory.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { ServiceContainer } from '../../../client/ioc/container';
import { EnvironmentType, PythonEnvironment } from '../../../client/pythonEnvironments/info';
import { IInterpreterAutoSelectionService } from '../../../client/interpreter/autoSelection/types';
import { Conda, CONDA_RUN_VERSION } from '../../../client/pythonEnvironments/common/environmentManagers/conda';
import * as pixi from '../../../client/pythonEnvironments/common/environmentManagers/pixi';

const pythonInterpreter: PythonEnvironment = {
path: '/foo/bar/python.exe',
Expand Down Expand Up @@ -87,10 +88,15 @@ suite('Process - PythonExecutionFactory', () => {
let executionService: typemoq.IMock<IPythonExecutionService>;
let autoSelection: IInterpreterAutoSelectionService;
let interpreterPathExpHelper: IInterpreterPathService;
let getPixiEnvironmentFromInterpreterStub: sinon.SinonStub;
const pythonPath = 'path/to/python';
setup(() => {
sinon.stub(Conda, 'getConda').resolves(new Conda('conda'));
sinon.stub(Conda.prototype, 'getInterpreterPathForEnvironment').resolves(pythonPath);

getPixiEnvironmentFromInterpreterStub = sinon.stub(pixi, 'getPixiEnvironmentFromInterpreter');
getPixiEnvironmentFromInterpreterStub.resolves(undefined);

activationHelper = mock(EnvironmentActivationService);
processFactory = mock(ProcessServiceFactory);
configService = mock(ConfigurationService);
Expand Down Expand Up @@ -336,6 +342,7 @@ suite('Process - PythonExecutionFactory', () => {
} else {
verify(pyenvs.getCondaEnvironment(interpreter!.path)).once();
}
expect(getPixiEnvironmentFromInterpreterStub.notCalled).to.be.equal(true);
});

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