Skip to content

Commit

Permalink
Switch from mamba-forge to micromamba
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Apr 29, 2023
1 parent 18303e5 commit a8787da
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 36 deletions.
21 changes: 12 additions & 9 deletions build/bin/sage-print-system-package-command
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ do
--quiet)
QUIET=yes
;;
--isolated)
ISOLATED=yes
;;
-*)
echo >&2 "$0: unknown option $1"
exit 1
Expand All @@ -67,12 +70,7 @@ if [ "$system" = auto ]; then
fi
fi
if [ "$SPKG" = "yes" ]; then
case $system in
mamba)
base_system=conda;;
*)
base_system=$system;;
esac
base_system=${system%%-*}
system_packages=$(echo $(sage-get-system-packages $base_system $*))
else
system_packages="$*"
Expand Down Expand Up @@ -149,15 +147,20 @@ case $system:$command in
opensuse*:install)
[ -n "$system_packages" ] && print_shell_command "${SUDO}zypper install $system_packages"
;;
*conda*:install)
conda-micromamba*:install)
[ "$YES" = yes ] && options="$options --yes"
[ -n "$system_packages" ] && print_shell_command "conda install $options $system_packages"
[ "$ISOLATED" = yes ] && options="$options --no-rc"
[ -n "$system_packages" ] && print_shell_command "micromamba install $options $system_packages"
;;
mamba*:install)
conda-mamba*:install)
[ "$YES" = yes ] && options="$options --yes"
[ "$QUIET" = yes ] && options="$options --no-banner"
[ -n "$system_packages" ] && print_shell_command "mamba install $options $system_packages"
;;
*conda*:install)
[ "$YES" = yes ] && options="$options --yes"
[ -n "$system_packages" ] && print_shell_command "conda install $options $system_packages"
;;
homebrew*:install)
[ -n "$system_packages" ] && print_shell_command "brew install $system_packages"
;;
Expand Down
3 changes: 2 additions & 1 deletion build/make/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,9 @@ $(1)-$(4)-no-deps:
rm -f "$$($(4))/$(SPKG_INST_RELDIR)/$(1)"-* && \
touch "$$($(4))/$(SPKG_INST_RELDIR)/$(1)-$(2)"; \
else \
INSTALL_COMMAND=$$$$(sage-print-system-package-command mamba --yes --quiet --spkg install $(1)); \
INSTALL_COMMAND=$$$$(sage-print-system-package-command conda-micromamba --yes --quiet --spkg install $(1)); \
if [ -n "$$$$INSTALL_COMMAND" ]; then \
export CONDARC="$(SAGE_ROOT)/condarc.yml"; \
echo "$$$$INSTALL_COMMAND" && \
. '$$(SAGE_ROOT)/src/bin/sage-src-env-config' && \
. '$$(SAGE_ROOT)/src/bin/sage-env-config' && \
Expand Down
12 changes: 9 additions & 3 deletions build/pkgs/mamba_forge/SPKG.rst → build/pkgs/conda/SPKG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mamba_forge: Installs conda-forge packages with the fast package manager mamba
==============================================================================
conda: Installs conda-forge packages in an isolated environment
===============================================================

Description
-----------
Expand All @@ -10,6 +10,10 @@ and distributions for the conda package manager.
mamba is a fast cross-platform package manager, a compatible
reimplementation of the conda package manager in C++.

micromamba is a tiny version of the mamba package manager. It is a statically linked
C++ executable with a separate command line interface. It does not need a base
environment and does not come with a default version of Python.

Installing this script package creates an isolated installation of mamba-forge
in ``$SAGE_LOCAL/var/lib/sage/conda``.

Expand All @@ -23,6 +27,8 @@ BSD-3-Clause
Upstream Contact
----------------

https://conda-forge.org/

https://github.com/mamba-org/mamba

https://conda-forge.org/
https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html
32 changes: 32 additions & 0 deletions build/pkgs/conda/spkg-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#! /bin/sh
set -e

ARCH=$(uname -m)
OS=$(uname)

# Adapted from micro.mamba.pm/install.sh, removed bashisms
if [ "$OS" = "Linux" ]; then
PLATFORM="linux"
if [ "$ARCH" = "aarch64" ]; then
ARCH="aarch64";
elif [ $ARCH == "ppc64le" ]; then
ARCH="ppc64le";
else
ARCH="64";
fi
fi

if [ "$OS" = "Darwin" ]; then
PLATFORM="osx";
if [ "$ARCH" = "arm64" ]; then
ARCH="arm64";
else
ARCH="64"
fi
fi

set -x
sage-download-file "https://micro.mamba.pm/api/micromamba/$PLATFORM-$ARCH/latest" | tar -xvj -C "$SAGE_LOCAL" bin/micromamba
export MAMBA_ROOT_PREFIX="$SAGE_LOCAL/var/lib/sage/conda"
export CONDARC="$SAGE_ROOT/condarc.yml"
micromamba create --yes -n sage -c conda-forge
File renamed without changes.
2 changes: 1 addition & 1 deletion build/pkgs/ffmpeg/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mamba_forge
conda
2 changes: 1 addition & 1 deletion build/pkgs/git/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mamba_forge
conda
2 changes: 1 addition & 1 deletion build/pkgs/github_cli/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mamba_forge
conda
2 changes: 1 addition & 1 deletion build/pkgs/imagemagick/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mamba_forge
conda
2 changes: 1 addition & 1 deletion build/pkgs/info/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mamba_forge
conda
4 changes: 0 additions & 4 deletions build/pkgs/latte_int/dependencies

This file was deleted.

6 changes: 0 additions & 6 deletions build/pkgs/mamba_forge/spkg-install

This file was deleted.

2 changes: 1 addition & 1 deletion build/pkgs/pandoc/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mamba_forge
conda
2 changes: 1 addition & 1 deletion build/pkgs/pdf2svg/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mamba_forge
conda
2 changes: 1 addition & 1 deletion build/pkgs/rubiks/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mamba_forge
conda
2 changes: 1 addition & 1 deletion build/pkgs/texlive/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mamba_forge
conda
2 changes: 1 addition & 1 deletion build/pkgs/valgrind/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mamba_forge
conda
14 changes: 11 additions & 3 deletions src/bin/sage-env
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,17 @@ if [ -z "${SAGE_ORIG_PATH_SET}" ]; then
SAGE_ORIG_PATH_SET=True && export SAGE_ORIG_PATH_SET
fi
if [ -n "$SAGE_LOCAL" ]; then
if [ -d "$SAGE_LOCAL/var/lib/sage/conda/bin" ]; then
export CONDA_PREFIX="$SAGE_LOCAL/var/lib/sage/conda"
export PATH="$CONDA_PREFIX/bin:$CONDA_PREFIX/condabin:$PATH"
# https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html
MAMBA_ROOT_PREFIX="$SAGE_LOCAL/var/lib/sage/conda"
CONDA_DEFAULT_ENV=sage
CONDA_PREFIX="$MAMBA_ROOT_PREFIX/envs/$CONDA_DEFAULT_ENV"
if [ -d "$CONDA_PREFIX/conda-meta" ]; then
export MAMBA_ROOT_PREFIX
export CONDA_DEFAULT_ENV
export CONDA_PREFIX
# We do not use the activation script; we only want bin in PATH, nothing else.
export PATH="$CONDA_PREFIX/bin:$PATH"
# Unset environment variables that may have come from outside
unset CONDA_EXE
unset CONDA_PYTHON_EXE
unset CONDA_DEFAULT_ENV
Expand Down

0 comments on commit a8787da

Please sign in to comment.