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 370d436bb2c..147ac4222b0 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -704,19 +704,30 @@ $(1)-$(4)-no-deps: echo "Error: The installation tree $(4) has been disabled" 2>&1; \ echo "$$($(4)_DISABLED_MESSAGE)" 2>&1; \ exit 1; \ - elif [ -x '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install' ]; then \ - cd '$$(SAGE_ROOT)/build/pkgs/$(1)' && \ + else \ + cd '$$(SAGE_ROOT)/build/pkgs/$(1)' && \ . '$$(SAGE_ROOT)/src/bin/sage-src-env-config' && \ . '$$(SAGE_ROOT)/src/bin/sage-env-config' && \ . '$$(SAGE_ROOT)/src/bin/sage-env' && \ . '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \ . '$$(SAGE_ROOT)/build/bin/sage-build-env' && \ - SAGE_SPKG_WHEELS=$$($(4))/var/lib/sage/wheels \ - SAGE_INST_LOCAL=$$($(4)) \ - sage-logger -p 'SAGE_CHECK=$$(SAGE_CHECK_$(1)) $$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install' '$$(SAGE_LOGS)/$(1)-$(2).log' && \ - rm -f "$$($(4))/$(SPKG_INST_RELDIR)/$(1)"-* && \ - touch "$$($(4))/$(SPKG_INST_RELDIR)/$(1)-$(2)"; \ - else ( \ + if [ -x '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install' ]; then \ + SAGE_SPKG_WHEELS=$$($(4))/var/lib/sage/wheels \ + SAGE_INST_LOCAL=$$($(4)) \ + sage-logger -p 'SAGE_CHECK=$$(SAGE_CHECK_$(1)) $$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install' '$$(SAGE_LOGS)/$(1)-$(2).log' || exit 1; \ + else \ + INSTALL_COMMAND=$$$$(sage-print-system-package-command conda-micromamba --yes --quiet --spkg install $(1)); \ + if [ -n "$$$$INSTALL_COMMAND" ]; then \ + if [ -d "$$$$SAGE_CONDA_PREFIX" ]; then \ + export MAMBA_ROOT_PREFIX="$$$$SAGE_CONDA_PREFIX"; \ + export CONDA_PREFIX="$$$$SAGE_CONDA_PREFIX"; \ + export CONDARC="$(SAGE_ROOT)/condarc.yml"; \ + eval $$$$INSTALL_COMMAND; \ + else ( \ + echo "Error: $(1) is a conda package, but the environment created by SPKG conda is not present" \ + ) | sage-logger -p 'cat; exit 1' '$$(SAGE_LOGS)/$(1)-$(2).log'; \ + fi; \ + else ( \ echo; \ echo "Note: $(1) is a dummy package that the Sage distribution uses"; \ echo "to provide information about equivalent system packages."; \ @@ -729,6 +740,10 @@ $(1)-$(4)-no-deps: echo; \ echo "Error: $(1) is a dummy package and "; \ echo "cannot be installed using the Sage distribution." ) | sage-logger -p 'cat; exit 1' '$$(SAGE_LOGS)/$(1)-$(2).log'; \ + fi; \ + fi; \ + rm -f "$$($(4))/$(SPKG_INST_RELDIR)/$(1)"-* && \ + touch "$$($(4))/$(SPKG_INST_RELDIR)/$(1)-$(2)"; \ fi $(1)-no-deps: $(1)-$(4)-no-deps diff --git a/build/pkgs/conda/SPKG.rst b/build/pkgs/conda/SPKG.rst new file mode 100644 index 00000000000..06b31f26b69 --- /dev/null +++ b/build/pkgs/conda/SPKG.rst @@ -0,0 +1,34 @@ +conda: Installs conda-forge packages in an isolated environment +=============================================================== + +Description +----------- + +conda-forge is a community-led collection of recipes, build infrastructure +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 installs ``micromamba`` in ``$SAGE_LOCAL/bin`` +and creates an isolated conda environment within ``$SAGE_LOCAL/var/lib/sage/conda``. + + +License +------- + +BSD-3-Clause + + +Upstream Contact +---------------- + +https://conda-forge.org/ + +https://github.com/mamba-org/mamba + +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..c182bfd1c48 --- /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 --prefix "$MAMBA_ROOT_PREFIX" -c conda-forge diff --git a/build/pkgs/conda/type b/build/pkgs/conda/type new file mode 100644 index 00000000000..134d9bc32d5 --- /dev/null +++ b/build/pkgs/conda/type @@ -0,0 +1 @@ +optional 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/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 a7da60df28f..aa429c2d806 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -251,6 +251,12 @@ if [ -z "${SAGE_ORIG_PATH_SET}" ]; then SAGE_ORIG_PATH_SET=True && export SAGE_ORIG_PATH_SET fi if [ -n "$SAGE_LOCAL" ]; then + # https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html + SAGE_CONDA_PREFIX="$SAGE_LOCAL/var/lib/sage/conda" + if [ -d "$SAGE_CONDA_PREFIX/conda-meta" ]; then + # We do not use the activation script; we only want bin in PATH, nothing else. + export PATH="$SAGE_CONDA_PREFIX/bin:$PATH" + fi export PATH="$SAGE_LOCAL/bin:$PATH" fi if [ -n "$SAGE_VENV" ]; then