sageWithDoc: run src/doc/bootstrap script before docbuild

This commit is contained in:
Mauricio Collares 2023-05-21 16:26:59 +02:00
parent 0edaaae3ff
commit c13e4258f6
2 changed files with 21 additions and 17 deletions

View file

@ -92,17 +92,6 @@ stdenv.mkDerivation rec {
sed -i \
"s|var(\"SAGE_ROOT\".*|var(\"SAGE_ROOT\", \"$out\")|" \
src/sage/env.py
# docbuilding expects a spkg index generated by the doc/bootstrap script (which
# we don't run) to exist. the spkg list includes nix package names, but it's not
# worth the hassle of running the bootstrap script, so just create a dummy index.
touch src/doc/en/reference/spkg/index.rst
# the bootstrap script also generates installation instructions for
# arch, debian, fedora, cygwin and homebrew using data from build/pkgs.
# we don't run the bootstrap script, so disable including the generated
# files. docbuilding fails otherwise.
sed -i "/literalinclude/d" src/doc/en/installation/source.rst
'';
buildPhase = "# do nothing";

View file

@ -11,6 +11,11 @@ stdenv.mkDerivation rec {
strictDeps = true;
nativeBuildInputs = [
# for patchShebangs below
python3
];
unpackPhase = ''
export SAGE_DOC_OVERRIDE="$PWD/share/doc/sage"
export SAGE_DOC_SRC_OVERRIDE="$PWD/docsrc"
@ -24,15 +29,25 @@ stdenv.mkDerivation rec {
export HOME="$TMPDIR/sage_home"
mkdir -p "$HOME"
# run bootstrap script to generate Sage spkg docs, because unfortunately some unrelated doc
# pages link to them. it needs a few ugly (but self-contained) hacks for a standalone run.
cp -r "${src}/build" "$HOME"
chmod -R 755 "$HOME/build"
sed -i "/assert/d" "$HOME/build/sage_bootstrap/env.py"
sed -i "s|sage-bootstrap-python|python3|" "$HOME/build/bin/sage-package"
patchShebangs "$HOME/build/bin/sage-package"
pushd "$SAGE_DOC_SRC_OVERRIDE"
sed -i "s|OUTPUT_DIR=\"src/doc/|OUTPUT_DIR=\"$SAGE_DOC_SRC_OVERRIDE/|" bootstrap
PATH="$HOME/build/bin:$PATH" SAGE_ROOT="${src}" ./bootstrap
popd
# adapted from src/doc/Makefile (doc-src target), which tries to call Sage from PATH
mkdir -p $SAGE_DOC_SRC_OVERRIDE/en/reference/repl
${sage-with-env}/bin/sage -advanced > $SAGE_DOC_SRC_OVERRIDE/en/reference/repl/options.txt
# needed to link them in the sage docs using intersphinx
export PPLPY_DOCS=${python3.pkgs.pplpy.doc}/share/doc/pplpy
# adapted from src/doc/bootstrap (which we don't run)
OUTPUT_DIR="$SAGE_DOC_SRC_OVERRIDE/en/reference/repl"
mkdir -p "$OUTPUT_DIR"
OUTPUT="$OUTPUT_DIR/options.txt"
${sage-with-env}/bin/sage -advanced > "$OUTPUT"
# jupyter-sphinx calls the sagemath jupyter kernel during docbuild
export JUPYTER_PATH=${jupyter-kernel-specs}