mirror of https://github.com/mamba-org/mamba.git
add initial docs
This commit is contained in:
parent
d7854f528f
commit
5ac2dfda39
|
@ -0,0 +1,20 @@
|
|||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = source
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@ -0,0 +1,35 @@
|
|||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
|
@ -0,0 +1,59 @@
|
|||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file only contains a selection of the most common options. For a full
|
||||
# list see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
# import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'mamba'
|
||||
copyright = '2020, QuantStack & mamba contributors'
|
||||
author = 'QuantStack & mamba contributors'
|
||||
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '0.5.2'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'myst_parser'
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = []
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'sphinx_book_theme'
|
||||
html_logo = "_static/logo.png"
|
||||
html_title = "documentation"
|
||||
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
|
@ -0,0 +1,43 @@
|
|||
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.
|
||||
|
||||
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
|
||||
|
||||
To get started with `mamba`, it is currently advised to set up `miniconda` first. You find a installer for miniconda here: https://docs.conda.io/en/latest/miniconda.html
|
||||
Once you have miniconda successfully set up, you can use `conda` to install `mamba`. Just type `conda install mamba -n base -c conda-forge` (this will install mamba into your _base_ conda environment -- mamba has to live in the base environment side-by-side with conda).
|
||||
|
||||
### Micromamba
|
||||
|
||||
```{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 succes in CI systems, though, and we encourage this usage.
|
||||
```
|
||||
|
||||
An alternative to miniconda is micromamba. Micromamba is a statically linked, self-contained executable that comes with all the necessary bits and pieces to initialize and activate conda environments.
|
||||
|
||||
|
||||
```{toctree}
|
||||
:maxdepth: 2
|
||||
:caption: "Contents:"
|
||||
|
||||
python_api
|
||||
micromamba
|
||||
|
||||
```
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* {ref}`Index <genindex>`
|
||||
* {ref}`Search <search>`
|
||||
|
||||
<!-- * {ref}`modindex <modindex>` -->
|
|
@ -0,0 +1,2 @@
|
|||
# micromamba
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
# 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.
|
Loading…
Reference in New Issue