Skip to content

Commit

Permalink
Trac #30383: Add "configure --disable-notebook"; show descriptions of…
Browse files Browse the repository at this point in the history
… optional packages in "configure --help"

We refactor the code in `sage_spkg_enable.m4` and `sage_spkg_collect.m4`
so that it becomes possible to add `configure --disable-SPKG` options to
disable standard packages. This also simplifies `build/make/Makefile.in`
slightly because it no longer has to make a distinction between standard
and optional packages.

We demonstrate this by adding one such option, `configure --disable-
notebook`, which disables building the Jupyter `notebook` package ...
and all of its exclusive dependencies.  This is useful for people who
want to use the system Jupyter notebook -- the Jupyter kernel is still
built and can be installed there.

The new option appears before the `--enable...` options for optional
packages.

We also make the configure help a bit more informative (by including the
1-line descriptions of the optional packages) and prettier.

{{{
$ ./configure --help
...
Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-
FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
...
  --enable-experimental-packages
                          allow installing experimental packages
(default: no
                          = ask for user confirmation for each package)
  --enable-download-from-upstream-url
                          allow downloading packages from their upstream
URL
                          if they cannot be found on the Sage mirrors
  --disable-notebook      disable build of the Jupyter notebook and
related
                          packages
  --enable-4ti2={no|if_installed (default)|yes}
                          enable build and use of the optional package
4ti2: Algebraic, geometric
                          and combinatorial problems on linear spaces
                          * package info: ./sage -info 4ti2
  --disable-4ti2          disable build and uninstall if previously
installed by Sage in PREFIX;
                          same as --enable-4ti2=no
  --enable-atlas={no|if_installed (default)|yes}
                          enable build and use of the optional package
atlas: Automatically Tuned
                          Linear Algebra Software (BLAS implementation)
                          * package info: ./sage -info atlas
  --disable-atlas         disable build and uninstall if previously
installed by Sage in PREFIX;
                          same as --enable-atlas=no
  --enable-awali={no|if_installed (default)|yes}
                          enable build and use of the experimental
package awali: Computation of/with
                          finite state machines
                          * package info: ./sage -info awali
  --disable-awali         disable build and uninstall if previously
installed by Sage in PREFIX;
                          same as --enable-awali=no
}}}

This is also preparation for #30556 (packages that will not work without
openssl), and for testing modularized installs (#30778, #29864).

URL: https://trac.sagemath.org/30383
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): John Palmieri, Dima Pasechnik
  • Loading branch information
