Skip to content

Commit 0baf0c7

Browse files
Copilotm-aciek
andcommitted
Doc/Makefile: use separate venv-pdf for dist-pdf target
Co-authored-by: m-aciek <9288014+m-aciek@users.noreply.github.com>
1 parent 6e2f6ef commit 0baf0c7

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

Doc/Makefile

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# You can set these variables from the command line.
77
PYTHON = python3
88
VENVDIR = ./venv
9+
VENVDIR_PDF = ./venv-pdf
910
UV = uv
1011
SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-build
1112
BLURB = PATH=$(VENVDIR)/bin:$$PATH blurb
@@ -162,7 +163,7 @@ clean: clean-venv
162163

163164
.PHONY: clean-venv
164165
clean-venv:
165-
rm -rf $(VENVDIR)
166+
rm -rf $(VENVDIR) $(VENVDIR_PDF)
166167

167168
.PHONY: venv
168169
venv:
@@ -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
187207
dist-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

Comments
 (0)