refactor documentation (#953)

This commit is contained in:
Adrien Delsalle 2021-05-20 18:30:31 +02:00 committed by GitHub
parent 842e4447e4
commit 3823b6a7ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 1562 additions and 505 deletions

View File

@ -0,0 +1,181 @@
=============
Build locally
=============
Local development environment
=============================
Clone the repo
**************
Start by cloning the repo:
.. code::
git clone https://github.com/mamba-org/mamba.git
Then move to the newly created directory:
.. code::
cd mamba
Install dev requirements
************************
| Make sure you have Mamba's development requirements installed in your environment.
| To do so, you can use your existing ``mamba`` or ``micromamba`` installation:
.. code::
mamba env update --name <env_name> --file environment-dev.yml
.. code::
micromamba install --name <env_name> --file environment-dev.yml
If you don't have one, refer to the :ref:`installation<installation>` page.
``mamba`` relies on ``python setup.py`` installation while others targets rely on ``cmake`` configuration.
.. note::
All ``cmake`` commands listed below use ``bash`` multi-line syntax.
On Windows, replace ``\`` trailing character with ``^``.
Build ``mamba``
===============
If you build ``mamba`` in a different environment than *base*, you must also install ``conda``
in that environment:
.. code::
mamba install conda -c conda-forge
For a local (dev) build, run in the environment:
.. code::
pip install -e .
This will build and install ``mamba`` in the current environment.
Build ``micromamba``
====================
Dynamically linked
******************
To build ``micromamba``, just activate the ``BUILD_EXE`` flag in ``cmake`` command:
.. code:: bash
mkdir -p build
cd build
cmake .. \
-BUILD_EXE=ON
cmake --build . -j
.. note::
Feel free to use your favorite generator: ``make``, ``ninja``, etc.
.. note::
If you need to install, use to install in your current development environment:
- ``-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX`` [unix]
- ``-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX\\Library`` [win]
| Doing so, you have built the dynamically linked version of ``micromamba``.
| It's well fitted for development but is not the artefact shipped when installing ``micromamba``.
Statically linked
*****************
``micromamba`` is a fully statically linked executable. To build it, you need to install extra requirements:
.. code::
micromamba install --name <env_name> --file environment-static-dev.yml
It will install the development version of dependencies, including static libraries.
Now you can run ``cmake`` with the additional flag ``STATIC_DEPENDENCIES`` turned on:
.. code:: bash
mkdir -p build
cd build
cmake .. \
-DBUILD_EXE=ON \
-DSTATIC_DEPENDENCIES=ON
cmake --build . -j
Tests
*****
You should now be able to run the Python-based test suite:
.. code::
pytest ./test/micromamba
Build ``libmamba``
==================
Shared library
**************
You need to enable the build of ``libmamba`` shared library using ``BUILD_SHARED`` flag in ``cmake`` command:
.. code:: bash
mkdir -p build
cd build
cmake .. \
-DBUILD_SHARED=ON
cmake --build . -j
Static library
**************
| The static build of ``libmamba`` is enabled by default (``BUILD_STATIC=ON``).
| You can run :
.. code:: bash
mkdir -p build
cd build
cmake ..
cmake --build . -j
Tests
*****
First, compile the ``gtest``-based C++ test suite:
.. code::
mkdir -p build
cd build
cmake .. \
-DENABLE_TESTS=ON
cmake --build . -j
You should now be able to run:
.. code::
./test/test_mamba
Alternatively you can use:
.. code::
make test
.. note::
The static version of ``libmamba`` is necessary to build the C++ tests, don't disable it!

View File

@ -0,0 +1,15 @@
==============
Contributing
==============
When contributing to this repository, it is always a good idea to first
discuss the change you wish to make via issue, email, or any other method with
the owners of this repository before making a change.
We welcome all kinds of contribution -- code or non-code -- and value them
highly. We pledge to treat everyones contribution fairly and with respect and
we are here to help awesome pull requests over the finish line.
Please note we have a code of conduct, and follow it in all your interactions with the project.
We follow the `NumFOCUS code of conduct <https://numfocus.org/code-of-conduct>`_.

View File

@ -0,0 +1,8 @@
Internals of mamba
==================
Mamba comes with a C++ core (for speed and efficiency), and a clean Python API on top. The core of mamba uses:
- ``libsolv`` to solve dependencies (the same library used in RedHat dnf and other Linux package managers)
- ``curl`` for reliable and fast downloads
- ``libarchive`` to extract the packages

View File

@ -1,33 +0,0 @@
Getting started with mamba
==========================
For new users
-------------
We strongly recommend to start from `mambaforge`, a community project of the conda-forge community.
You can download `mambaforge` for [Windows, macOS and Linux under this link](https://github.com/conda-forge/miniforge#mambaforge).
Mambaforge comes with the popular `conda-forge` channel preconfigured, but you can modify the configuration to use any channel you like.
After successful installation, you can use the mamba commands as described in [How to Use](how_to_use).
For conda users
---------------
If you are already a conda user, very good! Using mamba will feel natural.
To get mamba, install it _into the base environment_ from the `conda-forge` channel:
```
conda install mamba -n base -c conda-forge
```
_Note: Installing mamba into any other environment can cause unexpected behavior._
There is little difference between using conda & mamba. You can swap almost all commands:
- `mamba install ...`
- `mamba create -n ... -c ... ...`
- `mamba list`
The one difference is that you should still use `conda` for activation and deactivation.

View File

@ -1,8 +0,0 @@
Internals of mamba
==================
Mamba comes with a C++ core (for speed and efficiency), and a clean Python API on top. The core of mamba uses:
- `libsolv` to solve dependencies (the same library used in RedHat dnf and other Linux package managers)
- `curl` for reliable and fast downloads
- `libarchive` to extract the packages

View File

@ -1,35 +0,0 @@
How to use mamba
================
If you already know `conda`, great, you already know `mamba`! mamba is a drop-in replacement and uses the same commands and configuration options as conda.
For everyone else, here is a short overview over how to use mamba:
Create an environment
---------------------
Mamba handles multiple environments. The initial environment is called the _base_ environment and in general, you should not install packages into the base environment. Rather it's good practice to create new environments whenever you work on a specific project. Mamba has advanced file deduplication to keep the memory footprint of having multiple environments low.
The `mamba create` command creates a new environment. Mamba's environments are similar to virtual environments known from Python's `virtualenv` and similar software, but more powerful since mamba also manages _native_ dependencies and generalizes the virtual environment concept to many programming languages.
You can create a virtual environment with the name `nameofmyenv` by calling
```
mamba create -n nameofmyenv <list of packages>
```
After this process has finished, you can _activate_ the virtual environment by calling `conda activate <nameofmyenv>`.
For example, to install JupyterLab from the `conda-forge` channel and then run it, you could use the following commands:
```
mamba create -n myjlabenv jupyterlab -c conda-forge
conda activate myjlabenv # activate our environment
jupyter lab # this will start up jupyter lab and open a browser
```
Once an environment is activated, `mamba install` can be used to install further packages into the environment.
```
conda activate myjlabenv
mamba install bqplot # now you can use bqplot in myjlabenv
```

View File

@ -1,29 +0,0 @@
Welcome to mamba's documentation!
=================================
Mamba is a fast, robust, and cross-platform package manager that runs on Windows, OS X and Linux (ARM64 and PPC64LE included).
Mamba is fully compatible with `conda` packages and supports most of conda's commands. In fact, mamba was conceived as a _drop-in_ replacement for conda, offering higher speed and more reliable environment solutions.
We recommend to [start from `mambaforge`](getting_started) or install mamba through `conda install mamba -n base -c conda-forge`, if you're already a conda user.
Mamba also offers a flavor specifically for the CI use-case ([micromamba](micromamba)). Micromamba is a single-file executable that comes with everything to start installing packages.
```{toctree}
:maxdepth: 2
:caption: "Contents:"
getting_started
how_to_use
python_api
micromamba
how_mamba_works
```
Indices and tables
==================
* {ref}`Index <genindex>`
* {ref}`Search <search>`
<!-- * {ref}`modindex <modindex>` -->

54
docs/source/index.rst Normal file
View File

@ -0,0 +1,54 @@
Welcome to Mamba's documentation!
=================================
Mamba is a fast, robust, and cross-platform package manager.
It runs on Windows, OS X and Linux (ARM64 and PPC64LE included) and is fully compatible with ``conda`` packages and supports most of conda's commands.
The ``mamba-org`` organization hosts multiple Mamba flavors:
- ``mamba``: a Python-based CLI conceived as a *drop-in* replacement for ``conda``, offering higher speed and more reliable environment solutions
- ``micromamba``: a pure C++-based CLI, self-contained in a single-file executable
- ``libmamba``: a C++ library exposing low-level and high-level APIs on top of which both ``mamba`` and ``micromamba`` are built
.. note::
In this documentation, ``Mamba`` will refer to all flavors while flavor-specific details will mention ``mamba``, ``micromamba`` or ``libmamba``.
.. note::
:ref:`micromamba<micromamba>` is especially well fitted for the CI use-case but not limited to that!
You can try Mamba now by visiting the :ref:`installation page<installation>`!
.. toctree::
:caption: INSTALLATION
:maxdepth: 2
:hidden:
installation
.. toctree::
:caption: USER GUIDE
:maxdepth: 2
:hidden:
user_guide/concepts
user_guide/mamba
user_guide/micromamba
user_guide/configuration
.. toctree::
:caption: API reference
:maxdepth: 2
:hidden:
python_api
.. toctree::
:caption: developer zone
:maxdepth: 2
:hidden:
developer_zone/contributing
developer_zone/build_locally
developer_zone/internals

View File

@ -0,0 +1,146 @@
.. _installation:
============
Installation
============
.. _mamba-install:
mamba
=====
Fresh install
*************
We strongly recommend to start from ``mambaforge``, a community project of the conda-forge community.
| You can download `mambaforge <https://github.com/conda-forge/miniforge#mambaforge>`_ for Windows, macOS and Linux.
| ``mambaforge`` comes with the popular ``conda-forge`` channel preconfigured, but you can modify the configuration to use any channel you like.
| After successful installation, you can use the mamba commands as described in :ref:`mamba user guide<mamba>`.
Existing ``conda`` install
**************************
If you are already a ``conda`` user, very good!
To get ``mamba``, just install it *into the base environment* from the ``conda-forge`` channel:
.. code::
conda install mamba -n base -c conda-forge
.. warning::
Installing mamba into any other environment than base can cause unexpected behavior
.. _umamba-install:
micromamba
==========
``micromamba`` is completely statically linked, which allows you to drop it in some place and just execute it.
Download and unzip the executable (from the official conda-forge package):
.. _umamba-install-linux:
Linux
*****
Ensure that basic utilities are installed. We need ``wget`` and ``tar`` with support for ``bzip2``.
Also you need a glibc based system like Ubuntu, Fedora or Centos (Alpine Linux does not work natively).
The following magic URL always returns the latest available version of micromamba, and the ``bin/micromamba`` part is automatically extracted using ``tar``.
.. code:: sh
wget -qO- https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
.. note::
Additional builds are available for linux-aarch64 (ARM64) and linux-ppc64le. Just modify ``linux-64`` in the URL above to match the desired architecture.
After extraction is completed, we can use the micromamba binary.
If you want to quickly use micromamba in an ad-hoc usecase, you can run
.. code::
export MAMBA_ROOT_PREFIX=/some/prefix # optional, defaults to ~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
This shell hook modifies your shell variables to include the micromamba command.
If you want to persist these changes, you can automatically write them to your ``.bashrc`` (or ``.zshrc``) by running ``./micromamba shell init ...``.
This also allows you to choose a custom MAMBA_ROOT_ENVIRONMENT, which is where the packages and repodata cache will live.
.. code::
sh
./bin/micromamba shell init -s bash -p ~/micromamba # this writes to your .bashrc file
# sourcing the bashrc file incorporates the changes into the running session.
# better yet, restart your terminal!
source ~/.bashrc
Now you can activate the base environment and install new packages, or create other environments.
.. code::
micromamba activate # this activates the base environment
micromamba install python=3.6 jupyter -c conda-forge
# or
micromamba create -n new_prefix xtensor -c conda-forge
micromamba activate new_prefix
.. _umamba-install-osx:
OS X
****
``micromamba`` has OS X support as well. Instructions are largely the same as :ref:`linux<umamba-install-linux>`:
.. code:: bash
curl -Ls https://micro.mamba.pm/api/micromamba/osx-64/latest | tar -xvj bin/micromamba
mv bin/micromamba ./micromamba
# directly execute the hook
eval "$(./bin/micromamba shell hook -s posix)"
# ... or shell init
./micromamba shell init -s zsh -p ~/micromamba
source ~/.zshrc
micromamba activate
micromamba install python=3.6 jupyter -c conda-forge
.. _umamba-install-win:
Windows
*******
| ``micromamba`` also has Windows support! For Windows, we recommend powershell.
| Below are the commands to get micromamba installed in ``PowerShell``.
.. code:: powershell
Invoke-Webrequest -URI https://micro.mamba.pm/api/micromamba/win-64/latest -OutFile micromamba.tar.bz2
C:\PROGRA~1\7-Zip\7z.exe x micromamba.tar.bz2 -aoa
C:\PROGRA~1\7-Zip\7z.exe x micromamba.tar -ttar -aoa -r Library\bin\micromamba.exe
MOVE -Force Library\bin\micromamba.exe micromamba.exe
.\micromamba.exe --help
# You can use e.g. $HOME\micromambaenv as your base prefix
$Env:MAMBA_ROOT_PREFIX="C:\Your\Root\Prefix"
# Invoke the hook
.\micromamba.exe shell hook -s powershell | Out-String | Invoke-Expression
# ... or initialize the shell
.\micromamba.exe shell init -s powershell -p C:\Your\Root\Prefix
# and use micromamba directly
micromamba create -f ./test/env_win.yaml -y
micromamba activate yourenv

View File

@ -1,266 +0,0 @@
# micromamba
Micromamba is a small, pure-C++ executable with enough functionalities to _bootstrap_ fully functional conda-environments.
Currently, given micromamba's early stage, it's main usage is in continous integration pipelines: since it's a single executable, based on mamba, it bootstraps _fast_.
```{admonition} Warning
:class: warning
Note that micromamba is still in early development and not considered ready-for-general-usage yet! It has been used with great success in CI systems, though, and we encourage this usage.
```
## Installation
`micromamba` works in the bash & zsh shell on Linux & OS X.
It's completely statically linked, which allows you to drop it in some place and just execute it.
Note: it's advised to use micromamba in containers & CI only.
Download and unzip the executable (from the official conda-forge package):
#### Linux / Basic Usage
Ensure that basic utilities are installed. We need `wget` and `tar` with support for `bzip2`.
Also you need a glibc based system like Ubuntu, Fedora or Centos (Alpine Linux does not work natively).
The following magic URL always returns the latest available version of micromamba, and the `bin/micromamba` part is automatically extracted using `tar`.
```sh
wget -qO- https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
```
```{admonition} Warning
:class: info
Additional builds are available for linux-aarch64 (ARM64) and linux-ppc64le. Just modify `linux-64` in the URL above to match the desired architecture.
```
After extraction is completed, we can use the micromamba binary.
If you want to quickly use micromamba in an ad-hoc usecase, you can run
```
export MAMBA_ROOT_PREFIX=/some/prefix # optional, defaults to ~/micromamba
eval "$(./bin/micromamba shell hook -s posix)"
```
This shell hook modifies your shell variables to include the micromamba command.
If you want to persist these changes, you can automatically write them to your `.bashrc` (or `.zshrc`) by running `./micromamba shell init ... `.
This also allows you to choose a custom MAMBA_ROOT_ENVIRONMENT, which is where the packages and repodata cache will live.
```sh
./bin/micromamba shell init -s bash -p ~/micromamba # this writes to your .bashrc file
# sourcing the bashrc file incorporates the changes into the running session.
# better yet, restart your terminal!
source ~/.bashrc
```
Now you can activate the base environment and install new packages, or create other environments.
```sh
micromamba activate # this activates the base environment
micromamba install python=3.6 jupyter -c conda-forge
# or
micromamba create -n new_prefix xtensor -c conda-forge
micromamba activate new_prefix
```
#### OS X
Micromamba has OS X support as well. Instructions are largely the same:
```sh
curl -Ls https://micro.mamba.pm/api/micromamba/osx-64/latest | tar -xvj bin/micromamba
mv bin/micromamba ./micromamba
# directly execute the hook
eval "$(./bin/micromamba shell hook -s posix)"
# ... or shell init
./micromamba shell init -s zsh -p ~/micromamba
source ~/.zshrc
micromamba activate
micromamba install python=3.6 jupyter -c conda-forge
```
#### Windows
Micromamba also has Windows support! For Windows, we recommend powershell. Below are the commands to get micromamba installed in `PowerShell`.
```powershell
Invoke-Webrequest -URI https://micro.mamba.pm/api/micromamba/win-64/latest -OutFile micromamba.tar.bz2
C:\PROGRA~1\7-Zip\7z.exe x micromamba.tar.bz2 -aoa
C:\PROGRA~1\7-Zip\7z.exe x micromamba.tar -ttar -aoa -r Library\bin\micromamba.exe
MOVE -Force Library\bin\micromamba.exe micromamba.exe
.\micromamba.exe --help
# You can use e.g. $HOME\micromambaenv as your base prefix
$Env:MAMBA_ROOT_PREFIX="C:\Your\Root\Prefix"
# Invoke the hook
.\micromamba.exe shell hook -s powershell | Out-String | Invoke-Expression
# ... or initialize the shell
.\micromamba.exe shell init -s powershell -p C:\Your\Root\Prefix
# and use micromamba directly
micromamba create -f ./test/env_win.yaml -y
micromamba activate ...
```
## Available commands
Micromamba supports a subset of all conda commands and implements a command line interface from scratch. You can see all implemented commands with `micromamba --help`:
```
$ micromamba --help
Subcommands:
activate Activate a conda / micromamba environment
deactivate Deactivate a conda / micromamba environment
shell Generate shell init scripts
create Create new environment
install Install packages in active environment
remove Remove packages from active environment
list List packages in active environment
constructor Commands to support using micromamba in constructor
```
To activate an environment just call `micromamba activate /path/to/env` or, when it's a named environment in your `$MAMBA_ROOT_PREFIX`, then you can just use `micromamba activate myenv`. Named environments live in `$MAMBA_ROOT_PREFIX/envs/`.
After activation, the `$CONDA_PREFIX` and `$PATH` environment variables are modified to add the environment to your current bash session. You can then run install to add new packages to the environment.
```
$ micromamba install xtensor -c conda-forge
```
Using create you can also create new virtual environments. Named environments are convenient and easy to use. For example, to create a new environment:
```
$ micromamba create -n xtensor_env xtensor xsimd -c conda-forge
__
__ ______ ___ ____ _____ ___ / /_ ____ _
/ / / / __ `__ \/ __ `/ __ `__ \/ __ \/ __ `/
/ /_/ / / / / / / /_/ / / / / / / /_/ / /_/ /
/ .___/_/ /_/ /_/\__,_/_/ /_/ /_/_.___/\__,_/
/_/
conda-forge/noarch [====================] (00m:01s) Done
conda-forge/linux-64 [====================] (00m:04s) Done
Transaction
Prefix: /home/wolfv/miniconda3/envs/xtensor_env
Updating specs:
- xtensor
- xsimd
Package Version Build Channel Size
────────────────────────────────────────────────────────────────────────
Install:
────────────────────────────────────────────────────────────────────────
_libgcc_mutex 0.1 conda_forge conda-forge/linux-64 Cached
_openmp_mutex 4.5 1_gnu conda-forge/linux-64 Cached
libgcc-ng 9.3.0 h5dbcf3e_17 conda-forge/linux-64 Cached
libgomp 9.3.0 h5dbcf3e_17 conda-forge/linux-64 Cached
libstdcxx-ng 9.3.0 h2ae2ef3_17 conda-forge/linux-64 Cached
xsimd 7.4.9 hc9558a2_0 conda-forge/linux-64 102 KB
xtensor 0.21.9 h0efe328_0 conda-forge/linux-64 183 KB
xtl 0.6.21 h0efe328_0 conda-forge/linux-64 Cached
Summary:
Install: 8 packages
Total download: 285 KB
────────────────────────────────────────────────────────────────────────
Confirm changes: [Y/n] ...
```
After the installation is finished, the environment can be activated with
```
$ micromamba activate xtensor_env
```
## Environment files
The create syntax also allows you to use spec- or environment files to easily recreate environments.
The three supported syntaxes are: yaml, txt and explicit spec files.
#### Simple text spec files
The txt file contains _one spec per line_. For example, this could look like:
```
xtensor
numpy 1.19
xsimd >=7.4
```
To use this file, pass
```
$ micromamba create -n from_file -f spec_file.txt -c conda-forge
```
Note: with spec text files you can pass multiple files by repeating the `-f` argument.
#### YAML environment files
More powerful are YAML files like the following, because they already contain a desired environment name and the channels to use.
```
name: testenv
channels:
- conda-forge
dependencies:
- python >=3.6,<3.7
- ipykernel >=5.1
- ipywidgets
```
```
$ micromamba create -f env.yml
```
YAML files do not allow multiple files.
#### Explicit environment specs
Using conda you can generate _explicit_ environment lock files. For this, create an environment and execute
```
$ conda list --explicit --md5
```
These environment files look like the following and precisely "pin" the desired package + version + build string.
```
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: linux-64
@EXPLICIT
https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81
https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-ng-9.3.0-h2ae2ef3_17.tar.bz2#342f3c931d0a3a209ab09a522469d20c
https://conda.anaconda.org/conda-forge/linux-64/libgomp-9.3.0-h5dbcf3e_17.tar.bz2#8fd587013b9da8b52050268d50c12305
https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-1_gnu.tar.bz2#561e277319a41d4f24f5c05a9ef63c04
https://conda.anaconda.org/conda-forge/linux-64/libgcc-ng-9.3.0-h5dbcf3e_17.tar.bz2#fc9f5adabc4d55cd4b491332adc413e0
https://conda.anaconda.org/conda-forge/linux-64/xtl-0.6.21-h0efe328_0.tar.bz2#9eee90b98fd394db7a049792e67e1659
https://conda.anaconda.org/conda-forge/linux-64/xtensor-0.21.8-hc9558a2_0.tar.bz2#1030174db5c183f3afb4181a0a02873d
```
To install such a file with micromamba, just pass the `-f` flag again:
```
$ micromamba create -n xtensor -c conda-forge -f explicit_env.txt
```

View File

@ -1,134 +0,0 @@
# The Python API of mamba
The core of mamba is written in C++, but we expose the internals of mamba with a Python API (using pybind11).
You can import the `mamba_api` using `from mamba import mamba_api`.
The mamba_api exposes the following objects:
- `Context`: a singleton configuration object. All global configuration goes through this. From Python you can use the context object like so:
```
from mamba import mamba_api
mamba_api.Context().conda_prefix = "/home/wolfv/conda"
ctx = mamba_api.Context()
print(ctx.root_prefix)
```
Here is an example usage of the mamba_api:
```
def get_index(
channel_urls=(),
prepend=True,
platform=None,
use_local=False,
use_cache=False,
unknown=None,
prefix=None,
repodata_fn="repodata.json",
):
real_urls = calculate_channel_urls(channel_urls, prepend, platform, use_local)
check_whitelist(real_urls)
dlist = mamba_api.DownloadTargetList()
index = []
for idx, url in enumerate(real_urls):
channel = Channel(url)
full_url = channel.url(with_credentials=True) + "/" + repodata_fn
full_path_cache = os.path.join(
create_cache_dir(), cache_fn_url(full_url, repodata_fn)
)
# Channels might not have a name.
if channel.name is None:
name_and_subdir = channel.subdir
else:
name_and_subdir = channel.name + "/" + channel.subdir
sd = mamba_api.SubdirData(name_and_subdir, full_url, full_path_cache)
sd.load()
index.append((sd, channel))
dlist.add(sd)
is_downloaded = dlist.download(True)
if not is_downloaded:
raise RuntimeError("Error downloading repodata.")
return index
class MambaSolver:
def __init__(self, prefix, channels, platform):
api_ctx = mamba_api.Context()
api_ctx.conda_prefix = prefix
self.channels = channels
self.platform = platform
self.index = get_index(channels, platform=platform)
self.local_index = []
self.pool = mamba_api.Pool()
self.repos = []
start_prio = len(channels)
priority = start_prio
subpriority = 0 # wrong! :)
for subdir, channel in self.index:
repo = mamba_api.Repo(
self.pool,
str(channel),
subdir.cache_path(),
channel.url(with_credentials=True),
)
repo.set_priority(start_prio, subpriority)
start_prio -= 1
self.repos.append(repo)
self.local_repos = {}
def solve(self, specs, prefix):
"""Solve given a set of specs.
Parameters
----------
specs : list of str
A list of package specs. You can use `conda.models.match_spec.MatchSpec`
to get them to the right form by calling
`MatchSpec(mypec).conda_build_form()`
Returns
-------
solvable : bool
True if the set of specs has a solution, False otherwise.
"""
solver_options = [(mamba_api.SOLVER_FLAG_ALLOW_DOWNGRADE, 1)]
api_solver = mamba_api.Solver(self.pool, solver_options)
_specs = specs
api_solver.add_jobs(_specs, mamba_api.SOLVER_INSTALL)
success = api_solver.solve()
if not success:
error_string = "Mamba failed to solve:\n"
for s in _specs:
error_string += f" - {s}\n"
error_string += "\nwith channels:\n"
for c in self.channels:
error_string += f" - {c}\n"
pstring = api_solver.problems_to_str()
pstring = "\n".join([" " + l for l in pstring.split("\n")])
error_string += f"\nThe reported errors are:\n⇟{pstring}"
print(error_string)
exit(1)
package_cache = mamba_api.MultiPackageCache(pkgs_dirs)
t = mamba_api.Transaction(api_solver, package_cache)
return t
```
Let's walk through this example:
We first use the `get_index` method to download repository data from the channels.

137
docs/source/python_api.rst Normal file
View File

@ -0,0 +1,137 @@
=======================
Python API of ``mamba``
=======================
The core of ``mamba`` is written in C++, but we expose the internals of mamba with a Python API (using ``pybind11``).
You can import the ``mamba_api`` using ``from mamba import mamba_api``.
The mamba_api exposes the following objects:
- ``Context``: a singleton configuration object. All global configuration goes through this. From Python you can use the context object like so:
.. code::
from mamba import mamba_api
mamba_api.Context().conda_prefix = "/home/wolfv/conda"
ctx = mamba_api.Context()
print(ctx.root_prefix)
Here is an example usage of the mamba_api:
.. code::
def get_index(
channel_urls=(),
prepend=True,
platform=None,
use_local=False,
use_cache=False,
unknown=None,
prefix=None,
repodata_fn="repodata.json",
):
real_urls = calculate_channel_urls(channel_urls, prepend, platform, use_local)
check_whitelist(real_urls)
dlist = mamba_api.DownloadTargetList()
index = []
for idx, url in enumerate(real_urls):
channel = Channel(url)
full_url = channel.url(with_credentials=True) + "/" + repodata_fn
full_path_cache = os.path.join(
create_cache_dir(), cache_fn_url(full_url, repodata_fn)
)
# Channels might not have a name.
if channel.name is None:
name_and_subdir = channel.subdir
else:
name_and_subdir = channel.name + "/" + channel.subdir
sd = mamba_api.SubdirData(name_and_subdir, full_url, full_path_cache)
sd.load()
index.append((sd, channel))
dlist.add(sd)
is_downloaded = dlist.download(True)
if not is_downloaded:
raise RuntimeError("Error downloading repodata.")
return index
class MambaSolver:
def __init__(self, prefix, channels, platform):
api_ctx = mamba_api.Context()
api_ctx.conda_prefix = prefix
self.channels = channels
self.platform = platform
self.index = get_index(channels, platform=platform)
self.local_index = []
self.pool = mamba_api.Pool()
self.repos = []
start_prio = len(channels)
priority = start_prio
subpriority = 0 # wrong! :)
for subdir, channel in self.index:
repo = mamba_api.Repo(
self.pool,
str(channel),
subdir.cache_path(),
channel.url(with_credentials=True),
)
repo.set_priority(start_prio, subpriority)
start_prio -= 1
self.repos.append(repo)
self.local_repos = {}
def solve(self, specs, prefix):
"""Solve given a set of specs.
Parameters
----------
specs : list of str
A list of package specs. You can use `conda.models.match_spec.MatchSpec`
to get them to the right form by calling
`MatchSpec(mypec).conda_build_form()`
Returns
-------
solvable : bool
True if the set of specs has a solution, False otherwise.
"""
solver_options = [(mamba_api.SOLVER_FLAG_ALLOW_DOWNGRADE, 1)]
api_solver = mamba_api.Solver(self.pool, solver_options)
_specs = specs
api_solver.add_jobs(_specs, mamba_api.SOLVER_INSTALL)
success = api_solver.solve()
if not success:
error_string = "Mamba failed to solve:\n"
for s in _specs:
error_string += f" - {s}\n"
error_string += "\nwith channels:\n"
for c in self.channels:
error_string += f" - {c}\n"
pstring = api_solver.problems_to_str()
pstring = "\n".join([" " + l for l in pstring.split("\n")])
error_string += f"\nThe reported errors are:\n⇟{pstring}"
print(error_string)
exit(1)
package_cache = mamba_api.MultiPackageCache(pkgs_dirs)
t = mamba_api.Transaction(api_solver, package_cache)
return t
Let's walk through this example:
We first use the ``get_index`` method to download repository data from the channels.

View File

@ -0,0 +1,87 @@
.. _concepts:
Concepts
--------
Few concepts are extensively used in ``Mamba`` and in this documentation as well.
You should start by getting familiar with those as a starting point.
.. _prefix:
Prefix/Environment
==================
In Unix-like platforms, installing a software consists in placing files in subdirectories of an "installation prefix":
.. image:: prefix.png
:height: 300
:align: center
- no file is placed outside of the installation *prefix*
- dependencies must be installed in the same *prefix* (or standard system prefixes with lower precedence)
.. note::
Examples on Unix: the root of the filesystem, the ``/usr/`` and ``/usr/local/`` directories.
| A *prefix* is a fully self-contained and portable installation.
| To disambiguate with :ref:`root prefix<root-prefix>`, *prefix* is often called *target prefix*. Without explicit *target* or *root* reference, you can assume it points a *target prefix*.
An *environment* is just another way to call a *target prefix*.
Mamba's environments are similar to virtual environments known from Python's ``virtualenv`` and similar software, but more powerful since Mamba also manages *native* dependencies and generalizes the virtual environment concept to many programming languages.
.. _root-prefix:
Root prefix
===========
When downloading for the first time the index of packages for resolution of the environment, or the packages themselves, a *cache* is generated to speed-up next operations:
- the index has a :ref:`configurable<configuration>` time-to-live (TTL) during which it will be considered as valid
- the packages are preferentially hard-linked to the *cache* location
This *cache* is shared by all *environments* or *target prefixes* based on the same *root prefix*. Basically, that *cache* directory is a subdirectory located at ``$root_prefix/pkgs/``.
The *root prefix* also provide a convenient structure to store *environments* ``$root_prefix/envs/``, even if you are free to create an *environment* elsewhere.
.. _base-env:
Base environment
================
The *base* environment is the environment located at the *root prefix*.
| This is a legacy *environment* from ``conda`` implementation still heavily used.
| The *base* environment contains the ``conda`` and ``mamba`` installation alongside a Python installation (since ``mamba`` and ``conda`` require Python to run)
| ``mamba`` and ``conda`` being themselves Python packages, they are installed in *base* environment, making the CLIs available in all *activated* environment *based* on this *base* environement.
.. note::
You can't ``create`` *base* environment because it's already part of the *root prefix* structure, directly ``install`` in *base* instead.
Activation/Deactivation
=======================
.. _activation:
Activation
**********
The *activation* of an :ref:`environment<prefix>` makes all its contents available to your shell. It mainly adds *target prefix* subdirectories to your ``$PATH`` environment variable.
.. note::
*activation* implementation is platform dependent.
| When *activating* an environment from another, you can choose to ``stack`` or not upon the currently activated env.
| Stacking will result in a new intermediate :ref:`prefix<prefix>`: ``system prefix < base < env1 < env2``.
.. _deactivation:
Deactivation
************
The *deactivation* is the opposite operation of :ref:`activation<activation>`, removing from your shell what makes the environment content accessible.

View File

@ -0,0 +1,293 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="1092.0388mm"
height="132.01334mm"
viewBox="0 0 1092.0388 132.01333"
version="1.1"
id="svg187">
<defs
id="defs181" />
<metadata
id="metadata184">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(285.88901,-110.92898)">
<g
id="g117"
transform="matrix(0,0.26458333,-0.42977593,0,378.89058,94.459492)"
style="fill:#91c23d;fill-opacity:1">
<g
id="g115"
style="fill:#91c23d;fill-opacity:1">
<g
id="g419"
style="fill:#91c23d;fill-opacity:1">
<g
id="g450"
style="fill:#91c23d;fill-opacity:1">
<g
id="g453"
style="fill:#91c23d;fill-opacity:1">
<path
d="m 438.755,53.927998 -178.179,-89.458 c -2.88,-1.446 -6.274,-1.446 -9.153,0 l -178.177,89.458 c -3.447,1.731 -5.623,5.259 -5.623,9.115 V 347.895 c 0,3.538 1.833,6.823 4.845,8.681 3.01,1.858 6.769,2.022 9.931,0.434 L 256,269.849 429.603,357.011 c 1.443,0.724 3.011,1.084 4.575,1.084 1.862,0 3.72,-0.509 5.356,-1.519 3.012,-1.858 4.845,-5.142 4.845,-8.681 V 63.041998 c -0.001,-3.856 -2.176,-7.384 -5.624,-9.114 z M 423.98,331.363 260.577,249.323 c -2.88,-1.446 -6.274,-1.446 -9.153,0 L 88.022,331.363 V 69.334998 l 167.978,-84.338 167.98,84.338 z"
id="path113"
style="fill:#91c23d;fill-opacity:1" />
</g>
</g>
</g>
</g>
</g>
<g
id="g117-2"
transform="matrix(0,0.26458333,-0.42977593,0,208.59758,94.459492)"
style="fill:#1d7ec0;fill-opacity:1">
<g
id="g115-2"
style="fill:#1d7ec0;fill-opacity:1">
<g
id="g419-5"
style="fill:#1d7ec0;fill-opacity:1">
<g
id="g450-8"
style="fill:#1d7ec0;fill-opacity:1">
<g
id="g453-4"
style="fill:#1d7ec0;fill-opacity:1">
<path
d="m 438.755,53.927998 -178.179,-89.458 c -2.88,-1.446 -6.274,-1.446 -9.153,0 l -178.177,89.458 c -3.447,1.731 -5.623,5.259 -5.623,9.115 V 347.895 c 0,3.538 1.833,6.823 4.845,8.681 3.01,1.858 6.769,2.022 9.931,0.434 L 256,269.849 429.603,357.011 c 1.443,0.724 3.011,1.084 4.575,1.084 1.862,0 3.72,-0.509 5.356,-1.519 3.012,-1.858 4.845,-5.142 4.845,-8.681 V 63.041998 c -0.001,-3.856 -2.176,-7.384 -5.624,-9.114 z M 423.98,331.363 260.577,249.323 c -2.88,-1.446 -6.274,-1.446 -9.153,0 L 88.022,331.363 V 69.334998 l 167.978,-84.338 167.98,84.338 z"
id="path113-3"
style="fill:#1d7ec0;fill-opacity:1" />
</g>
</g>
</g>
</g>
</g>
<g
id="g117-2-2"
transform="matrix(0,0.26458333,-0.42977593,0,38.304581,94.459492)"
style="fill:#57cbab;fill-opacity:1">
<g
id="g115-2-0"
style="fill:#57cbab;fill-opacity:1">
<g
id="g419-5-8"
style="fill:#57cbab;fill-opacity:1">
<g
id="g450-8-9"
style="fill:#57cbab;fill-opacity:1">
<g
id="g453-4-1"
style="fill:#57cbab;fill-opacity:1">
<path
d="m 438.755,53.927998 -178.179,-89.458 c -2.88,-1.446 -6.274,-1.446 -9.153,0 l -178.177,89.458 c -3.447,1.731 -5.623,5.259 -5.623,9.115 V 347.895 c 0,3.538 1.833,6.823 4.845,8.681 3.01,1.858 6.769,2.022 9.931,0.434 L 256,269.849 429.603,357.011 c 1.443,0.724 3.011,1.084 4.575,1.084 1.862,0 3.72,-0.509 5.356,-1.519 3.012,-1.858 4.845,-5.142 4.845,-8.681 V 63.041998 c -0.001,-3.856 -2.176,-7.384 -5.624,-9.114 z M 423.98,331.363 260.577,249.323 c -2.88,-1.446 -6.274,-1.446 -9.153,0 L 88.022,331.363 V 69.334998 l 167.978,-84.338 167.98,84.338 z"
id="path113-3-3"
style="fill:#57cbab;fill-opacity:1" />
</g>
</g>
</g>
</g>
</g>
<g
id="g117-2-1"
transform="matrix(0,0.26458333,-0.42977593,0,-131.9884,94.459492)"
style="fill:#58687a;fill-opacity:1">
<g
id="g115-2-1"
style="fill:#58687a;fill-opacity:1">
<g
id="g419-5-3"
style="fill:#58687a;fill-opacity:1">
<g
id="g450-8-8"
style="fill:#58687a;fill-opacity:1">
<g
id="g453-4-3"
style="fill:#58687a;fill-opacity:1">
<path
d="m 438.755,53.927998 -178.179,-89.458 c -2.88,-1.446 -6.274,-1.446 -9.153,0 l -178.177,89.458 c -3.447,1.731 -5.623,5.259 -5.623,9.115 V 347.895 c 0,3.538 1.833,6.823 4.845,8.681 3.01,1.858 6.769,2.022 9.931,0.434 L 256,269.849 429.603,357.011 c 1.443,0.724 3.011,1.084 4.575,1.084 1.862,0 3.72,-0.509 5.356,-1.519 3.012,-1.858 4.845,-5.142 4.845,-8.681 V 63.041998 c -0.001,-3.856 -2.176,-7.384 -5.624,-9.114 z M 423.98,331.363 260.577,249.323 c -2.88,-1.446 -6.274,-1.446 -9.153,0 L 88.022,331.363 V 69.334998 l 167.978,-84.338 167.98,84.338 z"
id="path113-3-2"
style="fill:#58687a;fill-opacity:1" />
</g>
</g>
</g>
</g>
</g>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:29.836px;line-height:1.25;font-family:sans-serif;fill:#91c23d;fill-opacity:1;stroke:none;stroke-width:0.14918"
x="323.44699"
y="148.77786"
id="text577"
transform="scale(0.97660315,1.0239574)"><tspan
id="tspan575"
x="323.44699"
y="148.77786"
style="font-size:29.836px;text-align:center;text-anchor:middle;fill:#91c23d;fill-opacity:1;stroke-width:0.14918">Target</tspan><tspan
x="323.44699"
y="186.07286"
style="font-size:29.836px;text-align:center;text-anchor:middle;fill:#91c23d;fill-opacity:1;stroke-width:0.14918"
id="tspan1868">prefix</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:28.476px;line-height:1.25;font-family:sans-serif;fill:#1d7ec0;fill-opacity:1;stroke:none;stroke-width:0.14238"
x="146.91801"
y="151.09187"
id="text577-3"
transform="scale(0.98573502,1.0144714)"><tspan
id="tspan575-4"
x="146.91801"
y="151.09187"
style="font-size:28.476px;text-align:center;text-anchor:middle;fill:#1d7ec0;fill-opacity:1;stroke-width:0.14238">User</tspan><tspan
x="146.91801"
y="186.68687"
style="font-size:28.476px;text-align:center;text-anchor:middle;fill:#1d7ec0;fill-opacity:1;stroke-width:0.14238"
id="tspan1870">home</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:29.0892px;line-height:1.25;font-family:sans-serif;fill:#57cbab;fill-opacity:1;stroke:none;stroke-width:0.145446"
x="-30.918478"
y="144.39604"
id="text577-3-4"
transform="scale(0.95646011,1.0455219)"><tspan
id="tspan575-4-8"
x="-30.91848"
y="144.39604"
style="font-size:29.0892px;text-align:center;text-anchor:middle;fill:#57cbab;fill-opacity:1;stroke-width:0.145446">Root</tspan><tspan
x="-30.91848"
y="180.75754"
style="font-size:29.0892px;text-align:center;text-anchor:middle;fill:#57cbab;fill-opacity:1;stroke-width:0.145446"
id="tspan1866">prefix</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:28.7086px;line-height:1.25;font-family:sans-serif;fill:#58687a;fill-opacity:1;stroke:none;stroke-width:0.143543"
x="-248.2466"
y="161.89194"
id="text577-3-0"
transform="scale(0.9546217,1.0475354)"><tspan
id="tspan575-4-6"
x="-248.2466"
y="161.89194"
style="font-size:28.7086px;fill:#58687a;fill-opacity:1;stroke-width:0.143543">System</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-286.52753"
y="241.33215"
id="text1502"><tspan
id="tspan1500"
x="-286.52753"
y="241.33215"
style="stroke-width:0.264583"><tspan
style="font-size:21.1667px"
id="tspan1644">lowest</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:21.1667px;line-height:1.25;font-family:sans-serif;fill:#323232;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="728.15967"
y="238.53947"
id="text1502-8"><tspan
id="tspan1500-0"
x="728.15967"
y="238.53947"
style="font-size:21.1667px;fill:#323232;fill-opacity:1;stroke-width:0.264583">highest</tspan></text>
<g
id="g117-1"
transform="matrix(0,0.26458333,-0.42977593,0,551.19921,94.218725)"
style="fill:#f9a230;fill-opacity:1">
<g
id="g115-0"
style="fill:#f9a230;fill-opacity:1">
<g
id="g419-2"
style="fill:#f9a230;fill-opacity:1">
<g
id="g450-7"
style="fill:#f9a230;fill-opacity:1">
<g
id="g453-3"
style="fill:#f9a230;fill-opacity:1">
<path
d="m 438.755,53.927998 -178.179,-89.458 c -2.88,-1.446 -6.274,-1.446 -9.153,0 l -178.177,89.458 c -3.447,1.731 -5.623,5.259 -5.623,9.115 V 347.895 c 0,3.538 1.833,6.823 4.845,8.681 3.01,1.858 6.769,2.022 9.931,0.434 L 256,269.849 429.603,357.011 c 1.443,0.724 3.011,1.084 4.575,1.084 1.862,0 3.72,-0.509 5.356,-1.519 3.012,-1.858 4.845,-5.142 4.845,-8.681 V 63.041998 c -0.001,-3.856 -2.176,-7.384 -5.624,-9.114 z M 423.98,331.363 260.577,249.323 c -2.88,-1.446 -6.274,-1.446 -9.153,0 L 88.022,331.363 V 69.334998 l 167.978,-84.338 167.98,84.338 z"
id="path113-6"
style="fill:#f9a230;fill-opacity:1" />
</g>
</g>
</g>
</g>
</g>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:29.836px;line-height:1.25;font-family:sans-serif;fill:#f9a230;fill-opacity:1;stroke:none;stroke-width:0.14918"
x="499.06799"
y="148.77307"
id="text577-37"
transform="scale(0.97660313,1.0239574)"><tspan
x="499.06799"
y="148.77307"
style="font-size:29.836px;text-align:center;text-anchor:middle;fill:#f9a230;fill-opacity:1;stroke-width:0.14918"
id="tspan1868-0">Env</tspan><tspan
x="499.06799"
y="186.06807"
style="font-size:29.836px;text-align:center;text-anchor:middle;fill:#f9a230;fill-opacity:1;stroke-width:0.14918"
id="tspan1902">var</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:1.90403px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 592.70824,110.94511 1.7761,104.81468"
id="path1904" />
<path
style="fill:none;stroke:#000000;stroke-width:1.90403px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 603.26282,110.94511 1.7761,104.81468"
id="path1904-4" />
<g
id="g117-1-4"
transform="matrix(0,0.26458333,-0.42977593,0,786.79871,94.218725)"
style="fill:#dd2919;fill-opacity:1;stroke:none;stroke-opacity:1">
<g
id="g115-0-7"
style="fill:#dd2919;fill-opacity:1;stroke:none;stroke-opacity:1">
<g
id="g419-2-1"
style="fill:#dd2919;fill-opacity:1;stroke:none;stroke-opacity:1">
<g
id="g450-7-8"
style="fill:#dd2919;fill-opacity:1;stroke:none;stroke-opacity:1">
<g
id="g453-3-4"
style="fill:#dd2919;fill-opacity:1;stroke:none;stroke-opacity:1">
<path
d="m 438.755,53.927998 -178.179,-89.458 c -2.88,-1.446 -6.274,-1.446 -9.153,0 l -178.177,89.458 c -3.447,1.731 -5.623,5.259 -5.623,9.115 V 347.895 c 0,3.538 1.833,6.823 4.845,8.681 3.01,1.858 6.769,2.022 9.931,0.434 L 256,269.849 429.603,357.011 c 1.443,0.724 3.011,1.084 4.575,1.084 1.862,0 3.72,-0.509 5.356,-1.519 3.012,-1.858 4.845,-5.142 4.845,-8.681 V 63.041998 c -0.001,-3.856 -2.176,-7.384 -5.624,-9.114 z M 423.98,331.363 260.577,249.323 c -2.88,-1.446 -6.274,-1.446 -9.153,0 L 88.022,331.363 V 69.334998 l 167.978,-84.338 167.98,84.338 z"
id="path113-6-6"
style="fill:#dd2919;fill-opacity:1;stroke:none;stroke-opacity:1" />
</g>
</g>
</g>
</g>
</g>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:29.836px;line-height:1.25;font-family:sans-serif;fill:#dd2919;fill-opacity:1;stroke:none;stroke-width:0.14918"
x="742.81421"
y="166.67886"
id="text577-37-9"
transform="scale(0.97660313,1.0239574)"><tspan
x="742.81421"
y="166.67886"
style="font-size:29.836px;text-align:center;text-anchor:middle;fill:#dd2919;fill-opacity:1;stroke-width:0.14918"
id="tspan1902-7">CLI</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,194 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="682.9917mm"
height="130.5909mm"
viewBox="0 0 682.9917 130.59089"
version="1.1"
id="svg187">
<defs
id="defs181" />
<metadata
id="metadata184">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(285.88901,-112.35141)">
<g
id="g117"
transform="matrix(0,0.26458333,-0.42977593,0,378.89058,94.459492)"
style="fill:#91c23d;fill-opacity:1">
<g
id="g115"
style="fill:#91c23d;fill-opacity:1">
<g
id="g419"
style="fill:#91c23d;fill-opacity:1">
<g
id="g450"
style="fill:#91c23d;fill-opacity:1">
<g
id="g453"
style="fill:#91c23d;fill-opacity:1">
<path
d="m 438.755,53.927998 -178.179,-89.458 c -2.88,-1.446 -6.274,-1.446 -9.153,0 l -178.177,89.458 c -3.447,1.731 -5.623,5.259 -5.623,9.115 V 347.895 c 0,3.538 1.833,6.823 4.845,8.681 3.01,1.858 6.769,2.022 9.931,0.434 L 256,269.849 429.603,357.011 c 1.443,0.724 3.011,1.084 4.575,1.084 1.862,0 3.72,-0.509 5.356,-1.519 3.012,-1.858 4.845,-5.142 4.845,-8.681 V 63.041998 c -0.001,-3.856 -2.176,-7.384 -5.624,-9.114 z M 423.98,331.363 260.577,249.323 c -2.88,-1.446 -6.274,-1.446 -9.153,0 L 88.022,331.363 V 69.334998 l 167.978,-84.338 167.98,84.338 z"
id="path113"
style="fill:#91c23d;fill-opacity:1" />
</g>
</g>
</g>
</g>
</g>
<g
id="g117-2"
transform="matrix(0,0.26458333,-0.42977593,0,208.59758,94.459492)"
style="fill:#1d7ec0;fill-opacity:1">
<g
id="g115-2"
style="fill:#1d7ec0;fill-opacity:1">
<g
id="g419-5"
style="fill:#1d7ec0;fill-opacity:1">
<g
id="g450-8"
style="fill:#1d7ec0;fill-opacity:1">
<g
id="g453-4"
style="fill:#1d7ec0;fill-opacity:1">
<path
d="m 438.755,53.927998 -178.179,-89.458 c -2.88,-1.446 -6.274,-1.446 -9.153,0 l -178.177,89.458 c -3.447,1.731 -5.623,5.259 -5.623,9.115 V 347.895 c 0,3.538 1.833,6.823 4.845,8.681 3.01,1.858 6.769,2.022 9.931,0.434 L 256,269.849 429.603,357.011 c 1.443,0.724 3.011,1.084 4.575,1.084 1.862,0 3.72,-0.509 5.356,-1.519 3.012,-1.858 4.845,-5.142 4.845,-8.681 V 63.041998 c -0.001,-3.856 -2.176,-7.384 -5.624,-9.114 z M 423.98,331.363 260.577,249.323 c -2.88,-1.446 -6.274,-1.446 -9.153,0 L 88.022,331.363 V 69.334998 l 167.978,-84.338 167.98,84.338 z"
id="path113-3"
style="fill:#1d7ec0;fill-opacity:1" />
</g>
</g>
</g>
</g>
</g>
<g
id="g117-2-2"
transform="matrix(0,0.26458333,-0.42977593,0,38.304581,94.459492)"
style="fill:#57cbab;fill-opacity:1">
<g
id="g115-2-0"
style="fill:#57cbab;fill-opacity:1">
<g
id="g419-5-8"
style="fill:#57cbab;fill-opacity:1">
<g
id="g450-8-9"
style="fill:#57cbab;fill-opacity:1">
<g
id="g453-4-1"
style="fill:#57cbab;fill-opacity:1">
<path
d="m 438.755,53.927998 -178.179,-89.458 c -2.88,-1.446 -6.274,-1.446 -9.153,0 l -178.177,89.458 c -3.447,1.731 -5.623,5.259 -5.623,9.115 V 347.895 c 0,3.538 1.833,6.823 4.845,8.681 3.01,1.858 6.769,2.022 9.931,0.434 L 256,269.849 429.603,357.011 c 1.443,0.724 3.011,1.084 4.575,1.084 1.862,0 3.72,-0.509 5.356,-1.519 3.012,-1.858 4.845,-5.142 4.845,-8.681 V 63.041998 c -0.001,-3.856 -2.176,-7.384 -5.624,-9.114 z M 423.98,331.363 260.577,249.323 c -2.88,-1.446 -6.274,-1.446 -9.153,0 L 88.022,331.363 V 69.334998 l 167.978,-84.338 167.98,84.338 z"
id="path113-3-3"
style="fill:#57cbab;fill-opacity:1" />
</g>
</g>
</g>
</g>
</g>
<g
id="g117-2-1"
transform="matrix(0,0.26458333,-0.42977593,0,-131.9884,94.459492)"
style="fill:#58687a;fill-opacity:1">
<g
id="g115-2-1"
style="fill:#58687a;fill-opacity:1">
<g
id="g419-5-3"
style="fill:#58687a;fill-opacity:1">
<g
id="g450-8-8"
style="fill:#58687a;fill-opacity:1">
<g
id="g453-4-3"
style="fill:#58687a;fill-opacity:1">
<path
d="m 438.755,53.927998 -178.179,-89.458 c -2.88,-1.446 -6.274,-1.446 -9.153,0 l -178.177,89.458 c -3.447,1.731 -5.623,5.259 -5.623,9.115 V 347.895 c 0,3.538 1.833,6.823 4.845,8.681 3.01,1.858 6.769,2.022 9.931,0.434 L 256,269.849 429.603,357.011 c 1.443,0.724 3.011,1.084 4.575,1.084 1.862,0 3.72,-0.509 5.356,-1.519 3.012,-1.858 4.845,-5.142 4.845,-8.681 V 63.041998 c -0.001,-3.856 -2.176,-7.384 -5.624,-9.114 z M 423.98,331.363 260.577,249.323 c -2.88,-1.446 -6.274,-1.446 -9.153,0 L 88.022,331.363 V 69.334998 l 167.978,-84.338 167.98,84.338 z"
id="path113-3-2"
style="fill:#58687a;fill-opacity:1" />
</g>
</g>
</g>
</g>
</g>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:52.9167px;line-height:1.25;font-family:sans-serif;fill:#91c23d;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="278.7619"
y="181.48132"
id="text577"><tspan
id="tspan575"
x="278.7619"
y="181.48132"
style="font-size:52.9167px;fill:#91c23d;fill-opacity:1;stroke-width:0.264583">API</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:52.9167px;line-height:1.25;font-family:sans-serif;fill:#1d7ec0;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="108.60566"
y="181.45549"
id="text577-3"><tspan
id="tspan575-4"
x="108.60566"
y="181.45549"
style="font-size:52.9167px;fill:#1d7ec0;fill-opacity:1;stroke-width:0.264583">CLI</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:49.0875px;line-height:1.25;font-family:sans-serif;fill:#57cbab;fill-opacity:1;stroke:none;stroke-width:0.245437"
x="-75.535545"
y="168.34894"
id="text577-3-4"
transform="scale(0.92763785,1.0780069)"><tspan
id="tspan575-4-8"
x="-75.535545"
y="168.34894"
style="font-size:49.0875px;fill:#57cbab;fill-opacity:1;stroke-width:0.245437">ENV</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:52.9167px;line-height:1.25;font-family:sans-serif;fill:#58687a;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-232.18469"
y="181.45549"
id="text577-3-0"><tspan
id="tspan575-4-6"
x="-232.18469"
y="181.45549"
style="font-size:52.9167px;fill:#58687a;fill-opacity:1;stroke-width:0.264583">RC</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-286.52753"
y="241.33215"
id="text1502"><tspan
id="tspan1500"
x="-286.52753"
y="241.33215"
style="stroke-width:0.264583"><tspan
style="font-size:21.1667px"
id="tspan1644">lowest</tspan></tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:21.1667px;line-height:1.25;font-family:sans-serif;fill:#323232;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="319.11252"
y="238.53947"
id="text1502-8"><tspan
id="tspan1500-0"
x="319.11252"
y="238.53947"
style="font-size:21.1667px;fill:#323232;fill-opacity:1;stroke-width:0.264583">highest</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -0,0 +1,129 @@
.. _configuration:
Configuration
=============
Overview
--------
While ``mamba`` currently relies on ``conda`` configuration, ``libmamba`` and downstream projects such as ``micromamba`` or ``rhumba``
rely on a pure C++ implementation.
.. note::
For ``mamba`` configuration, please refer to `conda documentation <https://conda.io/projects/conda/en/latest/user-guide/configuration/index.html>`_
The configuration is parsed/read from multiple sources types:
- **rc file**: a file using `YAML` syntax
- **environment variable**: a key/value pair set prior to mamba execution
- **CLI**: a parsed argument/option from a CLI interface
- **API**: a value set programmatically by a program relying on mamba
The precedence order between those sources is:
.. image:: config_srcs.svg
:width: 600
:align: center
.. note::
`rc` file stands historically for `run commands` which could also translate to `runtime configuration`.
It's a convenient way to persist configuration on the filesystem and use it as default.
.. _precedence-resolution:
Precedence resolution
---------------------
Depending on its type, the resolution of a configuration value between multiple sources is:
- scalar (boolean, string): value from highest precedence source
- sequence (list): appended from highest precedence source to lowest
Example:
Running ``micromamba install xtensor -c my-channel`` with 3 sources of configuration:
- ``channels`` and ``always_yes`` set from rc file located at `~/.mambarc`
- ``channels`` set from CLI using `-c` option
- ``always_yes`` set from environment variable using `MAMBA_ALWAYS_YES` env var
.. code::
$ cat ~/.mambarc
channels:
- conda-forge
always_yes: false
.. code::
$ echo $MAMBA_ALWAYS_YES
true
The resulting configuration written using `YAML` syntax is:
.. code::
channels:
- my-channel # 'CLI'
- conda-forge # '~/.mambarc'
always_yes: true # 'MAMBA_ALWAYS_YES' > '~/.mambarc'
Multiple rc files
-----------------
A user may have multiple rc files located at different places on his machine.
It's a convenient way for configuration to apply in given scopes:
- system wide: all users
- root prefix: all environments sharing the same root prefix
- current user
- target prefix: a specific target prefix | environment
- a single use
Alternatively, ones could also pass one or more rc files to use from the CLI. Other sources are then ignored.
RC files have their own precedence order and use the same resolution process as other configuration sources:
.. image:: config_rc_srcs.svg
:width: 800
:align: center
.. code::
// on_unix
{
"/etc/conda/.condarc",
"/etc/conda/condarc",
"/etc/conda/condarc.d/",
"/etc/conda/.mambarc",
"/var/lib/conda/.condarc",
"/var/lib/conda/condarc",
"/var/lib/conda/condarc.d/",
"/var/lib/conda/.mambarc"
}
// on_win
{
"C:\\ProgramData\\conda\\.condarc",
"C:\\ProgramData\\conda\\condarc",
"C:\\ProgramData\\conda\\condarc.d",
"C:\\ProgramData\\conda\\.mambarc"
}
{ root_prefix }/.condarc
{ root_prefix }/condarc
{ root_prefix }/condarc.d
{ root_prefix }/.mambarc
~/.conda/.condarc
~/.conda/condarc
~/.conda/condarc.d
~/.condarc
~/.mambarc
{ target_prefix }/.condarc
{ target_prefix }/condarc
{ target_prefix }/condarc.d
{ target_prefix }/.mambarc
$CONDARC,
$MAMBARC;

View File

@ -0,0 +1,105 @@
.. _mamba:
Mamba
-----
``mamba`` is a CLI tool to manage ``conda`` s environments.
If you already know ``conda``, great, you already know ``mamba``!
If you're new to this world, don't panic you will find everything you need in this documentation. We recommend to get familiar with :ref:`concepts<concepts>` first.
Quickstart
==========
The ``mamba create`` command creates a new environment.
You can create an environment with the name ``nameofmyenv`` by calling:
.. code::
mamba create -n nameofmyenv <list of packages>
After this process has finished, you can _activate_ the virtual environment by calling ``conda activate <nameofmyenv>``.
For example, to install JupyterLab from the ``conda-forge`` channel and then run it, you could use the following commands:
.. code::
mamba create -n myjlabenv jupyterlab -c conda-forge
conda activate myjlabenv # activate our environment
jupyter lab # this will start up jupyter lab and open a browser
Once an environment is activated, ``mamba install`` can be used to install further packages into the environment.
.. code::
conda activate myjlabenv
mamba install bqplot # now you can use bqplot in myjlabenv
``mamba`` vs ``conda`` CLIs
===========================
| ``mamba`` is a drop-in replacement and uses the same commands and configuration options as ``conda``.
| You can swap almost all commands between ``conda`` & ``mamba``:
.. code::
mamba install ...
mamba create -n ... -c ... ...
mamba list
.. warning::
The only difference is that you should still use ``conda`` for :ref:`activation<activation>` and :ref:`deactivation<deactivation>`.
Repoquery
=========
``mamba`` comes with features on top of stock ``conda``.
To efficiently query repositories and query package dependencies you can use ``mamba repoquery``.
Here are some examples:
.. code::
# will show you all available xtensor packages.
$ mamba repoquery search xtensor
# you can also specify more constraints on this search query
$ mamba repoquery search "xtensor>=0.18"
# will show you a tree view of the dependencies of xtensor.
$ mamba repoquery depends xtensor
.. code::
$ mamba repoquery depends xtensor
xtensor == 0.21.5
├─ libgcc-ng [>=7.3.0]
│ ├─ _libgcc_mutex [0.1 conda_forge]
│ └─ _openmp_mutex [>=4.5]
│ ├─ _libgcc_mutex already visited
│ └─ libgomp [>=7.3.0]
│ └─ _libgcc_mutex already visited
├─ libstdcxx-ng [>=7.3.0]
└─ xtl [>=0.6.9,<0.7]
├─ libgcc-ng already visited
└─ libstdcxx-ng already visited
And you can ask for the inverse, which packages depend on some other package (e.g. ``ipython``) using ``whoneeds``.
.. code::
$ mamba repoquery whoneeds ipython
Name Version Build Channel
──────────────────────────────────────────────────
ipykernel 5.2.1 py37h43977f1_0 installed
ipywidgets 7.5.1 py_0 installed
jupyter_console 6.1.0 py_1 installed
With the ``-t,--tree`` flag, you can get the same information in a tree.

View File

@ -0,0 +1,195 @@
.. _micromamba:
==========
Micromamba
==========
``micromamba`` is a small, pure-C++ executable with enough functionalities to *bootstrap* fully functional conda-environments.
Still at early stage, it's main usage is in continous integration pipelines: since it's a single executable, it reduces dramatically bandwidth usage and provide *fast* operations.
Quickstarts
===========
| ``micromamba`` supports a subset of all ``mamba`` or ``conda`` commands and implements a command line interface from scratch.
| You can see all implemented commands with ``micromamba --help``:
.. code::
$ micromamba --help
Subcommands:
activate Activate a conda / micromamba environment
deactivate Deactivate a conda / micromamba environment
shell Generate shell init scripts
create Create new environment
install Install packages in active environment
update Update packages in active environment
remove Remove packages from active environment
list List packages in active environment
config Configuration of micromamba
info Information about micromamba
clean Clean package cache
constructor Commands to support using micromamba in constructor
env List environments
To activate an environment just call ``micromamba activate /path/to/env`` or, when it's a named environment in your :ref:`root prefix<root-prefix>`, then you can also use ``micromamba activate myenv``.
``micromamba`` expects to find the *root prefix* set by ``$MAMBA_ROOT_PREFIX`` environment variable. You can also provide it using CLI option ``-r,--root-prefix``.
| Named environments then live in ``$MAMBA_ROOT_PREFIX/envs/``.
For more details, please read about :ref:`configuration<configuration>`.
After :ref:`activation<activation>`, you can run ``install`` to add new packages to the environment.
.. code::
$ micromamba install xtensor -c conda-forge
Using ``create``, you can also create environments:
.. code::
$ micromamba create -n xtensor_env xtensor xsimd -c conda-forge
__
__ ______ ___ ____ _____ ___ / /_ ____ _
/ / / / __ `__ \/ __ `/ __ `__ \/ __ \/ __ `/
/ /_/ / / / / / / /_/ / / / / / / /_/ / /_/ /
/ .___/_/ /_/ /_/\__,_/_/ /_/ /_/_.___/\__,_/
/_/
conda-forge/noarch [====================] (00m:01s) Done
conda-forge/linux-64 [====================] (00m:04s) Done
Transaction
Prefix: /home/wolfv/miniconda3/envs/xtensor_env
Updating specs:
- xtensor
- xsimd
Package Version Build Channel Size
────────────────────────────────────────────────────────────────────────
Install:
────────────────────────────────────────────────────────────────────────
_libgcc_mutex 0.1 conda_forge conda-forge/linux-64 Cached
_openmp_mutex 4.5 1_gnu conda-forge/linux-64 Cached
libgcc-ng 9.3.0 h5dbcf3e_17 conda-forge/linux-64 Cached
libgomp 9.3.0 h5dbcf3e_17 conda-forge/linux-64 Cached
libstdcxx-ng 9.3.0 h2ae2ef3_17 conda-forge/linux-64 Cached
xsimd 7.4.9 hc9558a2_0 conda-forge/linux-64 102 KB
xtensor 0.21.9 h0efe328_0 conda-forge/linux-64 183 KB
xtl 0.6.21 h0efe328_0 conda-forge/linux-64 Cached
Summary:
Install: 8 packages
Total download: 285 KB
────────────────────────────────────────────────────────────────────────
Confirm changes: [Y/n] ...
After the installation is finished, the environment can be :ref:`activated<activation>` with:
.. code::
$ micromamba activate xtensor_env
Specification files
===================
The ``create`` syntax also allows you to use specification or environment files (also called *spec files*) to easily re-create environments.
The three supported syntaxes are: yaml, txt and explicit spec files.
Simple text spec files
**********************
The ``txt`` file contains *one spec per line*. For example, this could look like:
.. code::
xtensor
numpy 1.19
xsimd >=7.4
To use this file, pass:
.. code::
$ micromamba create -n from_file -f spec_file.txt -c conda-forge
.. note::
You can pass multiple text spec files by repeating the ``-f,--file`` argument.
YAML spec files
***************
More powerful are ``YAML`` files like the following, because they already contain a desired environment name and the channels to use:
.. code::
name: testenv
channels:
- conda-forge
dependencies:
- python >=3.6,<3.7
- ipykernel >=5.1
- ipywidgets
They are used the same way as text files:
.. code::
$ micromamba create -f env.yml
.. note::
CLI options will keep :ref:`precedence<precedence-resolution>` over *target prefix* or *channels* specified in spec files.
.. warning::
``YAML`` spec files do not allow multiple files.
Explicit spec files
*******************
Using ``conda`` you can generate *explicit* environment lock files. For this, create an environment and execute:
.. code::
$ conda list --explicit --md5
These environment files look like the following and precisely "pin" the desired package + version + build string:
.. code::
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: linux-64
@EXPLICIT
https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81
https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-ng-9.3.0-h2ae2ef3_17.tar.bz2#342f3c931d0a3a209ab09a522469d20c
https://conda.anaconda.org/conda-forge/linux-64/libgomp-9.3.0-h5dbcf3e_17.tar.bz2#8fd587013b9da8b52050268d50c12305
https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-1_gnu.tar.bz2#561e277319a41d4f24f5c05a9ef63c04
https://conda.anaconda.org/conda-forge/linux-64/libgcc-ng-9.3.0-h5dbcf3e_17.tar.bz2#fc9f5adabc4d55cd4b491332adc413e0
https://conda.anaconda.org/conda-forge/linux-64/xtl-0.6.21-h0efe328_0.tar.bz2#9eee90b98fd394db7a049792e67e1659
https://conda.anaconda.org/conda-forge/linux-64/xtensor-0.21.8-hc9558a2_0.tar.bz2#1030174db5c183f3afb4181a0a02873d
To install such a file with ``micromamba``, just pass the ``-f`` flag again:
.. code::
$ micromamba create -n xtensor -c conda-forge -f explicit_env.txt

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,18 @@
name: mamba-dev
channels:
- conda-forge
dependencies:
- yaml-cpp-static
- libcurl=7.76.1=*_0
- libcurl-static=7.76.1 *_0
- xz-static
- libssh2-static
- libarchive=3.3
- krb5-static
- libsolv-static
- libopenssl-static
- zstd-static
- libnghttp2-static
- lz4-c-static
- reproc-static
- reproc-cpp-static