Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install some dummy and optional packages using conda-forge (micromamba) #35585

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
4 changes: 3 additions & 1 deletion bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ AS_VAR_SET_IF([SAGE_ENABLE_$pkgname], [], [AS_VAR_SET([SAGE_ENABLE_$pkgname], [y
_*) ;;
*) spkg_configures="$spkg_configures
AC_SUBST(SAGE_ENABLE_$pkgname, [if_installed])"
if [ -f build/pkgs/$pkgname/spkg-install -o -f build/pkgs/$pkgname/spkg-install.in ]; then
if [ -f build/pkgs/$pkgname/spkg-install -o -f build/pkgs/$pkgname/spkg-install.in -o -f build/pkgs/$pkgname/distros/conda.txt ]; then
# Issue #31163: Not just an optional dummy package
spkg_configures="$spkg_configures
SAGE_SPKG_ENABLE([$pkgname], [$pkgtype], [$(grep -v ^= build/pkgs/$pkgname/SPKG.rst | head -n1 2>/dev/null || echo $pkgname)])"
Expand Down Expand Up @@ -94,6 +94,8 @@ EOF
elif test ! -f "$DIR/checksums.ini"; then
if test -f "$DIR/spkg-install"; then
SPKG_SOURCE=script
elif test -f "$DIR/distros/conda.txt"; then
SPKG_SOURCE=conda
else
# a dummy package
SPKG_SOURCE=none
Expand Down
19 changes: 18 additions & 1 deletion build/bin/sage-print-system-package-command
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ do
--yes)
YES=yes
;;
--quiet)
QUIET=yes
;;
--isolated)
ISOLATED=yes
;;
-*)
echo >&2 "$0: unknown option $1"
exit 1
Expand All @@ -64,7 +70,8 @@ if [ "$system" = auto ]; then
fi
fi
if [ "$SPKG" = "yes" ]; then
system_packages=$(echo $(sage-get-system-packages $system $*))
base_system=${system%%-*}
system_packages=$(echo $(sage-get-system-packages $base_system $*))
else
system_packages="$*"
fi
Expand Down Expand Up @@ -140,6 +147,16 @@ case $system:$command in
opensuse*:install)
[ -n "$system_packages" ] && print_shell_command "${SUDO}zypper install $system_packages"
;;
conda-micromamba*:install)
[ "$YES" = yes ] && options="$options --yes"
[ "$ISOLATED" = yes ] && options="$options --no-rc"
[ -n "$system_packages" ] && print_shell_command "micromamba install $options $system_packages"
;;
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"
Expand Down
29 changes: 22 additions & 7 deletions build/make/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -725,25 +725,36 @@ $(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 \
rm -rf '$$($(4))/var/lib/sage/scripts/$(1)'; \
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' && \
if [ -x '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install' ]; then \
rm -rf '$$($(4))/var/lib/sage/scripts/$(1)'; \
PKG_BASE="$(1)" \
PKG_VER="$(2)" \
PKG_NAME="$(1)-$(2)" \
SAGE_SPKG_WHEELS=$$($(4))/var/lib/sage/wheels \
SAGE_SPKG_SCRIPTS=$$($(4))/var/lib/sage/scripts \
SAGE_INST_LOCAL=$$($(4)) \
SAGE_CHECK=$$(SAGE_CHECK_$(1)) \
sage-logger -p '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install && if [ $$$$SAGE_CHECK != no -a -x $$(SAGE_ROOT)/build/pkgs/$(1)/spkg-check ]; then $$(SAGE_ROOT)/build/pkgs/$(1)/spkg-check; fi' '$$(SAGE_LOGS)/$(1)-$(2).log' && \
rm -f "$$($(4))/$(SPKG_INST_RELDIR)/$(1)"-* && \
touch "$$($(4))/$(SPKG_INST_RELDIR)/$(1)-$(2)"; \
else ( \
sage-logger -p '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install && if [ $$$$SAGE_CHECK != no -a -x $$(SAGE_ROOT)/build/pkgs/$(1)/spkg-check ]; then $$(SAGE_ROOT)/build/pkgs/$(1)/spkg-check; fi' '$$(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."; \
Expand All @@ -756,6 +767,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
Expand Down
34 changes: 34 additions & 0 deletions build/pkgs/conda/SPKG.rst
Original file line number Diff line number Diff line change
@@ -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
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 --prefix "$MAMBA_ROOT_PREFIX" -c conda-forge
1 change: 1 addition & 0 deletions build/pkgs/conda/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
optional
1 change: 1 addition & 0 deletions build/pkgs/ffmpeg/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conda
1 change: 1 addition & 0 deletions build/pkgs/git/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conda
1 change: 1 addition & 0 deletions build/pkgs/github_cli/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conda
1 change: 1 addition & 0 deletions build/pkgs/imagemagick/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conda
5 changes: 0 additions & 5 deletions build/pkgs/info/checksums.ini

This file was deleted.

10 changes: 1 addition & 9 deletions build/pkgs/info/dependencies
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
ncurses | xz

xz is needed for unpacking the tarball when sage-bootstrap-python is ancient
Both perl and (g)awk are checked by the ./configure script, but perl is part
of the _prereq package, and (g)awk is seemingly assumed throughout the build
system despite not being listed explicitly anywhere.

----------
All lines of this file are ignored except the first.
conda
1 change: 0 additions & 1 deletion build/pkgs/info/package-version.txt

This file was deleted.

12 changes: 0 additions & 12 deletions build/pkgs/info/spkg-build.in

This file was deleted.

2 changes: 0 additions & 2 deletions build/pkgs/info/spkg-install.in

This file was deleted.

4 changes: 0 additions & 4 deletions build/pkgs/latte_int/dependencies

This file was deleted.

1 change: 1 addition & 0 deletions build/pkgs/pandoc/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conda
1 change: 1 addition & 0 deletions build/pkgs/pdf2svg/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conda
5 changes: 0 additions & 5 deletions build/pkgs/rubiks/checksums.ini

This file was deleted.

5 changes: 1 addition & 4 deletions build/pkgs/rubiks/dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
# no dependencies

----------
All lines of this file are ignored except the first.
conda
1 change: 0 additions & 1 deletion build/pkgs/rubiks/package-version.txt

This file was deleted.

18 changes: 0 additions & 18 deletions build/pkgs/rubiks/patches/Makefile.patch

This file was deleted.

46 changes: 0 additions & 46 deletions build/pkgs/rubiks/patches/dietz-cu2-Makefile.patch

This file was deleted.

58 changes: 0 additions & 58 deletions build/pkgs/rubiks/patches/dietz-mcube-Makefile.patch

This file was deleted.

Loading
Loading