From b06a4fb1702025679fcd6495806b8a3a16e9cb01 Mon Sep 17 00:00:00 2001 From: Hao Guan <10684225+hguandl@users.noreply.github.com> Date: Wed, 18 Dec 2024 01:53:49 +0800 Subject: [PATCH] Add activation command for micromamba --- .../condaActivationProvider.ts | 5 +++++ src/client/interpreter/contracts.ts | 1 + .../common/environmentManagers/condaService.ts | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/src/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts b/src/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts index d209550e04a4..af61413ff694 100644 --- a/src/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts +++ b/src/client/common/terminal/environmentActivationProviders/condaActivationProvider.ts @@ -60,6 +60,11 @@ export class CondaActivationCommandProvider implements ITerminalActivationComman const condaEnv = envInfo.name.length > 0 ? envInfo.name : envInfo.path; + // Directly use the self-contained micromamba executable. + if (await this.condaService.isMicroMamba()) { + return [`micromamba activate ${condaEnv.toCommandArgumentForPythonExt()}`]; + } + // New version. const interpreterPath = await this.condaService.getInterpreterPathForEnvironment(envInfo); const activatePath = await this.condaService.getActivationScriptFromInterpreter(interpreterPath, envInfo.name); diff --git a/src/client/interpreter/contracts.ts b/src/client/interpreter/contracts.ts index 30a05c140249..dbd24c562a79 100644 --- a/src/client/interpreter/contracts.ts +++ b/src/client/interpreter/contracts.ts @@ -62,6 +62,7 @@ export interface ICondaService { getCondaFile(forShellExecution?: boolean): Promise; getCondaInfo(): Promise; isCondaAvailable(): Promise; + isMicroMamba(): Promise; getCondaVersion(): Promise; getInterpreterPathForEnvironment(condaEnv: CondaEnvironmentInfo): Promise; getCondaFileFromInterpreter(interpreterPath?: string, envName?: string): Promise; diff --git a/src/client/pythonEnvironments/common/environmentManagers/condaService.ts b/src/client/pythonEnvironments/common/environmentManagers/condaService.ts index 049e19380d4e..fd42b1d974ac 100644 --- a/src/client/pythonEnvironments/common/environmentManagers/condaService.ts +++ b/src/client/pythonEnvironments/common/environmentManagers/condaService.ts @@ -82,6 +82,15 @@ export class CondaService implements ICondaService { .catch(() => (this.isAvailable = false)); // eslint-disable-line no-return-assign } + /** + * Is the conda executable named "micromamba"? + */ + public async isMicroMamba(): Promise { + const file = await this.getCondaFile(); + const name = path.basename(file, '.exe'); + return name === 'micromamba'; + } + /** * Return the conda version. */