Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 119bf47

Browse files
author
Release Manager
committed
Trac #29558: Autogenerated parts of installation guide
- Add a homebrew section, which requires producing good autogenerated homebrew files - Clean up the cygwin autogenerated files URL: https://trac.sagemath.org/29558 Reported by: jhpalmieri Ticket author(s): John Palmieri, Matthias Koeppe Reviewer(s): Matthias Koeppe, John Palmieri
2 parents 5912940 + 8f064f4 commit 119bf47

File tree

5 files changed

+129
-49
lines changed

5 files changed

+129
-49
lines changed
Lines changed: 71 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,85 @@
11
#!/usr/bin/env bash
22
#
33
system=$1
4-
command=$2
5-
if [ -z "$system" -o -z "$command" ]; then
6-
echo >&2 "usage: $0 {debian|arch|conda|...} {install|remove|...} PACKAGES..."
7-
exit 1
8-
fi
9-
shift 2
10-
system_packages="$*"
11-
shopt -s extglob
12-
if [ -n "$system_packages" ]; then
13-
# No command needed to install nothing
14-
case $system:$command in
15-
debian*|ubuntu*)
16-
echo "sudo apt-get $command $system_packages"
17-
;;
18-
@(fedora*|redhat*|centos*):install)
19-
echo "sudo yum install $system_packages"
20-
;;
21-
arch*:install)
22-
echo "sudo pacman -S $system_packages"
4+
shift
5+
IF_VERBOSE=:
6+
SUDO=
7+
PROMPT=
8+
while :
9+
do
10+
case "$1" in
11+
--verbose)
12+
IF_VERBOSE=
2313
;;
24-
*conda*:install)
25-
echo "conda install $system_packages"
14+
--sudo)
15+
# Whether to print sudo for package managers that need sudo for non-root users
16+
SUDO="sudo "
2617
;;
27-
homebrew*:install)
28-
echo "brew install $system_packages"
29-
echo "# Afterwards: "
18+
--prompt)
19+
PROMPT=' $ '
3020
;;
31-
slackware*:install)
32-
echo "sudo slackpkg install $system_packages"
33-
;;
34-
cygwin*:install)
35-
echo "# first install apt-cyg from https://github.com/transcode-open/apt-cyg"
36-
echo "apt-cyg install $system_packages"
21+
-*)
22+
echo >&2 "$0: unknown option $2"
23+
exit 1
3724
;;
3825
*)
39-
echo "# $command the following packages: $system_packages"
40-
;;
26+
break
4127
esac
28+
shift
29+
done
30+
command=$1
31+
shift
32+
if [ -z "$system" -o -z "$command" ]; then
33+
echo >&2 "usage: $0 {debian|arch|conda|...} [--verbose] [--sudo] [--prompt] {update|install|setup-build-env|remove|...} PACKAGES..."
34+
exit 1
4235
fi
43-
# Messages that should go out even if not packages need to be installed
36+
system_packages="$*"
37+
shopt -s extglob
4438
case $system:$command in
45-
homebrew*:install)
46-
echo "# To automatically take care of homebrew messages regarding "
47-
echo "# keg-only packages for the current shell session:"
39+
homebrew*:setup-build-env)
40+
$IF_VERBOSE echo "# To automatically take care of homebrew messages regarding "
41+
$IF_VERBOSE echo "# keg-only packages for the current shell session:"
4842
[ -n "$SAGE_ROOT" ] || SAGE_ROOT=.
49-
echo "# $ source $SAGE_ROOT/.homebrew-build-env"
50-
echo "# Add this to your shell profile if you want it to persist between shell sessions."
43+
echo "${PROMPT}source $SAGE_ROOT/.homebrew-build-env"
44+
$IF_VERBOSE echo "# Add this to your shell profile if you want it to persist between shell sessions."
45+
;;
46+
*:setup-build-env)
47+
# Nothing needed
48+
;;
49+
#
50+
# Verbs handled above are our own inventions. Verbs handled below are apt-get verbs.
51+
#
52+
@(debian*|ubuntu*):update)
53+
echo "${PROMPT}${SUDO}apt-get $command $system_packages"
54+
;;
55+
@(debian*|ubuntu*):*)
56+
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}apt-get $command $system_packages"
57+
;;
58+
@(fedora*|redhat*|centos*):install)
59+
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}yum install $system_packages"
60+
;;
61+
arch*:install)
62+
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}pacman -S $system_packages"
63+
;;
64+
*conda*:install)
65+
[ -n "$system_packages" ] && echo "${PROMPT}conda install $system_packages"
66+
;;
67+
homebrew*:install)
68+
[ -n "$system_packages" ] && echo "${PROMPT}brew install $system_packages"
69+
;;
70+
slackware*:install)
71+
[ -n "$system_packages" ] && echo "${PROMPT}${SUDO}slackpkg install $system_packages"
72+
;;
73+
cygwin*:update)
74+
echo "# first install apt-cyg from https://github.com/transcode-open/apt-cyg"
75+
;;
76+
cygwin*:install)
77+
[ -n "$system_packages" ] && echo "${PROMPT}apt-cyg install $system_packages"
78+
;;
79+
*:update)
80+
# Nothing needed
81+
;;
82+
*)
83+
echo "# $command the following packages: $system_packages"
5184
;;
5285
esac

