Skip to content

Commit

Permalink
sagemathgh-36911: src/doc/bootstrap: Parallelize generation of SPKG.r…
Browse files Browse the repository at this point in the history
…st 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 sagemath#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 sagemath#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
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36911
Reported by: Matthias Köppe
Reviewer(s): Dima Pasechnik
  • Loading branch information
Release Manager committed Dec 24, 2023
2 parents 86229d4 + 84c3e36 commit 80d1abc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
29 changes: 22 additions & 7 deletions build/bin/sage-spkg-info
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,26 @@
#
# Assumes SAGE_ROOT is set
PKG_BASE=$1
if [ -n "$OUTPUT_DIR" ]; then
exec > "$OUTPUT_DIR"/$PKG_BASE.rst
fi
if [ -n "$OUTPUT_RST" ]; then
echo ".. _spkg_$PKG_BASE:"
echo
ref () { echo ":ref:\`$1\`"; }
issue () { echo ":issue:\`$1\`"; }
code () { echo "\`\`$*\`\`"; }
else
ref () { echo "$1"; }
issue () { echo "https://github.com/sagemath/sage/issues/$1"; }
code () { echo "$1"; }
fi
PKG_SCRIPTS="$SAGE_ROOT/build/pkgs/$PKG_BASE"
for ext in rst txt; do
SPKG_FILE="$PKG_SCRIPTS/SPKG.$ext"
if [ -f "$SPKG_FILE" ]; then
sed "1,3s/^ *Sage: Open Source Mathematics Software:/$PKG_BASE:/" "$SPKG_FILE"
# for sphinx 4.4 we need to replace all direct links by some "extlink" (issue 33272)
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"
break
fi
done
Expand Down Expand Up @@ -39,9 +54,9 @@ for dep_file in dependencies dependencies_order_only; do
# Dependencies like $(BLAS)
\$\(*) echo "- $dep";;
# Looks like a package
*) if [ -n "$OUTPUT_RST" -a -r "$SAGE_ROOT/build/pkgs/$dep/SPKG.rst" ]; then
*) if [ -r "$SAGE_ROOT/build/pkgs/$dep/SPKG.rst" ]; then
# This RST label is set in src/doc/bootstrap
echo "- :ref:\`spkg_$dep\`"
echo "- $(ref spkg_$dep)"
else
echo "- $dep"
fi;;
Expand Down Expand Up @@ -114,15 +129,15 @@ else
if [ -f "${SPKG_CONFIGURE}" ]; then
if grep -q SAGE_PYTHON_PACKAGE_CHECK "${SPKG_CONFIGURE}"; then
echo "If the system package is installed and if the (experimental) option"
echo "--enable-system-site-packages is passed to ./configure, then ./configure"
echo "$(code --enable-system-site-packages) is passed to $(code ./configure), then $(code ./configure)"
echo "will check if the system package can be used."
else
echo "If the system package is installed, ./configure will check if it can be used."
echo "If the system package is installed, $(code ./configure) will check if it can be used."
fi
else
echo "However, these system packages will not be used for building Sage"
echo "because spkg-configure.m4 has not been written for this package;"
echo "see https://github.com/sagemath/sage/issues/27330"
echo "because $(code spkg-configure.m4) has not been written for this package;"
echo "see $(issue 27330)"
fi
fi
echo
14 changes: 5 additions & 9 deletions src/doc/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ All External Packages
EOF

OUTPUT_INDEX="$OUTPUT_DIR"/index_alph.rst
cat >> "$OUTPUT_INDEX" <<EOF
(cat <<EOF
Details of external packages
============================
Expand All @@ -202,16 +202,12 @@ Packages are in alphabetical order.
EOF
for PKG_BASE in $(sage-package list --has-file SPKG.rst); do
PKG_SCRIPTS=build/pkgs/$PKG_BASE
# Instead of just copying, we may want to call
# a version of sage-spkg-info to format extra information.
# for sphinx 4.4 we need to replace all direct links by some "extlink" (issue 33272)

(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
echo >> "$OUTPUT_INDEX" " $PKG_BASE"
echo " $PKG_BASE"
done
cat >> "$OUTPUT_INDEX" <<EOF
cat <<EOF
.. default-role::
EOF
) > "$OUTPUT_INDEX"
sage-package list --has-file SPKG.rst | OUTPUT_DIR=$OUTPUT_DIR OUTPUT_RST=1 xargs -P 0 -n 1 sage-spkg-info

0 comments on commit 80d1abc

Please sign in to comment.