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

src/doc/bootstrap: Parallelize generation of SPKG.rst files #36911

Merged
merged 3 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -190,7 +190,7 @@ All External Packages
EOF

OUTPUT_INDEX="$OUTPUT_DIR"/index_alph.rst
cat >> "$OUTPUT_INDEX" <<EOF
(cat <<EOF

Details of external packages
============================
Expand All @@ -204,16 +204,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
Loading