sqrtminusone.github.io/packages/micromamba/index.html
2024-01-04 19:27:36 +00:00

153 lines
8.3 KiB
HTML

<!DOCTYPE html>
<html lang=""><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>micromamba.el</title>
<meta name="description" content="Freedom is a state of mind">
<meta name="author" content='SqrtMinusOne'>
<link href="https://fonts.googleapis.com/css2?family=Inconsolata:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous">
<link rel="stylesheet" href="/sass/researcher.min.css">
<link rel="icon" type="image/ico" href="https://sqrtminusone.xyz/favicon.ico">
<script defer data-domain="sqrtminusone.xyz" src="https://plausible.sqrtminusone.xyz/js/plausible.js"></script>
</head>
<body><div class="container mt-5">
<nav class="navbar navbar-expand-sm flex-column flex-sm-row text-nowrap p-0">
<a class="navbar-brand mx-0 mr-sm-auto" href="https://sqrtminusone.xyz/" title="SqrtMinusOne">
SqrtMinusOne
</a>
<div class="navbar-nav flex-row flex-wrap justify-content-center">
<a class="nav-item nav-link" href="/" title="Index">
Index
</a>
<span class="nav-item navbar-text mx-1">/</span>
<a class="nav-item nav-link" href="/posts/" title="Posts">
Posts
</a>
<span class="nav-item navbar-text mx-1">/</span>
<a class="nav-item nav-link" href="/configs/readme" title="Configs">
Configs
</a>
<span class="nav-item navbar-text mx-1">/</span>
<a class="nav-item nav-link" href="/emacs-packages/" title="Emacs packages">
Emacs packages
</a>
</div>
</nav>
</div>
<hr>
<div id="content">
<script defer language="javascript" type="text/javascript" src="/js/dynamic-toc.js"></script>
<div class="root">
<h1 id="title-small-screen">
micromamba.el
<iframe src="https://ghbtns.com/github-btn.html?user=SqrtMinusOne&repo=micromamba.el&type=star&count=true" frameborder="0" scrolling="0" width="150" height="20" title="GitHub"></iframe>
</h1>
<div class="container" id="actual-content">
<h1 id="title-large-screen" class="dotfiles-title">
micromamba.el
<iframe src="https://ghbtns.com/github-btn.html?user=SqrtMinusOne&repo=micromamba.el&type=star&count=true" frameborder="0" scrolling="0" width="150" height="20" title="GitHub"></iframe>
</h1>
<figure><a href="https://melpa.org/#/micromamba"><img src="https://melpa.org/packages/micromamba-badge.svg"/></a>
</figure>
<p>Emacs package for working with <a href="https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html">micromamba</a> environments.</p>
<p><a href="https://mamba.readthedocs.io/en/latest/index.html">mamba</a> is a reimplementation of the <a href="https://docs.conda.io/en/latest/">conda</a> package manager in C++. <code>mamba</code> is notably much faster and essentially compatible with <code>conda</code>, so it also works with <a href="https://github.com/necaris/conda.el">conda.el</a>. <code>micromamba</code>, however, implements only a subset of <code>mamba</code> commands, and as such requires a separate integration.</p>
<h2 id="installation">Installation</h2>
<p>The package is available on MELPA. Install it however you normally install packages, I prefer <code>use-package</code> and <code>straight</code>:</p>
<div class="highlight"><pre tabindex="0" style=";-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-emacs-lisp" data-lang="emacs-lisp"><span style="display:flex;"><span>(<span style="color:#008000">use-package</span> <span style="color:#19177c">micromamba</span>
</span></span><span style="display:flex;"><span> <span style="color:#008000">:straight</span> <span style="color:#800">t</span>)
</span></span></code></pre></div><p>Or clone the repository, add it to the <code>load-path</code> and <code>require</code> the package.</p>
<p>If your <code>micromamba</code> binary is located in some place unknown to <code>executable-find</code>, set the <code>micromamba-executable</code> variable.</p>
<p>If you are running shells (e.g. <a href="https://github.com/akermu/emacs-libvterm">vterm</a>) from Emacs, you probably want to set <code>auto_activate_base</code> in your <a href="https://docs.conda.io/projects/conda/en/latest/user-guide/configuration/index.html">.condarc</a> or <a href="https://mamba.readthedocs.io/en/latest/user_guide/configuration.html">.mambarc</a>, because the shells are launched in the correct environment anyway.</p>
<h2 id="usage">Usage</h2>
<p>The package has two entrypoints:</p>
<ul>
<li><code>M-x micromamba-activate</code> - activate the environment</li>
<li><code>M-x micromamba-deactivate</code> - deactivate the environment</li>
</ul>
<p><code>micromamba-activate</code> prompts for the environment (by parsing <code>micromamba env list</code>). If some environments have duplicate names, these names are replaced by full paths.</p>
<p>I&rsquo;ve noticed that <code>micromamba</code> also sees <code>conda</code> environments, so migrating from <code>conda</code> was rather painless for me.</p>
<h2 id="implementation-notes">Implementation notes</h2>
<p>I initially wanted to extend <a href="https://github.com/necaris/conda.el">conda.el</a>, but decided it would be counterproductive for a few reasons.</p>
<p>First, <code>conda</code> is rather slow, so <code>conda.el</code> does various tricks to avoid calling the <code>conda</code> executable. For instance, it gets the environment list from scanning the anaconda home directory instead of running <code>conda env list</code>. This is really not necessary with <code>micromamba</code>, which is written in C++.</p>
<p>Second, and more importantly, <code>conda.el</code> relies heavily on passing <code>shell.posix+json</code> to <code>conda</code>. <code>micromamba</code> doesn&rsquo;t support that. It supports the <code>--json</code> flag in some places, but not in the <code>activate</code> command, so I have to parse the output of <code>micromamba shell -s bash activate</code> and <code>micromamba shell -s bash deactivate</code> to get the environment configuration.</p>
<p>This also means the package most likely won&rsquo;t work out-of-the-box on Windows.</p>
</div>
<div class="table-of-contents">
<div class="table-of-contents-text">
<b><a href="#">Table of Contents</a></b>
<nav id="TableOfContents">
<ul>
<li><a href="#installation">Installation</a></li>
<li><a href="#usage">Usage</a></li>
<li><a href="#implementation-notes">Implementation notes</a></li>
</ul>
</nav>
</div>
<a id="unhide-all-button" class="hidden">&lt;Expand&gt;</a>
<a id="hide-all-button" class="hidden">&lt;Collapse&gt;</a>
</div>
</div>
</div><div id="footer" class="mb-5">
<hr>
<div class="container text-center">
</div>
<div class="container text-center">
<a href="https://creativecommons.org/licenses/by/4.0/legalcode" title="Licensed under CC-BY 4.0"><small>Licensed under CC-BY 4.0</small></a>
|
<a href="https://plausible.io/" title="Uses Plausible Analytics"><small>Uses Plausible Analytics</small></a>
<br>
<a href="https://sqrtminusone.xyz/" title="Pavel Korytov, 2023"><small>Pavel Korytov, 2023</small></a>
</div>
</div>
</body>
</html>