Skip to content

Commit be3cce8

Browse files
author
Release Manager
committed
Trac #30010: Split sage_setup.docbuild out to a separate distribution sage_docbuild
`sage_setup.docbuild`, created in #19127, has very different dependencies compared to `sage_setup`: It depends on `sagelib` and `sphinx`, whereas the rest of `sage_setup` is for building `sagelib`. We remove the nesting within `sage_setup`, creating a new top-level package `sage_docbuild`. We split it out as a separate pip-installable distribution package `sage_docbuild`. Using the `spkg-src` script, a pip-installable tarball can be generated, which could be uploaded to PyPI -- for the use by external packages that want to build documentation. This is preparation for #29868 (pip-installable packages sagemath-doc- src, sagemath-doc-inventory, sagemath-doc-html, sagemath-doc-pdf) URL: https://trac.sagemath.org/30010 Reported by: mkoeppe Ticket author(s): Matthias Koeppe Reviewer(s): John Palmieri
2 parents 9eb36fd + aaab1d3 commit be3cce8

28 files changed

+166
-29
lines changed

build/bin/sage-site

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ if [ "$1" = "-docbuild" -o "$1" = "--docbuild" ]; then
162162
export OMP_NUM_THREADS=1
163163
fi
164164

165-
exec sage-python -m sage_setup.docbuild "$@" </dev/null
165+
exec sage-python -m sage_docbuild "$@" </dev/null
166166
fi
167167

168168
if [ "$1" = '-git-branch' -o "$1" = '--git-branch' ]; then

build/make/Makefile.in

+5-2
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ base: $(inst_patch) $(inst_pkgconf)
335335
# Building the documentation has many dependencies, because all
336336
# documented modules are imported and because we use matplotlib to
337337
# produce plots.
338-
DOC_DEPENDENCIES = sagelib $(inst_sphinx) \
338+
DOC_DEPENDENCIES = sagelib sage_docbuild $(inst_sphinx) \
339339
| $(SAGERUNTIME) $(inst_maxima) $(inst_networkx) $(inst_scipy) $(inst_sympy) \
340340
$(inst_matplotlib) $(inst_pillow) $(inst_mathjax) $(inst_mpmath) \
341341
$(inst_ipykernel) $(inst_jupyter_client) $(inst_conway_polynomials) \
@@ -391,7 +391,10 @@ sagelib-clean:
391391
rm -rf sage/ext/interpreters) \
392392
&& (cd "$(SAGE_ROOT)/build/pkgs/sagelib/src/" && rm -rf build)
393393

394-
build-clean: clean doc-clean sagelib-clean
394+
sage_docbuild-clean:
395+
(cd "$(SAGE_ROOT)/build/pkgs/sage_docbuild/src" && rm -rf build)
396+
397+
build-clean: clean doc-clean sagelib-clean sage_docbuild-clean
395398

396399
# Special target for cleaning up a broken GCC install detected by configure
397400
# This should check for the .clean-broken-gcc stamp, and if found clean

