Skip to content

Commit 8432095

Browse files
author
Release Manager
committed
gh-36911: src/doc/bootstrap: Parallelize generation of SPKG.rst files <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> This makes running `bootstrap` a bit faster. We also improve the RST markup a bit. <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36911 Reported by: Matthias Köppe Reviewer(s): Dima Pasechnik
2 parents d1c22c5 + 84c3e36 commit 8432095

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

build/bin/sage-spkg-info

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,26 @@
55
#
66
# Assumes SAGE_ROOT is set
77
PKG_BASE=$1
8+
if [ -n "$OUTPUT_DIR" ]; then
9+
exec > "$OUTPUT_DIR"/$PKG_BASE.rst
10+
fi
11+
if [ -n "$OUTPUT_RST" ]; then
12+
echo ".. _spkg_$PKG_BASE:"
13+
echo
14+
ref () { echo ":ref:\`$1\`"; }
15+
issue () { echo ":issue:\`$1\`"; }
16+
code () { echo "\`\`$*\`\`"; }
17+
else
18+
ref () { echo "$1"; }
19+
issue () { echo "https://github.com/sagemath/sage/issues/$1"; }
20+
code () { echo "$1"; }
21+
fi
822
PKG_SCRIPTS="$SAGE_ROOT/build/pkgs/$PKG_BASE"
923
for ext in rst txt; do
1024
SPKG_FILE="$PKG_SCRIPTS/SPKG.$ext"
1125
if [ -f "$SPKG_FILE" ]; then
12-
sed "1,3s/^ *Sage: Open Source Mathematics Software:/$PKG_BASE:/" "$SPKG_FILE"
26+
# for sphinx 4.4 we need to replace all direct links by some "extlink" (issue 33272)
27+
sed -e "1,3s/^ *Sage: Open Source Mathematics Software:/$PKG_BASE:/" -e "s|https://github.com/sagemath/sage/issues/\([0-9]*\)|:issue:\`\1\`|g" -e "s|https://arxiv.org/abs/cs/\([0-9]*\)|:arxiv:\`cs/\1\`|g" "$SPKG_FILE"
1328
break
1429
fi
1530
done
@@ -39,9 +54,9 @@ for dep_file in dependencies dependencies_order_only; do
3954
# Dependencies like $(BLAS)
4055
\$\(*) echo "- $dep";;
4156
# Looks like a package
42-
*) if [ -n "$OUTPUT_RST" -a -r "$SAGE_ROOT/build/pkgs/$dep/SPKG.rst" ]; then
57+
*) if [ -r "$SAGE_ROOT/build/pkgs/$dep/SPKG.rst" ]; then
4358
# This RST label is set in src/doc/bootstrap
44-
echo "- :ref:\`spkg_$dep\`"
59+
echo "- $(ref spkg_$dep)"
4560
else
4661
echo "- $dep"
4762
fi;;
@@ -114,15 +129,15 @@ else
114129
if [ -f "${SPKG_CONFIGURE}" ]; then
115130
if grep -q SAGE_PYTHON_PACKAGE_CHECK "${SPKG_CONFIGURE}"; then
116131
echo "If the system package is installed and if the (experimental) option"
117-
echo "--enable-system-site-packages is passed to ./configure, then ./configure"
132+
echo "$(code --enable-system-site-packages) is passed to $(code ./configure), then $(code ./configure)"
118133
echo "will check if the system package can be used."
119134
else
120-
echo "If the system package is installed, ./configure will check if it can be used."
135+
echo "If the system package is installed, $(code ./configure) will check if it can be used."
121136
fi
122137
else
123138
echo "However, these system packages will not be used for building Sage"
124-
echo "because spkg-configure.m4 has not been written for this package;"
125-
echo "see https://github.com/sagemath/sage/issues/27330"
139+
echo "because $(code spkg-configure.m4) has not been written for this package;"
140+
echo "see $(issue 27330)"
126141
fi
127142
fi
128143
echo

src/doc/bootstrap

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ All External Packages
188188
EOF
189189

190190
OUTPUT_INDEX="$OUTPUT_DIR"/index_alph.rst
191-
cat >> "$OUTPUT_INDEX" <<EOF
191+
(cat <<EOF
192192
193193
Details of external packages
194194
============================
@@ -202,16 +202,12 @@ Packages are in alphabetical order.
202202
203203
EOF
204204
for PKG_BASE in $(sage-package list --has-file SPKG.rst); do
205-
PKG_SCRIPTS=build/pkgs/$PKG_BASE
206-
# Instead of just copying, we may want to call
207-
# a version of sage-spkg-info to format extra information.
208-
# for sphinx 4.4 we need to replace all direct links by some "extlink" (issue 33272)
209-
210-
(echo ".. _spkg_$PKG_BASE:" && echo && OUTPUT_RST=1 sage-spkg-info $PKG_BASE) | sed -e "s|https://github.com/sagemath/sage/issues/\([0-9]*\)|:issue:\`\1\`|g" -e "s|https://arxiv.org/abs/cs/\([0-9]*\)|:arxiv:\`cs/\1\`|g" > "$OUTPUT_DIR"/$PKG_BASE.rst
211-
echo >> "$OUTPUT_INDEX" " $PKG_BASE"
205+
echo " $PKG_BASE"
212206
done
213-
cat >> "$OUTPUT_INDEX" <<EOF
207+
cat <<EOF
214208
215209
.. default-role::
216210
217211
EOF
212+
) > "$OUTPUT_INDEX"
213+
sage-package list --has-file SPKG.rst | OUTPUT_DIR=$OUTPUT_DIR OUTPUT_RST=1 xargs -P 0 -n 1 sage-spkg-info

0 commit comments

Comments
 (0)