Release Manager committed Mar 18, 2021
2 parents ca83d06 + 4916415 commit 1a15085
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 70 deletions.
10 changes: 9 additions & 1 deletion bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ install_config_rpath() {
bootstrap () {
rm -f m4/sage_spkg_configures.m4
spkg_configures=""

# initialize SAGE_ENABLE... options for standard packages
for pkgname in $(./sage --package list :standard: | sort); do
spkg_configures="$spkg_configures
AS_VAR_SET_IF([SAGE_ENABLE_$pkgname], [], [AS_VAR_SET([SAGE_ENABLE_$pkgname], [yes])])"
done
# --enable-SPKG options
for pkgname in $(./sage --package list :optional: :experimental: | sort); do
# Trac #29629: Temporary solution for Sage 9.1: Do not provide
# --enable-SPKG options for installing pip packages
Expand All @@ -89,7 +96,8 @@ bootstrap () {
case "$pkgname" in
_*) ;;
*) spkg_configures="$spkg_configures
SAGE_SPKG_ENABLE([$pkgname], [$pkgtype])" ;;
AC_SUBST(SAGE_ENABLE_$pkgname, [if_installed])
SAGE_SPKG_ENABLE([$pkgname], [$pkgtype], [$(head -n1 build/pkgs/$pkgname/SPKG.rst 2>/dev/null || echo $pkgname)])" ;;
esac
fi
done
Expand Down
27 changes: 10 additions & 17 deletions build/make/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,16 @@ GCC_DEP = @SAGE_GCC_DEP@

@SAGE_PACKAGE_TREES@

# All standard packages
STANDARD_PACKAGES = @SAGE_STANDARD_PACKAGES@
STANDARD_PACKAGE_INSTS = \
$(foreach pkgname,$(STANDARD_PACKAGES),$(inst_$(pkgname)))

# Optional/experimental packages to be installed
# All standard/optional/experimental installed packages (triggers the auto-update)
OPTIONAL_INSTALLED_PACKAGES = @SAGE_OPTIONAL_INSTALLED_PACKAGES@

# All packages to be installed
INSTALLED_PACKAGES = $(STANDARD_PACKAGES) $(OPTIONAL_INSTALLED_PACKAGES)
INSTALLED_PACKAGES = $(OPTIONAL_INSTALLED_PACKAGES)
INSTALLED_PACKAGE_INSTS = \
$(foreach pkgname,$(INSTALLED_PACKAGES),$(inst_$(pkgname)))

# All previously installed packages that are to be uninstalled
OPTIONAL_CLEANED_PACKAGES = @SAGE_OPTIONAL_CLEANED_PACKAGES@
CLEANED_PACKAGES = $(OPTIONAL_CLEANED_PACKAGES)
CLEANED_PACKAGES_CLEANS = $(CLEANED_PACKAGES:%=%-clean)
# All previously installed standard/optional/experimental packages that are to be uninstalled
OPTIONAL_UNINSTALLED_PACKAGES = @SAGE_OPTIONAL_UNINSTALLED_PACKAGES@
UNINSTALLED_PACKAGES = $(OPTIONAL_UNINSTALLED_PACKAGES)
UNINSTALLED_PACKAGES_CLEANS = $(UNINSTALLED_PACKAGES:%=%-clean)

# All packages which should be downloaded
SDIST_PACKAGES = @SAGE_SDIST_PACKAGES@
Expand Down Expand Up @@ -240,18 +233,18 @@ base-toolchain: _clean-broken-gcc base
all-sage: \
sagelib \
$(INSTALLED_PACKAGE_INSTS) \
$(CLEANED_PACKAGES_CLEANS)
$(UNINSTALLED_PACKAGES_CLEANS)

# Same but filtered by installation trees:
all-build-local: toolchain-deps
+$(MAKE_REC) all-sage-local

all-sage-local: $(SAGE_LOCAL_INSTALLED_PACKAGE_INSTS) $(SAGE_LOCAL_CLEANED_PACKAGES_CLEANS)
all-sage-local: $(SAGE_LOCAL_INSTALLED_PACKAGE_INSTS) $(SAGE_LOCAL_UNINSTALLED_PACKAGES_CLEANS)

all-build-venv: toolchain-deps
+$(MAKE_REC) all-sage-venv

all-sage-venv: $(SAGE_VENV_INSTALLED_PACKAGE_INSTS) $(SAGE_VENV_CLEANED_PACKAGES_CLEANS)
all-sage-venv: $(SAGE_VENV_INSTALLED_PACKAGE_INSTS) $(SAGE_VENV_UNINSTALLED_PACKAGES_CLEANS)

# Download all packages which should be inside an sdist tarball (the -B
# option to make forces all targets to be built unconditionally)
Expand Down Expand Up @@ -306,7 +299,7 @@ build-start: all-build
# We make this depend on all standard packages because running
# sage-starts runs sage-location, which should be run after installing
# any package.
$(STARTED): $(STANDARD_PACKAGE_INSTS)
$(STARTED): $(OPTIONAL_INSTALLED_PACKAGE_INSTS)
$(AM_V_at)"$(SAGE_ROOT)/build/bin/sage-starts"


Expand Down
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,14 @@ AS_IF([test "x$enable_download_from_upstream_url" = "xyes"], [
])
AC_SUBST([SAGE_SPKG_OPTIONS])

AC_ARG_ENABLE([notebook],
AS_HELP_STRING([--disable-notebook],
[disable build of the Jupyter notebook and related packages]), [
for pkg in notebook nbconvert sagenb_export nbformat terminado send2trash prometheus_client mistune pandocfilters bleach defusedxml jsonschema jupyter_jsmol; do
AS_VAR_SET([SAGE_ENABLE_$pkg], [$enableval])
done
])

SAGE_SPKG_COLLECT()

dnl AC_CONFIG_HEADERS([config.h])
Expand Down
58 changes: 35 additions & 23 deletions m4/sage_spkg_collect.m4
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
# platform, or the dependency on them is satisfied by an existing
# system package.
#
# - SAGE_STANDARD_PACKAGES - lists the names of all packages that have
# the "standard" type. All "standard" packages are installed by
# default (if they are listed in SAGE_DUMMY_PACKAGES "installed" in
# this case is a no-op).
# - SAGE_OPTIONAL_INSTALLED_PACKAGES - lists the names of packages with the
# "standard", "optional", or "experimental" type that should be installed.
#
# - SAGE_OPTIONAL_PACKAGES - lists the names of packages with the
# "optional" type that should be installed.
# - SAGE_OPTIONAL_UNINSTALLED_PACKAGES - lists the names of packages with the
# "standard", "optional", or "experimental" type that should be uninstalled.
#
# - SAGE_SDIST_PACKAGES - lists the names of all packages whose sources
# need to be downloaded to be included in the source distribution.
Expand Down Expand Up @@ -107,13 +105,10 @@ SAGE_BUILT_PACKAGES=''
# underlying system.
SAGE_DUMMY_PACKAGES=''
# Standard packages
SAGE_STANDARD_PACKAGES=''
# List of currently installed and to-be-installed optional packages - filled in SAGE_SPKG_ENABLE
#SAGE_OPTIONAL_INSTALLED_PACKAGES
# List of optional packages to be uninstalled - filled in SAGE_SPKG_ENABLE
#SAGE_OPTIONAL_CLEANED_PACKAGES
# List of currently installed and to-be-installed standard/optional/experimental packages
SAGE_OPTIONAL_INSTALLED_PACKAGES=''
# List of optional packages to be uninstalled
SAGE_OPTIONAL_UNINSTALLED_PACKAGES=''
# List of all packages that should be downloaded
SAGE_SDIST_PACKAGES=''
Expand Down Expand Up @@ -170,25 +165,30 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do
message="came preinstalled with the SageMath tarball"
;;
standard)
SAGE_STANDARD_PACKAGES="${SAGE_STANDARD_PACKAGES} \\$(printf '\n ')${SPKG_NAME}"
in_sdist=yes
message="will be installed as an SPKG"
AS_VAR_IF([SAGE_ENABLE_]${SPKG_NAME}, [yes], [
message="$SPKG_TYPE, will be installed as an SPKG"
], [
message="$SPKG_TYPE, but disabled using configure option"
])
;;
optional|experimental)
AS_VAR_IF([SAGE_ENABLE_]${SPKG_NAME}, [yes], [
message="$SPKG_TYPE, will be installed as an SPKG"
], [
message="$SPKG_TYPE, use \"$srcdir/configure --enable-$SPKG_NAME\" to install"
])
uninstall_message=", use \"$srcdir/configure --disable-$SPKG_NAME\" to uninstall"
;;
*)
AC_MSG_ERROR([The content of "$SPKG_TYPE_FILE" must be 'base', 'standard', 'optional', or 'experimental'])
;;
esac
case "$SPKG_TYPE" in
standard)
in_sdist=yes
;;
optional|experimental)
uninstall_message=", use \"$srcdir/configure --disable-$SPKG_NAME\" to uninstall"
stampfile=""
for f in "$SAGE_SPKG_INST/$SPKG_NAME"-*; do
AS_IF([test -r "$f"], [
Expand Down Expand Up @@ -229,7 +229,7 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do
], [ message="not required on your platform; SPKG will not be installed"
])
], [
dnl We won't use the system package.
dnl We will not use the system package.
SAGE_BUILT_PACKAGES="${SAGE_BUILT_PACKAGES} \\$(printf '\n ')${SPKG_NAME}"
AS_VAR_SET_IF([sage_use_system], [
AS_VAR_COPY([reason], [sage_use_system])
Expand All @@ -239,9 +239,6 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do
],
[installed], [ message="already installed as an SPKG$uninstall_message" ],
[ message="$reason; $message" ])
], [
# Package does not use spkg-configure.m4 yet
message="does not support check for system package; $message"
])
])
Expand Down Expand Up @@ -296,6 +293,22 @@ for DIR in $SAGE_ROOT/build/pkgs/*; do
SAGE_SDIST_PACKAGES="${SAGE_SDIST_PACKAGES} \\$(printf '\n ')${SPKG_NAME}"
fi
# Determine whether package is enabled
AS_VAR_SET([is_installed], [no])
for f in "$SAGE_SPKG_INST/${SPKG_NAME}"-*; do
AS_IF([test -r "$f"],
[AS_VAR_SET([is_installed], [yes])])
done
AS_VAR_IF([SAGE_ENABLE_${SPKG_NAME}}], [if_installed],
[AS_VAR_SET([SAGE_ENABLE_${SPKG_NAME}], $is_installed)])
AS_VAR_COPY([want_spkg], [SAGE_ENABLE_${SPKG_NAME}])
spkg_line=" \\$(printf '\n ')$SPKG_NAME"
AS_CASE([$is_installed-$want_spkg],
[*-yes], [AS_VAR_APPEND(SAGE_OPTIONAL_INSTALLED_PACKAGES, "$spkg_line")],
[yes-no], [AS_VAR_APPEND(SAGE_OPTIONAL_UNINSTALLED_PACKAGES, "$spkg_line")])
# Determine package dependencies
#
DEP_FILE="$DIR/dependencies"
Expand Down Expand Up @@ -340,9 +353,8 @@ AC_SUBST([SAGE_PIP_PACKAGES])
AC_SUBST([SAGE_SCRIPT_PACKAGES])
AC_SUBST([SAGE_BUILT_PACKAGES])
AC_SUBST([SAGE_DUMMY_PACKAGES])
AC_SUBST([SAGE_STANDARD_PACKAGES])
AC_SUBST([SAGE_OPTIONAL_INSTALLED_PACKAGES])
AC_SUBST([SAGE_OPTIONAL_CLEANED_PACKAGES])
AC_SUBST([SAGE_OPTIONAL_UNINSTALLED_PACKAGES])
AC_SUBST([SAGE_SDIST_PACKAGES])
])

Expand Down
52 changes: 23 additions & 29 deletions m4/sage_spkg_enable.m4
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
AC_DEFUN([SAGE_SPKG_ENABLE], [
m4_pushdef([SPKG_NAME], [$1])
m4_pushdef([SPKG_TYPE], [$2])
AC_ARG_ENABLE(SPKG_NAME,
AS_HELP_STRING([--enable-]SPKG_NAME={no|if_installed|yes},
[enable build and use of the $2 package ]SPKG_NAME[ (default: "if_installed")])
AS_HELP_STRING([], [package information: ./sage -info ]SPKG_NAME)
AC_DEFUN([SAGE_SPKG_ENABLE], [dnl
m4_pushdef([SPKG_NAME], [$1])dnl
m4_pushdef([SPKG_TYPE], [$2])dnl
m4_if(SPKG_TYPE, [standard], [dnl
dnl standard packages; help message is deliberately very brief,
dnl as this is for advanced users only
AC_ARG_ENABLE(SPKG_NAME,
AS_HELP_STRING([--disable-]SPKG_NAME,
[disable $2 package ]SPKG_NAME),
AS_VAR_SET([SAGE_ENABLE_]SPKG_NAME, [$enableval])
)
], [dnl
dnl optional/experimental packages
AC_ARG_ENABLE(SPKG_NAME,
AS_HELP_STRING([--enable-]SPKG_NAME={no|if_installed (default)|yes},
[enable build and use of the SPKG_TYPE package $3], [26], [100])
AS_HELP_STRING([], [* package info: ./sage -info SPKG_NAME])
AS_HELP_STRING([--disable-]SPKG_NAME,
[disable build and uninstall if previously installed by Sage in PREFIX; same as --enable-]SPKG_NAME[=no]),
AS_VAR_SET(want_spkg, [$enableval]),
AS_VAR_SET(want_spkg, [if_installed])
)
AS_VAR_SET([is_installed], [no])
for f in "$SAGE_SPKG_INST/SPKG_NAME"-*; do
AS_IF([test -r "$f"],
[AS_VAR_SET([is_installed], [yes])])
done
AS_IF([test "$want_spkg" = if_installed],
[AS_VAR_SET([want_spkg], $is_installed)])
spkg_line=" \\$(printf '\n ')SPKG_NAME"
AS_CASE([$is_installed-$want_spkg],
[*-yes], [AS_VAR_APPEND(SAGE_OPTIONAL_INSTALLED_PACKAGES, "$spkg_line")],
[yes-no], [AS_VAR_APPEND(SAGE_OPTIONAL_CLEANED_PACKAGES, "$spkg_line")])
AS_VAR_SET([SAGE_ENABLE_]SPKG_NAME, [$want_spkg])
AC_SUBST([SAGE_ENABLE_]SPKG_NAME)
m4_popdef([SPKG_TYPE])
m4_popdef([SPKG_NAME])
[disable build and uninstall if previously installed by Sage in PREFIX; same as --enable-]SPKG_NAME[=no], [26], [100]),
AS_VAR_SET([SAGE_ENABLE_]SPKG_NAME, [$enableval])
)
])dnl
m4_popdef([SPKG_TYPE])dnl
m4_popdef([SPKG_NAME])dnl
])

0 comments on commit 1a15085

Please sign in to comment.