use mamba for installs once available
MAMBA_EXE is mamba itself, not micromamba
use variable everywhere, so switching fully to micromamba can happen in once place,
assuming they are fully compatible (they _almost_ are, except for `env update` vs `install` in a couple places)
MODIFY
repo2docker/buildpacks/conda/__init__.py
repo2docker/buildpacks/conda/__init__.py
@@ -56,7 +56,9 @@ class CondaBuildPack(BaseImage):
("NPM_CONFIG_GLOBALCONFIG", "${NPM_DIR}/npmrc"),
("NB_ENVIRONMENT_FILE", self._nb_environment_file),
("MAMBA_ROOT_PREFIX", "${CONDA_DIR}"),
- ("MAMBA_EXE", "/usr/local/bin/micromamba"),
+ # this exe should be used for installs after bootstrap with micromamba
+ # switch this to /usr/local/bin/micromamba to use it for all installs
+ ("MAMBA_EXE", "${CONDA_DIR}/bin/mamba"),
]
if self._nb_requirements_file:
env.append(("NB_REQUIREMENTS_FILE", self._nb_requirements_file))
@@ -334,13 +336,15 @@ class CondaBuildPack(BaseImage):
environment_yml = self.binder_path("environment.yml")
env_prefix = "${KERNEL_PYTHON_PREFIX}" if self.py2 else "${NB_PYTHON_PREFIX}"
if os.path.exists(environment_yml):
+ # TODO: when using micromamba, we call $MAMBA_EXE install -p ...
+ # whereas mamba/conda need `env update -p ...` when it's an env.yaml file
scripts.append(
(
"${NB_USER}",
r"""
TIMEFORMAT='time: %3R' \
- bash -c 'time ${{MAMBA_EXE}} install -p {0} -f "{1}" && \
- time ${{MAMBA_EXE}} clean --all -y && \
+ bash -c 'time ${{MAMBA_EXE}} env update -p {0} --file "{1}" && \
+ time ${{MAMBA_EXE}} clean --all -f -y && \
${{MAMBA_EXE}} list -p {0} \
'
""".format(
@@ -359,7 +363,7 @@ class CondaBuildPack(BaseImage):
"${NB_USER}",
r"""
${{MAMBA_EXE}} install -p {0} r-base{1} r-irkernel=1.2 r-devtools -y && \
- ${{MAMBA_EXE}} clean --all -y && \
+ ${{MAMBA_EXE}} clean --all -f -y && \
${{MAMBA_EXE}} list -p {0}
""".format(
env_prefix, r_pin

MODIFY
repo2docker/buildpacks/conda/activate-conda.sh
repo2docker/buildpacks/conda/activate-conda.sh
# enable conda and activate the notebook environment
-micromamba shell init -s bash -p ${CONDA_DIR}
-export MAMBA_ROOT_PREFIX="/srv/conda"
-CONDA_PROFILE="${CONDA_DIR}/etc/profile.d/mamba.sh"
+eval $(micromamba shell hook -s posix -p ${CONDA_DIR})
+for name in conda mamba; do
+ CONDA_PROFILE="${CONDA_DIR}/etc/profile.d/${name}.sh"
test -f $CONDA_PROFILE && . $CONDA_PROFILE
+done
if [[ "${KERNEL_PYTHON_PREFIX}" != "${NB_PYTHON_PREFIX}" ]]; then
# if the kernel is a separate env, stack them
# so both are on PATH, notebook first
- micromamba activate ${KERNEL_PYTHON_PREFIX}
- micromamba activate --stack ${NB_PYTHON_PREFIX}
+ mamba activate ${KERNEL_PYTHON_PREFIX}
+ mamba activate --stack ${NB_PYTHON_PREFIX}
# even though it's second on $PATH
# make sure CONDA_DEFAULT_ENV is the *kernel* env
@@ -16,5 +17,5 @@ if [[ "${KERNEL_PYTHON_PREFIX}" != "${NB_PYTHON_PREFIX}" ]]; then
# which only contains UI when the two are different
export CONDA_DEFAULT_ENV="${KERNEL_PYTHON_PREFIX}"
else
- micromamba activate ${NB_PYTHON_PREFIX}
+ mamba activate ${NB_PYTHON_PREFIX}
fi

MODIFY
repo2docker/buildpacks/conda/install-base-env.bash
repo2docker/buildpacks/conda/install-base-env.bash
@@ -15,14 +15,13 @@ URL="https://anaconda.org/conda-forge/micromamba/${MAMBA_VERSION}/download/linux
unset HOME
mkdir -p ${CONDA_DIR}
-export MAMBA_ROOT_PREFIX=${CONDA_DIR}
-export MAMBA_EXE="/usr/local/bin/micromamba"
+export MICROMAMBA_EXE="/usr/local/bin/micromamba"
time wget -qO- ${URL} | tar -xvj bin/micromamba
-mv bin/micromamba "$MAMBA_EXE"
-chmod 0755 "$MAMBA_EXE"
+mv bin/micromamba "$MICROMAMBA_EXE"
+chmod 0755 "$MICROMAMBA_EXE"
-eval "$(${MAMBA_EXE} shell hook -p ${CONDA_DIR} -s posix)"
+eval "$(${MICROMAMBA_EXE} shell hook -p ${CONDA_DIR} -s posix)"
micromamba activate
@@ -44,7 +43,7 @@ echo "installing notebook env:"
cat "${NB_ENVIRONMENT_FILE}"
-time micromamba create -p ${NB_PYTHON_PREFIX} -f "${NB_ENVIRONMENT_FILE}"
+time ${MAMBA_EXE} create -p ${NB_PYTHON_PREFIX} --file "${NB_ENVIRONMENT_FILE}"
if [[ ! -z "${NB_REQUIREMENTS_FILE:-}" ]]; then
echo "installing pip requirements"
@@ -61,7 +60,7 @@ if [[ ! -z "${KERNEL_ENVIRONMENT_FILE:-}" ]]; then
# install kernel env and register kernelspec
echo "installing kernel env:"
cat "${KERNEL_ENVIRONMENT_FILE}"
- time micromamba create -p ${KERNEL_PYTHON_PREFIX} -f "${KERNEL_ENVIRONMENT_FILE}"
+ time ${MAMBA_EXE} create -p ${KERNEL_PYTHON_PREFIX} --file "${KERNEL_ENVIRONMENT_FILE}"
if [[ ! -z "${KERNEL_REQUIREMENTS_FILE:-}" ]]; then
echo "installing pip requirements for kernel"
@@ -71,18 +70,18 @@ if [[ ! -z "${KERNEL_ENVIRONMENT_FILE:-}" ]]; then
${KERNEL_PYTHON_PREFIX}/bin/ipython kernel install --prefix "${NB_PYTHON_PREFIX}"
echo '' > ${KERNEL_PYTHON_PREFIX}/conda-meta/history
- micromamba list -p ${KERNEL_PYTHON_PREFIX}
+ ${MAMBA_EXE} list -p ${KERNEL_PYTHON_PREFIX}
fi
# Clean things out!
-time micromamba clean --all -y
+time ${MAMBA_EXE} clean --all -f -y
# Remove the pip cache created as part of installing micromamba
rm -rf /root/.cache
chown -R $NB_USER:$NB_USER ${CONDA_DIR}
-micromamba list -p ${NB_PYTHON_PREFIX}
+${MAMBA_EXE} list -p ${NB_PYTHON_PREFIX}
# Set NPM config
${NB_PYTHON_PREFIX}/bin/npm config --global set prefix ${NPM_DIR}

use mamba for installs once available

MAMBA_EXE is mamba itself, not micromamba
use variable everywhere, so switching fully to micromamba can happen in once place,
assuming they are fully compatible (they _almost_ are, except for `env update` vs `install` in a couple places)