Skip to content

Commit

Permalink
Add activation command for micromamba
Browse files Browse the repository at this point in the history
  • Loading branch information
hguandl committed Dec 18, 2024
1 parent 5ec7510 commit b06a4fb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/client/interpreter/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface ICondaService {
getCondaFile(forShellExecution?: boolean): Promise<string>;
getCondaInfo(): Promise<CondaInfo | undefined>;
isCondaAvailable(): Promise<boolean>;
isMicroMamba(): Promise<boolean>;
getCondaVersion(): Promise<SemVer | undefined>;
getInterpreterPathForEnvironment(condaEnv: CondaEnvironmentInfo): Promise<string | undefined>;
getCondaFileFromInterpreter(interpreterPath?: string, envName?: string): Promise<string | undefined>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
const file = await this.getCondaFile();
const name = path.basename(file, '.exe');
return name === 'micromamba';
}

/**
* Return the conda version.
*/
Expand Down

0 comments on commit b06a4fb

Please sign in to comment.