Build locally
Contents
Build locally#
Local development environment#
Clone the repo#
Start by cloning the repo:
git clone https://github.com/mamba-org/mamba.git
Then move to the newly created directory:
cd mamba
Install dev requirements#
mamba
or micromamba
installation:mamba env update --name <env_name> --file ./<project>/environment-dev.yml
micromamba install --name <env_name> --file ./<project>/environment-dev.yml
Pick the correction environment spec file depending on the project you want to build.
If you don’t have an existing env, refer to the installation page.
The different parts of this repository are sub-projects, all relying (totally or partially) on cmake
configuration.
Note
All cmake
commands listed below use bash
multi-line syntax.
On Windows, replace \
trailing character with ^
.
Note
Feel free to use your favorite generator: make
, ninja
, etc.
Build libmamba
#
libmamba
build is enabled using BUILD_LIBMAMBA
cmake
option.
Static library#
BUILD_STATIC
option needs to be activated:
mkdir -p build
cd build
cmake .. \
-DBUILD_LIBMAMBA=ON \
-DBUILD_STATIC=ON
make
Note
libmamba-static
cmake
target represents the static library without any dependency linkage
Fully static library#
BUILD_STATIC_DEPS
option needs to be activated:
mkdir -p build
cd build
cmake .. \
-DBUILD_LIBMAMBA=ON \
-DBUILD_STATIC_DEPS=ON
make
Note
libmamba-full-static
cmake
target represents the static library with static dependencies linkage
Note
The libmamba
static library does not embed the dependencies but the cmake
target will expose those dependencies to any executable linking on it
Note
The fully statically lib still has few symbols required from system shared libraries (glibc
for instance)
Warning
This version of the library has a small difference versus the static and shared ones, on the way the SSL backend of cURL is set See libmamba/src/core/fetch.cpp for more information
Tests#
libmamba
to be built.gtest
-based C++ test suite, run:mkdir -p build
cd build
cmake .. \
-DBUILD_LIBMAMBA=ON \
-DBUILD_SHARED=ON \
-DBUILD_LIBMAMBA_TESTS=ON
make
You should now be able to run:
./libmamba/tests/test_libmamba
Alternatively you can use:
make test
Build libmambapy
#
The Python bindings of libmamba
, libmambapy
can be built by using the BUILD_LIBMAMBAPY
cmake
option.
You can either rely on libmamba
package already installed in your environment and run:
mkdir -p build
cd build
cmake .. \
-DBUILD_LIBMAMBAPY=ON
make
or rebuild libmamba
in the same time:
mkdir -p build
cd build
cmake .. \
-DBUILD_LIBMAMBA=ON \
-DBUILD_SHARED=ON \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DBUILD_LIBMAMBAPY=ON
make
Note
When rebuilding libmamba
, you also need to install the library in a path it will be found.
Use for that the CMAKE_INSTALL_PREFIX
cmake
option to point your current development environment:
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
[unix]-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX\\Library
[win]
You’ll need to install the target to have the bindings Python sub-module correctly located, then you can use pip
to install that Python package:
make install
pip install -e ../libmambapy/ --no-deps
Note
The editable mode -e
provided by pip
allows to use the source directory as the Python package instead of copying sources inside the environment
You can then change the code without having to reinstall the package
Note
The --no-deps
tells pip
to skip the dependencies installation, since they are already installed (libmamba
installed using cmake
)
Note
libmambapy
is dynamically linking against libmamba
(shared) library
Build mamba
#
You need to build and install libmambapy
, which is a dependency of mamba
, then install mamba
:
Note
Other dependencies are already installed from the environment-dev.yml file
Build micromamba
#
Dynamically linked#
To build micromamba
, activate the BUILD_MICROMAMBA
flag in cmake
command:
mkdir -p build
cd build
cmake .. \
-DBUILD_MICROMAMBA=ON \
-DMICROMAMBA_LINKAGE=DYNAMIC
make
or rebuild libmamba
in the same time:
mkdir -p build
cd build
cmake .. \
-DBUILD_LIBMAMBA=ON \
-DBUILD_SHARED=ON \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DBUILD_MICROMAMBA=ON \
-DMICROMAMBA_LINKAGE=DYNAMIC
make
Note
If you need to install, use the CMAKE_INSTALL_PREFIX
cmake
option to point your current development environment:
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
[unix]-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX\\Library
[win]
Note
micromamba
will be dynamically linked against libmamba
and all its dependencies (libsolv
, libarchive
, etc.)
Note
MICROMAMBA_LINKAGE
default value is DYNAMIC
Statically linked#
You can also build micromamba
statically linked against libmamba
:
mkdir -p build
cd build
cmake .. \
-DBUILD_MICROMAMBA=ON \
-DMICROMAMBA_LINKAGE=STATIC
make
or with libmamba
:
mkdir -p build
cd build
cmake .. \
-DBUILD_LIBMAMBA=ON \
-DBUILD_STATIC=ON \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DBUILD_MICROMAMBA=ON \
-DMICROMAMBA_LINKAGE=STATIC
make
Note
MICROMAMBA_LINKAGE
default value is DYNAMIC
Note
micromamba
will be then statically linked against libmamba
but still dynamically linked against all its dependencies (libsolv
, libarchive
, etc.)
Fully statically linked#
micromamba
can be built as a fully statically linked executable. For that, you need to install extra requirements:
micromamba install --name <env_name> --file ./libmamba/environment-static-dev.yml
It will install the development version of dependencies, including static libraries.
Now you can run cmake
with the additional flag MICROMAMBA_STATIC_DEPS
turned on:
mkdir -p build
cd build
cmake .. \
-DBUILD_MICROMAMBA=ON \
-DMICROMAMBA_LINKAGE=FULL_STATIC
make
or with libmamba
:
mkdir -p build
cd build
cmake .. \
-DBUILD_LIBMAMBA=ON \
-DBUILD_STATIC_DEPS=ON \
-DBUILD_MICROMAMBA=ON \
-DMICROMAMBA_LINKAGE=FULL_STATIC
make
Tests#
You should be able to run the Python-based test suite:
pytest ./micromamba/tests/