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
@@ -162,7 +163,7 @@ clean: clean-venv
162163
163164.PHONY : clean-venv
164165clean-venv :
165- rm -rf $(VENVDIR )
166+ rm -rf $(VENVDIR ) $( VENVDIR_PDF )
166167
167168.PHONY : venv
168169venv :
@@ -183,6 +184,25 @@ venv:
183184 echo " The venv has been created in the $( VENVDIR) directory" ; \
184185 fi
185186
187+ .PHONY : venv-pdf
188+ venv-pdf :
189+ @if [ -d $( VENVDIR_PDF) ] ; then \
190+ echo " venv-pdf already exists." ; \
191+ echo " To recreate it, remove it first with \` make clean-venv'." ; \
192+ else \
193+ set -e; \
194+ echo " Creating venv in $( VENVDIR_PDF) " ; \
195+ if $( UV) --version > /dev/null 2>&1 ; then \
196+ $(UV ) venv --python=$(PYTHON ) $(VENVDIR_PDF ) ; \
197+ VIRTUAL_ENV=$(VENVDIR_PDF ) $(UV ) pip install -r requirements-pdf.txt; \
198+ else \
199+ $(PYTHON ) -m venv $(VENVDIR_PDF ) ; \
200+ $(VENVDIR_PDF ) /bin/python3 -m pip install --upgrade pip; \
201+ $(VENVDIR_PDF ) /bin/python3 -m pip install -r requirements-pdf.txt; \
202+ fi ; \
203+ echo " The venv has been created in the $( VENVDIR_PDF) directory" ; \
204+ fi
205+
186206.PHONY : dist-no-html
187207dist-no-html : dist-text dist-epub dist-texinfo
188208
@@ -230,13 +250,13 @@ dist-text:
230250 @echo " Build finished and archived!"
231251
232252.PHONY : dist-pdf
233- dist-pdf :
253+ dist-pdf : venv-pdf
234254 # archive the A4 latex
235255 @echo " Building LaTeX (A4 paper)..."
236256 mkdir -p dist
237257 rm -rf build/latex
238258 find dist -name ' python-$(DISTVERSION)-docs-pdf*' -exec rm -rf {} \;
239- $(MAKE ) latex PAPER=a4
259+ $(MAKE ) latex PAPER=a4 VENVDIR= $( VENVDIR_PDF )
240260 # remove zip & bz2 dependency on all-pdf,
241261 # as otherwise the full latexmk process is run twice.
242262 # ($$ is needed to escape the $; https://www.gnu.org/software/make/manual/make.html#Basics-of-Variable-References)
0 commit comments