Skip to content

Emacs package for working with micromamba environments

License

Notifications You must be signed in to change notification settings

SqrtMinusOne/micromamba.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

micromamba.el

https://melpa.org/packages/micromamba-badge.svg

Emacs package for working with micromamba environments.

mamba is a reimplementation of the conda package manager in C++. mamba is notably much faster and essentially compatible with conda, so it also works with conda.el. micromamba, however, implements only a subset of mamba commands, and as such requires a separate integration.

Installation

The package is available on MELPA. Install it however you normally install packages, I prefer use-package and straight:

(use-package micromamba
  :straight t)

Or clone the repository, add it to the load-path and require the package.

If your micromamba binary is located in some place unknown to executable-find, set the micromamba-executable variable.

If you are running shells (e.g. vterm) from Emacs, you probably want to set auto_activate_base in your .condarc or .mambarc, because the shells are launched in the correct environment anyway.

Usage

The package has two entrypoints:

  • M-x micromamba-activate - activate the environment
  • M-x micromamba-deactivate - deactivate the environment

micromamba-activate prompts for the environment (by parsing micromamba env list). If some environments have duplicate names, these names are replaced by full paths.

I’ve noticed that micromamba also sees conda environments, so migrating from conda was rather painless for me.

Implementation notes

I initially wanted to extend conda.el, but decided it would be counterproductive for a few reasons.

First, conda is rather slow, so conda.el does various tricks to avoid calling the conda executable. For instance, it gets the environment list from scanning the anaconda home directory instead of running conda env list. This is really not necessary with micromamba, which is written in C++.

Second, and more importantly, conda.el relies heavily on passing shell.posix+json to conda. micromamba doesn’t support that. It supports the --json flag in some places, but not in the activate command, so I have to parse the output of micromamba shell -s bash activate and micromamba shell -s bash deactivate to get the environment configuration.

This also means the package most likely won’t work out-of-the-box on Windows.

About

Emacs package for working with micromamba environments

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published