8000 Update `venv` and `clean` make targets (#856) · python/devguide@a8cc91e · GitHub
[go: up one dir, main page]

Skip to content

Commit a8cc91e

Browse files
authored
Update venv and clean make targets (#856)
* Update the `venv` command in the Makefile. * Add the `clean-env` and updated the `clean` command.
1 parent 6490df6 commit a8cc91e

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

Makefile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,26 @@
33

44
# You can set these variables from the command line.
55
PYTHON = python3
6+
VENVDIR = ./venv
7+
BUILDDIR = _build
68
SPHINXOPTS =
7-
SPHINXBUILD = ./venv/bin/sphinx-build
9+
SPHINXBUILD = $(VENVDIR)/bin/sphinx-build
810
PAPER =
9-
BUILDDIR = _build
1011

1112
# Internal variables.
1213
PAPEROPT_a4 = -D latex_paper_size=a4
1314
PAPEROPT_letter = -D latex_paper_size=letter
1415
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
1516

16-
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp \
17+
.PHONY: help venv clean html dirhtml singlehtml pickle json htmlhelp qthelp \
1718
devhelp epub latex latexpdf text man changes linkcheck doctest htmlview check
1819

1920
help:
2021
@echo "Please use \`make <target>' where <target> is one of"
22+
@echo " venv to create a venv with necessary tools"
2123
@echo " html to make standalone HTML files"
2224
@echo " htmlview to open the index page built by the html target in your browser"
25+
@echo " clean to remove the venv and build files"
2326
@echo " dirhtml to make HTML files named index.html in directories"
2427
@echo " singlehtml to make a single large HTML file"
2528
@echo " pickle to make pickle files"
@@ -37,13 +40,22 @@ help:
3740
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
3841
@echo " check to run a check for frequent markup errors"
3942

40-
clean:
43+
clean: clean-venv
4144
-rm -rf $(BUILDDIR)/*
4245

46+
clean-venv:
47+
rm -rf $(VENVDIR)
48+
4349
venv:
44-
$(PYTHON) -m venv venv
45-
./venv/bin/python3 -m pip install --upgrade pip
46-
./venv/bin/python3 -m pip install -r requirements.txt
50+
@if [ -d $(VENVDIR) ] ; then \
51+
echo "venv already exists."; \
52+
echo "To recreate it, remove it first with \`make clean-venv'."; \
53+
else \
54+
$(PYTHON) -m venv $(VENVDIR); \
55+
$(VENVDIR)/bin/python3 -m pip install --upgrade pip; \
56+
$(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \
57+
echo "The venv has been created in the $(VENVDIR) directory"; \
58+
fi
4759

4860
html: venv
4961
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html

0 commit comments

Comments
 (0)
0