Skip to content

Commit d22c876

Browse files
authored
bpo-44756: in ./Doc, make build depends on make html (#27403)
- venv rule is now conditional, and only does anything if $VENVDIR does not exist - add rule "clean-venv"
1 parent ddf8ae3 commit d22c876

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

Doc/Makefile

+14-7
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ help:
4545
@echo " check to run a check for frequent markup errors"
4646
@echo " serve to serve the documentation on the localhost (8000)"
4747

48-
build:
48+
build: venv
4949
-mkdir -p build
5050
# Look first for a Misc/NEWS file (building from a source release tarball
5151
# or old repo) and use that, otherwise look for a Misc/NEWS.d directory
@@ -137,14 +137,21 @@ pydoc-topics: build
137137
htmlview: html
138138
$(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
139139

140-
clean:
141-
-rm -rf build/* $(VENVDIR)/*
140+
clean: clean-venv
141+
-rm -rf build/*
142+
143+
clean-venv:
144+
rm -rf $(VENVDIR)
142145

143146
venv:
144-
$(PYTHON) -m venv $(VENVDIR)
145-
$(VENVDIR)/bin/python3 -m pip install -U pip setuptools
146-
$(VENVDIR)/bin/python3 -m pip install -r requirements.txt
147-
@echo "The venv has been created in the $(VENVDIR) directory"
147+
@if [ -d $(VENVDIR) ] ; then \
148+
echo "venv already exists"; \
149+
else \
150+
$(PYTHON) -m venv $(VENVDIR); \
151+
$(VENVDIR)/bin/python3 -m pip install -U pip setuptools; \
152+
$(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \
153+
echo "The venv has been created in the $(VENVDIR) directory"; \
154+
fi
148155

149156
dist:
150157
rm -rf dist

Doc/README.rst

+9-13
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,24 @@ install the tools into there.
2828
Using make
2929
----------
3030

31-
To get started on UNIX, you can create a virtual environment with the command ::
32-
33-
make venv
34-
35-
That will install all the tools necessary to build the documentation. Assuming
36-
the virtual environment was created in the ``venv`` directory (the default;
37-
configurable with the VENVDIR variable), you can run the following command to
38-
build the HTML output files::
31+
To get started on UNIX, you can create a virtual environment and build
32+
documentation with the command::
3933

4034
make html
4135

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).
36+
The virtual environment in the ``venv`` directory will contain all the tools
37+
necessary to build the documentation. You can also configure where the virtual
38+
environment directory will be with the ``VENVDIR`` variable.
4539

4640
On Windows, we try to emulate the Makefile as closely as possible with a
4741
``make.bat`` file. If you need to specify the Python interpreter to use,
48-
set the PYTHON environment variable instead.
42+
set the PYTHON environment variable.
4943

5044
Available make targets are:
5145

52-
* "clean", which removes all build files.
46+
* "clean", which removes all build files and the virtual environment.
47+
48+
* "clean-venv", which removes the virtual environment directory.
5349

5450
* "venv", which creates a virtual environment with all necessary tools
5551
installed.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
In the Makefile for documentation (:file:`Doc/Makefile`), the ``build`` rule
2+
is dependent on the ``venv`` rule. Therefore, ``html``, ``latex``, and other
3+
build-dependent rules are also now dependent on ``venv``. The ``venv`` rule
4+
only performs an action if ``$(VENVDIR)`` does not exist.
5+
:file:`Doc/README.rst` was updated; most users now only need to type ``make
6+
html``.

0 commit comments

Comments
 (0)