diff --git a/build/bin/sage-print-system-package-command b/build/bin/sage-print-system-package-command index e03f275aa40..75f9729fd9f 100755 --- a/build/bin/sage-print-system-package-command +++ b/build/bin/sage-print-system-package-command @@ -44,6 +44,9 @@ do --quiet) QUIET=yes ;; + --isolated) + ISOLATED=yes + ;; -*) echo >&2 "$0: unknown option $1" exit 1 @@ -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="$*" @@ -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" ;; diff --git a/build/make/Makefile.in b/build/make/Makefile.in index 961004731ae..20fab9c61d2 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -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' && \ diff --git a/build/pkgs/mamba_forge/SPKG.rst b/build/pkgs/conda/SPKG.rst similarity index 54% rename from build/pkgs/mamba_forge/SPKG.rst rename to build/pkgs/conda/SPKG.rst index 751981b38c7..9aae81dcbde 100644 --- a/build/pkgs/mamba_forge/SPKG.rst +++ b/build/pkgs/conda/SPKG.rst @@ -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 ----------- @@ -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``. @@ -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 diff --git a/build/pkgs/conda/spkg-install b/build/pkgs/conda/spkg-install new file mode 100755 index 00000000000..a5de8d37d22 --- /dev/null +++ b/build/pkgs/conda/spkg-install @@ -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 diff --git a/build/pkgs/mamba_forge/type b/build/pkgs/conda/type similarity index 100% rename from build/pkgs/mamba_forge/type rename to build/pkgs/conda/type diff --git a/build/pkgs/ffmpeg/dependencies b/build/pkgs/ffmpeg/dependencies index 0fb459e652e..a34a7e56db3 100644 --- a/build/pkgs/ffmpeg/dependencies +++ b/build/pkgs/ffmpeg/dependencies @@ -1 +1 @@ -mamba_forge +conda diff --git a/build/pkgs/git/dependencies b/build/pkgs/git/dependencies index 0fb459e652e..a34a7e56db3 100644 --- a/build/pkgs/git/dependencies +++ b/build/pkgs/git/dependencies @@ -1 +1 @@ -mamba_forge +conda diff --git a/build/pkgs/github_cli/dependencies b/build/pkgs/github_cli/dependencies index 0fb459e652e..a34a7e56db3 100644 --- a/build/pkgs/github_cli/dependencies +++ b/build/pkgs/github_cli/dependencies @@ -1 +1 @@ -mamba_forge +conda diff --git a/build/pkgs/imagemagick/dependencies b/build/pkgs/imagemagick/dependencies index 0fb459e652e..a34a7e56db3 100644 --- a/build/pkgs/imagemagick/dependencies +++ b/build/pkgs/imagemagick/dependencies @@ -1 +1 @@ -mamba_forge +conda diff --git a/build/pkgs/info/dependencies b/build/pkgs/info/dependencies index 0fb459e652e..a34a7e56db3 100644 --- a/build/pkgs/info/dependencies +++ b/build/pkgs/info/dependencies @@ -1 +1 @@ -mamba_forge +conda diff --git a/build/pkgs/latte_int/dependencies b/build/pkgs/latte_int/dependencies deleted file mode 100644 index 412db1855de..00000000000 --- a/build/pkgs/latte_int/dependencies +++ /dev/null @@ -1,4 +0,0 @@ -$(MP_LIBRARY) ntl 4ti2 cddlib lidia - ----------- -All lines of this file are ignored except the first. diff --git a/build/pkgs/mamba_forge/spkg-install b/build/pkgs/mamba_forge/spkg-install deleted file mode 100755 index 42f7effa270..00000000000 --- a/build/pkgs/mamba_forge/spkg-install +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh -set -e -INSTALLER="Mambaforge-$(uname)-$(uname -m).sh" -sage-download-file "https://github.com/conda-forge/miniforge/releases/latest/download/$INSTALLER" > "$SAGE_DISTFILES/$INSTALLER" -export CONDA_PREFIX="$SAGE_LOCAL/var/lib/sage/conda" -bash "$SAGE_DISTFILES/$INSTALLER" -b -f -p "$CONDA_PREFIX" diff --git a/build/pkgs/pandoc/dependencies b/build/pkgs/pandoc/dependencies index 0fb459e652e..a34a7e56db3 100644 --- a/build/pkgs/pandoc/dependencies +++ b/build/pkgs/pandoc/dependencies @@ -1 +1 @@ -mamba_forge +conda diff --git a/build/pkgs/pdf2svg/dependencies b/build/pkgs/pdf2svg/dependencies index 0fb459e652e..a34a7e56db3 100644 --- a/build/pkgs/pdf2svg/dependencies +++ b/build/pkgs/pdf2svg/dependencies @@ -1 +1 @@ -mamba_forge +conda diff --git a/build/pkgs/rubiks/dependencies b/build/pkgs/rubiks/dependencies index 0fb459e652e..a34a7e56db3 100644 --- a/build/pkgs/rubiks/dependencies +++ b/build/pkgs/rubiks/dependencies @@ -1 +1 @@ -mamba_forge +conda diff --git a/build/pkgs/texlive/dependencies b/build/pkgs/texlive/dependencies index 0fb459e652e..a34a7e56db3 100644 --- a/build/pkgs/texlive/dependencies +++ b/build/pkgs/texlive/dependencies @@ -1 +1 @@ -mamba_forge +conda diff --git a/build/pkgs/valgrind/dependencies b/build/pkgs/valgrind/dependencies index 0fb459e652e..a34a7e56db3 100644 --- a/build/pkgs/valgrind/dependencies +++ b/build/pkgs/valgrind/dependencies @@ -1 +1 @@ -mamba_forge +conda diff --git a/src/bin/sage-env b/src/bin/sage-env index 6eda029f1f1..699dc53bba8 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -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