66# You can set these variables from the command line.
77PYTHON = python3
88VENVDIR = ./venv
9+ VENVDIR_PDF = ./venv-pdf
910UV = uv
1011SPHINXBUILD = PATH=$(VENVDIR ) /bin:$$PATH sphinx-build
1112BLURB = PATH=$(VENVDIR ) /bin:$$PATH blurb
@@ -163,7 +164,7 @@ clean: clean-venv
163164
164165.PHONY : clean-venv
165166clean-venv :
166- rm -rf $(VENVDIR )
167+ rm -rf $(VENVDIR ) $( VENVDIR_PDF )
167168
168169.PHONY : venv
169170venv :
@@ -184,6 +185,25 @@ venv:
184185 echo " The venv has been created in the $( VENVDIR) directory" ; \
185186 fi
186187
188+ .PHONY : venv-pdf
189+ venv-pdf :
190+ @if [ -d $( VENVDIR_PDF) ] ; then \
191+ echo " venv-pdf already exists." ; \
192+ echo " To recreate it, remove it first with \` make clean-venv'." ; \
193+ else \
194+ set -e; \
195+ echo " Creating venv in $( VENVDIR_PDF) " ; \
196+ if $( UV) --version > /dev/null 2>&1 ; then \
197+ $(UV ) venv --python=$(PYTHON ) $(VENVDIR_PDF ) ; \
198+ VIRTUAL_ENV=$(VENVDIR_PDF ) $(UV ) pip install -r requirements-pdf.txt; \
199+ else \
200+ $(PYTHON ) -m venv $(VENVDIR_PDF ) ; \
201+ $(VENVDIR_PDF ) /bin/python3 -m pip install --upgrade pip; \
202+ $(VENVDIR_PDF ) /bin/python3 -m pip install -r requirements-pdf.txt; \
203+ fi ; \
204+ echo " The venv has been created in the $( VENVDIR_PDF) directory" ; \
205+ fi
206+
187207.PHONY : dist-no-html
188208dist-no-html : dist-text dist-epub dist-texinfo
189209
@@ -231,13 +251,13 @@ dist-text:
231251 @echo " Build finished and archived!"
232252
233253.PHONY : dist-pdf
234- dist-pdf :
254+ dist-pdf : venv-pdf
235255 # archive the A4 latex
236256 @echo " Building LaTeX (A4 paper)..."
237257 mkdir -p dist
238258 rm -rf build/latex
239259 find dist -name ' python-$(DISTVERSION)-docs-pdf*' -exec rm -rf {} \;
240- $(MAKE ) latex PAPER=a4
260+ $(MAKE ) latex PAPER=a4 VENVDIR= $( VENVDIR_PDF )
241261 # remove zip & bz2 dependency on all-pdf,
242262 # as otherwise the full latexmk process is run twice.
243263 # ($$ is needed to escape the $; https://www.gnu.org/software/make/manual/make.html#Basics-of-Variable-References)
0 commit comments