build/bin/sage-spkg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ if [ $INFO -ne 0 -a "$USE_LOCAL_SCRIPTS" = yes ]; then
390390
;;
391391
esac
392392
echo -n " "
393-
sage-print-system-package-command $system install $system_packages
393+
sage-print-system-package-command $system --prompt --sudo install $system_packages
394394
fi
395395
done
396396
if [ -z "$system" ]; then

m4/sage_spkg_collect.m4

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,10 @@ AC_DEFUN([SAGE_SYSTEM_PACKAGE_NOTICE], [
313313
AS_IF([test $SYSTEM != unknown], [
314314
SYSTEM_PACKAGES=$(build/bin/sage-get-system-packages $SYSTEM $SAGE_NEED_SYSTEM_PACKAGES)
315315
AS_IF([test -n "$SYSTEM_PACKAGES"], [
316-
COMMAND=$(SAGE_ROOT=$SAGE_ROOT build/bin/sage-print-system-package-command $SYSTEM install $SYSTEM_PACKAGES)
316+
PRINT_SYS="build/bin/sage-print-system-package-command $SYSTEM --verbose --prompt --sudo"
317+
COMMAND=$($PRINT_SYS update && $PRINT_SYS install $SYSTEM_PACKAGES && SAGE_ROOT=$SAGE_ROOT $PRINT_SYS setup-build-env )
317318
AC_MSG_NOTICE([hint: installing the following system packages is recommended and may avoid building some of the above SPKGs from source:])
318-
AC_MSG_NOTICE([ \$ $COMMAND])
319+
AC_MSG_NOTICE([$COMMAND])
319320
AC_MSG_NOTICE([After installation, re-run configure using:])
320321
AC_MSG_NOTICE([ \$ ./config.status --recheck && ./config.status])
321322
], [

src/doc/bootstrap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ fi
1616

1717
cd "$SAGE_ROOT"
1818

19-
PROMPT=' $ '
2019
STRIP_COMMENTS="sed s/#.*//;"
2120
OUTPUT_DIR="src/doc/en/installation"
2221
mkdir -p "$OUTPUT_DIR"
2322

2423
shopt -s extglob
2524

26-
for SYSTEM in arch debian fedora cygwin; do
25+
for SYSTEM in arch debian fedora cygwin homebrew; do
2726
SYSTEM_PACKAGES=$(echo $(${STRIP_COMMENTS} build/pkgs/$SYSTEM.txt))
27+
OPTIONAL_SYSTEM_PACKAGES=
2828
for PKG_SCRIPTS in build/pkgs/*; do
2929
if [ -d $PKG_SCRIPTS ]; then
3030
PKG_BASE=$(basename $PKG_SCRIPTS)
@@ -46,6 +46,6 @@ for SYSTEM in arch debian fedora cygwin; do
4646
fi
4747
done
4848
echo >&2 $0:$LINENO: installing "$OUTPUT_DIR"/$SYSTEM.txt and "$OUTPUT_DIR"/$SYSTEM-optional.txt
49-
echo "$PROMPT$(sage-print-system-package-command $SYSTEM install $(echo $(echo $SYSTEM_PACKAGES | xargs -n 1 echo | sort)))" > "$OUTPUT_DIR"/$SYSTEM.txt
50-
echo "$PROMPT$(sage-print-system-package-command $SYSTEM install $(echo $(echo $OPTIONAL_SYSTEM_PACKAGES | xargs -n 1 echo | sort)))" > "$OUTPUT_DIR"/$SYSTEM-optional.txt
49+
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $SYSTEM_PACKAGES | xargs -n 1 echo | sort)))" > "$OUTPUT_DIR"/$SYSTEM.txt
50+
echo "$(sage-print-system-package-command $SYSTEM --prompt --sudo install $(echo $(echo $OPTIONAL_SYSTEM_PACKAGES | xargs -n 1 echo | sort)))" > "$OUTPUT_DIR"/$SYSTEM-optional.txt
5151
done

src/doc/en/installation/source.rst

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ On Debian ("buster" or newer) or Ubuntu ("bionic" or newer):
228228

229229
.. literalinclude:: debian.txt
230230

231+
.. WARNING::
232+
233+
Note: in this documentation, commands like these are
234+
autogenerated. They may as such include duplications. The
235+
duplications are certainly not necessary for the commands to
236+
function properly, but they don't cause any harm, either.
237+
231238
On Fedora / Redhat / CentOS:
232239

233240
.. literalinclude:: fedora.txt
@@ -297,6 +304,43 @@ a registration.
297304
to Command Line Tools.
298305

299306

307+
308+
macOS recommended installation
309+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
310+
311+
Although Sage can in theory build its own version of gfortran, this
312+
can take a while, and the process fails on some recent versions of
313+
OS X. So instead you can install your own copy. One advantage of this
314+
is that you can install it once, and it will get used every time you
315+
build Sage, rather than building gfortran every time.
316+
317+
One way to do that is with the `Homebrew package manager
318+
<https://brew.sh>`_. Install Homebrew as their web page describes, and
319+
then the command ::
320+
321+
$ brew install gcc
322+
323+
will install Homebrew's gcc package, which includes gfortran. Sage
324+
will also use other Homebrew packages, if they are present. You can
325+
install the following:
326+
327+
.. literalinclude:: homebrew.txt
328+
329+
Some Homebrew packages are installed "keg-only," meaning that they are
330+
not available in standard paths. To make them accessible when building
331+
Sage, run ::
332+
333+
$ source SAGE_ROOT/.homebrew-build-env
334+
335+
(replacing ``SAGE_ROOT`` by Sage's home directory). You can add a
336+
command like this to your shell profile if you want the settings to
337+
persist between shell sessions.
338+
339+
Some additional optional packages are taken care of by:
340+
341+
.. literalinclude:: homebrew-optional.txt
342+
343+
300344
.. _section_cygwinprereqs:
301345

302346
Cygwin prerequisite installation
@@ -310,7 +354,7 @@ Although it is possible to install Sage's dependencies using the Cygwin
310354
graphical installer, it is recommended to install the `apt-cyg
311355
<https://github.com/transcode-open/apt-cyg>`_ command-line package
312356
installer, which is used for the remainder of these instructions. To
313-
run `apt-cyg`, you must have already installed (using the graphical
357+
run ``apt-cyg``, you must have already installed (using the graphical
314358
installer) the following packages at a minimum::
315359

316360
bzip2 coreutils gawk gzip tar wget
@@ -575,8 +619,10 @@ Running Sage from a directory with spaces in its name will also fail.
575619
#. Optional: Set various other environment variables that influence the
576620
build process; see :ref:`section_envvar`.
577621

578-
Some environment variables deserve a special mention: `CC`, `CXX` and `FC`;
579-
and on macOS, `OBJC` and `OBJCXX`. Those variables defining your compilers
622+
Some environment variables deserve a special mention: :envvar:`CC`,
623+
:envvar:`CXX` and :envvar:`FC`;
624+
and on macOS, :envvar:`OBJC` and :envvar:`OBJCXX`. Those variables
625+
defining your compilers
580626
can be set at configuration time and their values will be recorded for
581627
further use at runtime. Those initial values are over-ridden if Sage builds
582628
its own compiler or they are set to a different value again before calling
@@ -1445,4 +1491,4 @@ the directory where you want to install Sage.
14451491

14461492

14471493

1448-
**This page was last updated in August 2019 (Sage 9.0).**
1494+
**This page was last updated in April 2020 (Sage 9.1).**

0 commit comments

Comments
 (0)