build/pkgs/sage_docbuild/dependencies

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$(PYTHON) sphinx ../pkgs/sage_docbuild/src/sage_docbuild/*.py ../pkgs/sage_docbuild/src/sage_docbuild/ext/*.py | $(PYTHON_TOOLCHAIN) sagelib
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../sagelib/package-version.txt

build/pkgs/sage_docbuild/spkg-install

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
# From sage-spkg.
3+
# For type=script packages, the build rule in build/make/Makefile sources
4+
# sage-env but not sage-dist-helpers.
5+
lib="$SAGE_ROOT/build/bin/sage-dist-helpers"
6+
source "$lib"
7+
if [ $? -ne 0 ]; then
8+
echo >&2 "Error: failed to source $lib"
9+
echo >&2 "Is $SAGE_ROOT the correct SAGE_ROOT?"
10+
exit 1
11+
fi
12+
# We build the wheel directly with "setup.py bdist_wheel", not with "pip wheel",
13+
# because pip does not handle our symlinks correctly.
14+
cd src && sdh_setup_bdist_wheel && sdh_store_and_pip_install_wheel .

build/pkgs/sage_docbuild/spkg-src

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Script to prepare an sdist tarball for sage_docbuild
4+
# This script is not used during build.
5+
#
6+
# HOW TO MAKE THE TARBALL:
7+
# ./sage --sh build/pkgs/sage_docbuild/spkg-src
8+
9+
if [ -z "$SAGE_ROOT" ] ; then
10+
echo >&2 "Error - SAGE_ROOT undefined ... exiting"
11+
echo >&2 "Maybe run 'sage -sh'?"
12+
exit 1
13+
fi
14+
15+
# Exit on failure
16+
set -e
17+
18+
cd build/pkgs/sage_docbuild
19+
20+
cd src
21+
python3 -u setup.py --no-user-cfg sdist --dist-dir "$SAGE_DISTFILES"
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include VERSION.txt
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
================================================================================
2+
Sage: Open Source Mathematics Software: Build system of the Sage documentation
3+
================================================================================
4+
5+
About SageMath
6+
--------------
7+
8+
"Creating a Viable Open Source Alternative to
9+
Magma, Maple, Mathematica, and MATLAB"
10+
11+
Copyright (C) 2005-2020 The Sage Development Team
12+
13+
https://www.sagemath.org
14+
15+
SageMath fully supports all major Linux distributions, recent versions of macOS, and Windows (using Cygwin or Windows Subsystem for Linux).
16+
17+
The traditional and recommended way to install SageMath is from source via Sage-the-distribution (https://www.sagemath.org/download-source.html). Sage-the-distribution first builds a large number of open source packages from source (unless it finds suitable versions installed in the system) and then installs the Sage Library (sagelib, implemented in Python and Cython).
18+
19+
20+
About this pip-installable source distribution
21+
----------------------------------------------
22+
23+
This is the build system of the Sage documentation, based on Sphinx.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../package-version.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#sage
2+
sphinx
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../src/sage_docbuild
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[metadata]
2+
name = sage_docbuild
3+
version = file: VERSION.txt
4+
description = Sage: Open Source Mathematics Software: Build system of the Sage documentation
5+
long_description = file: README.rst
6+
long_description_content_type = text/x-rst
7+
license = GNU General Public License (GPL) v2 or later
8+
author = The Sage Developers
9+
author_email = [email protected]
10+
url = https://www.sagemath.org
11+
12+
classifiers =
13+
Development Status :: 6 - Mature
14+
Intended Audience :: Education
15+
Intended Audience :: Science/Research
16+
License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
17+
Operating System :: POSIX
18+
Operating System :: MacOS :: MacOS X
19+
Programming Language :: Python :: 3 :: Only
20+
Programming Language :: Python :: 3.6
21+
Programming Language :: Python :: 3.7
22+
Programming Language :: Python :: 3.8
23+
Programming Language :: Python :: 3.9
24+
Programming Language :: Python :: Implementation :: CPython
25+
Topic :: Scientific/Engineering :: Mathematics
26+
27+
[options]
28+
packages =
29+
sage_docbuild
30+
sage_docbuild.ext
31+
32+
install_requires =
33+
sphinx

build/pkgs/sage_docbuild/src/setup.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env python
2+
3+
from setuptools import setup
4+
5+
setup()

build/pkgs/sage_docbuild/src/tox.ini

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# First pip-install tox:
2+
#
3+
# ./sage -pip install tox
4+
#
5+
# To build and test in the tox environment:
6+
#
7+
# ./sage -sh -c '(cd build/pkgs/sage_docbuild/src && tox)'
8+
#
9+
# To test interactively:
10+
#
11+
# build/pkgs/sage_docbuild/src/.tox/python/bin/python
12+
#
13+
[tox]
14+
15+
[testenv]
16+
deps = -rrequirements.txt
17+
18+
setenv =
19+
# Sage scripts like to use $HOME/.sage
20+
HOME={envdir}
21+
22+
whitelist_externals =
23+
bash
24+
25+
commands =
26+
# Beware of the treacherous non-src layout.
27+
#python -c 'import sys; "" in sys.path and sys.path.remove(""); import sage_docbuild'
28+
29+
# TODO: Add tests after adding the dependency on sagelib to
30+
# requirements.txt

build/pkgs/sage_docbuild/type

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
standard

build/pkgs/sagelib/src/MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ prune .tox
66

77
graft sage/libs/gap/test
88
prune sage/ext/interpreters # In particular, __init__.py must not be present in the distribution; or sage_setup.autogen.interpreters.rebuild will not generate the code
9+
10+
prune sage_docbuild # Shipped by sage_docbuild

src/doc/en/developer/sage_manuals.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Building the Manuals
176176

177177
All of the Sage manuals are built using the ``sage --docbuild``
178178
script. The content of the ``sage --docbuild`` script is defined in
179-
``SAGE_ROOT/src/sage_setup/docbuild/__init__.py``. It is a thin wrapper around
179+
``SAGE_ROOT/src/sage_docbuild/__init__.py``. It is a thin wrapper around
180180
the ``sphinx-build`` script which does all of the real work. It is
181181
designed to be a replacement for the default Makefiles generated by
182182
the ``sphinx-quickstart`` script. The general form of the command

src/sage/docs/conf.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,14 @@
1212
import sphinx.ext.intersphinx as intersphinx
1313
from IPython.lib.lexers import IPythonConsoleLexer, IPyLexer
1414

15-
# If your extensions are in another directory, add it here.
16-
sys.path.append(os.path.join(SAGE_SRC, "sage_setup", "docbuild", "ext"))
17-
1815
# General configuration
1916
# ---------------------
2017

2118
# Add any Sphinx extension module names here, as strings. They can be extensions
2219
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
23-
extensions = ['inventory_builder',
24-
'multidocs',
25-
'sage_autodoc',
20+
extensions = ['sage_docbuild.ext.inventory_builder',
21+
'sage_docbuild.ext.multidocs',
22+
'sage_docbuild.ext.sage_autodoc',
2623
'sphinx.ext.graphviz',
2724
'sphinx.ext.inheritance_diagram',
2825
'sphinx.ext.todo',

src/sage/doctest/control.py

+1
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ def all_files():
700700
# don't make sense to run outside a build environment
701701
if have_git:
702702
self.files.append(opj(SAGE_SRC, 'sage_setup'))
703+
self.files.append(opj(SAGE_SRC, 'sage_docbuild'))
703704
self.files.append(SAGE_DOC_SRC)
704705

705706
if self.options.all or (self.options.new and not have_git):

src/sage_setup/docbuild/__init__.py src/sage_docbuild/__init__.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ def builder_helper(type):
9090
9191
Check that :trac:`25161` has been resolved::
9292
93-
sage: from sage_setup.docbuild import DocBuilder, setup_parser
93+
sage: from sage_docbuild import DocBuilder, setup_parser
9494
sage: DocBuilder._options = setup_parser().parse_args([])[0] # builder_helper needs _options to be set
9595
96-
sage: import sage_setup.docbuild.sphinxbuild
96+
sage: import sage_docbuild.sphinxbuild
9797
sage: def raiseBaseException():
9898
....: raise BaseException("abort pool operation")
99-
sage: original_runsphinx, sage_setup.docbuild.sphinxbuild.runsphinx = sage_setup.docbuild.sphinxbuild.runsphinx, raiseBaseException
99+
sage: original_runsphinx, sage_docbuild.sphinxbuild.runsphinx = sage_docbuild.sphinxbuild.runsphinx, raiseBaseException
100100
101-
sage: from sage_setup.docbuild import builder_helper, build_ref_doc
102-
sage: from sage_setup.docbuild import _build_many as build_many
101+
sage: from sage_docbuild import builder_helper, build_ref_doc
102+
sage: from sage_docbuild import _build_many as build_many
103103
sage: helper = builder_helper("html")
104104
sage: try:
105105
....: build_many(build_ref_doc, [("docname", "en", "html", {})])
@@ -180,7 +180,7 @@ def _output_dir(self, type):
180180
181181
EXAMPLES::
182182
183-
sage: from sage_setup.docbuild import DocBuilder
183+
sage: from sage_docbuild import DocBuilder
184184
sage: b = DocBuilder('tutorial')
185185
sage: b._output_dir('html')
186186
'.../html/en/tutorial'
@@ -197,7 +197,7 @@ def _doctrees_dir(self):
197197
198198
EXAMPLES::
199199
200-
sage: from sage_setup.docbuild import DocBuilder
200+
sage: from sage_docbuild import DocBuilder
201201
sage: b = DocBuilder('tutorial')
202202
sage: b._doctrees_dir()
203203
'.../doctrees/en/tutorial'
@@ -212,7 +212,7 @@ def _output_formats(self):
212212
213213
EXAMPLES::
214214
215-
sage: from sage_setup.docbuild import DocBuilder
215+
sage: from sage_docbuild import DocBuilder
216216
sage: b = DocBuilder('tutorial')
217217
sage: b._output_formats()
218218
['changes', 'html', 'htmlhelp', 'inventory', 'json', 'latex', 'linkcheck', 'pickle', 'web']
@@ -236,7 +236,7 @@ def pdf(self):
236236
237237
EXAMPLES::
238238
239-
sage: from sage_setup.docbuild import DocBuilder
239+
sage: from sage_docbuild import DocBuilder
240240
sage: b = DocBuilder('tutorial')
241241
sage: b.pdf() #not tested
242242
"""
@@ -288,7 +288,7 @@ def clean(self, *args):
288288

289289
def build_many(target, args, processes=None):
290290
"""
291-
Thin wrapper around `sage_setup.docbuild.utils.build_many` which uses the
291+
Thin wrapper around `sage_docbuild.utils.build_many` which uses the
292292
docbuild settings ``NUM_THREADS`` and ``ABORT_ON_ERROR``.
293293
"""
294294
if processes is None:
@@ -369,7 +369,7 @@ def get_all_documents(self):
369369
370370
EXAMPLES::
371371
372-
sage: from sage_setup.docbuild import AllBuilder
372+
sage: from sage_docbuild import AllBuilder
373373
sage: documents = AllBuilder().get_all_documents()
374374
sage: 'en/tutorial' in documents
375375
True
@@ -525,7 +525,7 @@ def _output_dir(self, type, lang='en'):
525525
526526
EXAMPLES::
527527
528-
sage: from sage_setup.docbuild import ReferenceBuilder
528+
sage: from sage_docbuild import ReferenceBuilder
529529
sage: b = ReferenceBuilder('reference')
530530
sage: b._output_dir('html')
531531
'.../html/en/reference'
@@ -688,7 +688,7 @@ def get_all_documents(self, refdir):
688688
689689
EXAMPLES::
690690
691-
sage: from sage_setup.docbuild import ReferenceBuilder
691+
sage: from sage_docbuild import ReferenceBuilder
692692
sage: b = ReferenceBuilder('reference')
693693
sage: refdir = os.path.join(os.environ['SAGE_DOC_SRC'], 'en', b.name)
694694
sage: sorted(b.get_all_documents(refdir))
@@ -1046,7 +1046,7 @@ def auto_rest_filename(self, module_name):
10461046
10471047
EXAMPLES::
10481048
1049-
sage: from sage_setup.docbuild import ReferenceSubBuilder
1049+
sage: from sage_docbuild import ReferenceSubBuilder
10501050
sage: ReferenceSubBuilder("reference").auto_rest_filename("sage.combinat.partition")
10511051
'.../doc/en/reference/sage/combinat/partition.rst'
10521052
"""
@@ -1616,7 +1616,7 @@ def setup_logger(verbose=1, color=True):
16161616
16171617
EXAMPLES::
16181618
1619-
sage: from sage_setup.docbuild import setup_logger, logger
1619+
sage: from sage_docbuild import setup_logger, logger
16201620
sage: setup_logger()
16211621
sage: type(logger)
16221622
<class 'logging.Logger'>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/sage_setup/docbuild/sphinxbuild.py src/sage_docbuild/sphinxbuild.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _check_errors(self, line):
172172
EXAMPLES::
173173
174174
sage: from sys import stdout
175-
sage: from sage_setup.docbuild.sphinxbuild import SageSphinxLogger
175+
sage: from sage_docbuild.sphinxbuild import SageSphinxLogger
176176
sage: logger = SageSphinxLogger(stdout, "doctesting")
177177
sage: logger._log_line("Segmentation fault!\n") # indirect doctest
178178
[doctestin] Segmentation fault!
@@ -200,7 +200,7 @@ def _log_line(self, line):
200200
EXAMPLES::
201201
202202
sage: from sys import stdout
203-
sage: from sage_setup.docbuild.sphinxbuild import SageSphinxLogger
203+
sage: from sage_docbuild.sphinxbuild import SageSphinxLogger
204204
sage: logger = SageSphinxLogger(stdout, "doctesting")
205205
sage: logger._log_line("building documentation…\n")
206206
[doctestin] building documentation…
@@ -243,7 +243,7 @@ def raise_errors(self):
243243
EXAMPLES::
244244
245245
sage: from sys import stdout
246-
sage: from sage_setup.docbuild.sphinxbuild import SageSphinxLogger
246+
sage: from sage_docbuild.sphinxbuild import SageSphinxLogger
247247
sage: logger = SageSphinxLogger(stdout, "doctesting")
248248
sage: logger._log_line("This is a SEVERE error\n")
249249
[doctestin] This is a SEVERE error

src/sage_setup/docbuild/utils.py src/sage_docbuild/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def build_many(target, args, processes=None):
4242
4343
EXAMPLES::
4444
45-
sage: from sage_setup.docbuild.utils import build_many
45+
sage: from sage_docbuild.utils import build_many
4646
sage: def target(N):
4747
....: import time
4848
....: time.sleep(float(0.1))

0 commit comments

Comments
 (0)