Skip to content

Commit 590665c

Browse files
authoredSep 8, 2017
bpo-31036: Allow sphinx and blurb to be found automatically (python#3440)
Rather than requiring the path to blurb and/or sphinx-build to be specified to the make rule, enhance the Doc/Makefile to look for each first in a virtual environment created by make venv and, if not found, look on the normal process PATH. This allows the Doc/Makefile to take advantage of an installed spinx-build or blurb and, thus, do the right thing most of the time. Also, make the directory for the venv be configurable and document the `make venv` target.
1 parent 5a85167 commit 590665c

File tree

3 files changed

+38
-26
lines changed

3 files changed

+38
-26
lines changed
 

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
.gdb_history
2020
Doc/build/
2121
Doc/venv/
22+
Doc/.venv/
23+
Doc/env/
24+
Doc/.env/
2225
Include/pydtrace_probes.h
2326
Lib/distutils/command/*.pdb
2427
Lib/lib2to3/*.pickle

‎Doc/Makefile

+8-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
# You can set these variables from the command line.
77
PYTHON = python3
8-
SPHINXBUILD = sphinx-build
9-
BLURB = $(PYTHON) -m blurb
8+
VENVDIR = ./venv
9+
SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-build
10+
BLURB = PATH=$(VENVDIR)/bin:$$PATH blurb
1011
PAPER =
1112
SOURCES =
1213
DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
@@ -118,11 +119,12 @@ htmlview: html
118119
$(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
119120

120121
clean:
121-
-rm -rf build/* venv/*
122+
-rm -rf build/* $(VENVDIR)/*
122123

123124
venv:
124-
$(PYTHON) -m venv venv
125-
./venv/bin/python3 -m pip install -U Sphinx blurb
125+
$(PYTHON) -m venv $(VENVDIR)
126+
$(VENVDIR)/bin/python3 -m pip install -U Sphinx blurb
127+
@echo "The venv has been created in the $(VENVDIR) directory"
126128

127129
dist:
128130
rm -rf dist
@@ -168,7 +170,7 @@ dist:
168170
cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
169171

170172
check:
171-
$(PYTHON) tools/rstlint.py -i tools -i venv -i README.rst
173+
$(PYTHON) tools/rstlint.py -i tools -i $(VENVDIR) -i README.rst
172174

173175
serve:
174176
../Tools/scripts/serve.py build/html

‎Doc/README.rst

+27-20
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,46 @@ developers guide.
1414
Building the docs
1515
=================
1616

17-
You need to have `Sphinx <http://sphinx-doc.org/>`_ installed; it is the toolset
18-
used to build the docs. It is not included in this tree, but maintained
19-
separately and `available from PyPI <https://pypi.python.org/pypi/Sphinx>`_.
17+
The documentation is built with several tools which are not included in this
18+
tree but are maintained separately and are available from
19+
`PyPI <https://pypi.org/>`_.
20+
21+
* `Sphinx <https://pypi.org/project/Sphinx/>`_
22+
* `blurb <https://pypi.org/project/blurb/>`_
23+
24+
The easiest way to install these tools is to create a virtual environment and
25+
install the tools into there.
2026

2127

2228
Using make
2329
----------
2430

25-
A Makefile has been prepared so that on Unix, provided you have installed
26-
Sphinx, you can just run ::
31+
To get started on UNIX, you can create a virtual environment with the command ::
2732

28-
make html
33+
make venv
2934

30-
to build the HTML output files.
31-
32-
On Windows, we try to emulate the Makefile as closely as possible with a
33-
``make.bat`` file.
35+
That will install all the tools necessary to build the documentation. Assuming
36+
the virtual environment was created in the ``env`` directory (the default;
37+
configurable with the VENVDIR variable), you can run the following command to
38+
build the HTML output files::
3439

35-
To use a Python interpreter that's not called ``python``, use the standard
36-
way to set Makefile variables, using e.g. ::
40+
make html
3741

38-
make html PYTHON=python3
42+
By default, if the virtual environment is not created, the Makefile will
43+
look for instances of sphinxbuild and blurb installed on your process PATH
44+
(configurable with the SPHINXBUILD and BLURB variables).
3945

40-
On Windows, set the PYTHON environment variable instead.
41-
42-
To use a specific sphinx-build (something other than ``sphinx-build``), set
43-
the SPHINXBUILD variable.
46+
On Windows, we try to emulate the Makefile as closely as possible with a
47+
``make.bat`` file. If you need to specify the Python interpreter to use,
48+
set the PYTHON environment variable instead.
4449

4550
Available make targets are:
4651

4752
* "clean", which removes all build files.
4853

54+
* "venv", which creates a virtual environment with all necessary tools
55+
installed.
56+
4957
* "html", which builds standalone HTML files for offline viewing.
5058

5159
* "htmlview", which re-uses the "html" builder, but then opens the main page
@@ -96,7 +104,7 @@ Available make targets are:
96104
Without make
97105
------------
98106

99-
Install the Sphinx package and its dependencies from PyPI.
107+
First, install the tool dependencies from PyPI.
100108

101109
Then, from the ``Doc`` directory, run ::
102110

@@ -112,8 +120,7 @@ Contributing
112120
Bugs in the content should be reported to the
113121
`Python bug tracker <https://bugs.python.org>`_.
114122

115-
Bugs in the toolset should be reported in the
116-
`Sphinx bug tracker <https://github.com/sphinx-doc/sphinx/issues>`_.
123+
Bugs in the toolset should be reported to the tools themselves.
117124

118125
You can also send a mail to the Python Documentation Team at docs@python.org,
119126
and we will process your request as soon as possible.

0 commit comments

Comments
 (0)