Skip to content

Commit 53e3d90

Browse files
authored
Only print make venv message when needed. (python#867)
* Only print `make venv` message when needed. * Remove duplicated code.
1 parent 272c02d commit 53e3d90

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

Makefile

+22-17
Original file line numberDiff line numberDiff line change
@@ -52,44 +52,49 @@ venv:
5252
echo "venv already exists."; \
5353
echo "To recreate it, remove it first with \`make clean-venv'."; \
5454
else \
55+
$(MAKE) ensure-venv; \
56+
fi
57+
58+
ensure-venv:
59+
@if [ ! -d $(VENVDIR) ] ; then \
5560
$(PYTHON) -m venv $(VENVDIR); \
5661
$(VENVDIR)/bin/python3 -m pip install --upgrade pip; \
5762
$(VENVDIR)/bin/python3 -m pip install -r requirements.txt; \
5863
echo "The venv has been created in the $(VENVDIR) directory"; \
5964
fi
6065

61-
html: venv
66+
html: ensure-venv
6267
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
6368
@echo
6469
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
6570

66-
dirhtml: venv
71+
dirhtml: ensure-venv
6772
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
6873
@echo
6974
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
7075

71-
singlehtml: venv
76+
singlehtml: ensure-venv
7277
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
7378
@echo
7479
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
7580

76-
pickle: venv
81+
pickle: ensure-venv
7782
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
7883
@echo
7984
@echo "Build finished; now you can process the pickle files."
8085

81-
json: venv
86+
json: ensure-venv
8287
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
8388
@echo
8489
@echo "Build finished; now you can process the JSON files."
8590

86-
htmlhelp: venv
91+
htmlhelp: ensure-venv
8792
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
8893
@echo
8994
@echo "Build finished; now you can run HTML Help Workshop with the" \
9095
".hhp project file in $(BUILDDIR)/htmlhelp."
9196

92-
qthelp: venv
97+
qthelp: ensure-venv
9398
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
9499
@echo
95100
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
@@ -98,7 +103,7 @@ qthelp: venv
98103
@echo "To view the help file:"
99104
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PythonDevelopersGuide.qhc"
100105

101-
devhelp: venv
106+
devhelp: ensure-venv
102107
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
103108
@echo
104109
@echo "Build finished."
@@ -107,54 +112,54 @@ devhelp: venv
107112
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PythonDevelopersGuide"
108113
@echo "# devhelp"
109114

110-
epub: venv
115+
epub: ensure-venv
111116
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
112117
@echo
113118
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
114119

115-
latex: venv
120+
latex: ensure-venv
116121
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
117122
@echo
118123
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
119124
@echo "Run \`make' in that directory to run these through (pdf)latex" \
120125
"(use \`make latexpdf' here to do that automatically)."
121126

122-
latexpdf: venv
127+
latexpdf: ensure-venv
123128
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
124129
@echo "Running LaTeX files through pdflatex..."
125130
make -C $(BUILDDIR)/latex all-pdf
126131
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
127132

128-
text: venv
133+
text: ensure-venv
129134
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
130135
@echo
131136
@echo "Build finished. The text files are in $(BUILDDIR)/text."
132137

133-
man: venv
138+
man: ensure-venv
134139
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
135140
@echo
136141
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
137142

138-
changes: venv
143+
changes: ensure-venv
139144
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
140145
@echo
141146
@echo "The overview file is in $(BUILDDIR)/changes."
142147

143-
linkcheck: venv
148+
linkcheck: ensure-venv
144149
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
145150
@echo
146151
@echo "Link check complete; look for any errors in the above output " \
147152
"or in $(BUILDDIR)/linkcheck/output.txt."
148153

149-
doctest: venv
154+
doctest: ensure-venv
150155
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
151156
@echo "Testing of doctests in the sources finished, look at the " \
152157
"results in $(BUILDDIR)/doctest/output.txt."
153158

154159
htmlview: html
155160
$(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('_build/html/index.html'))"
156161

157-
check: venv
162+
check: ensure-venv
158163
# Ignore the tools and venv dirs and check that the default role is not used.
159164
$(SPHINXLINT) -i tools -i $(VENVDIR) --enable default-role
160165

0 commit comments

Comments
 (0)