Skip to content

Commit 273d2aa

Browse files
committed
Add support for PDF virtual environment in Makefile
1 parent 6c6f528 commit 273d2aa

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
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
@@ -163,7 +164,7 @@ clean: clean-venv
163164

164165
.PHONY: clean-venv
165166
clean-venv:
166-
rm -rf $(VENVDIR)
167+
rm -rf $(VENVDIR) $(VENVDIR_PDF)
167168

168169
.PHONY: venv
169170
venv:
@@ -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
188208
dist-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)

Doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
# Ignore any .rst files in the includes/ directory;
117117
# they're embedded in pages but not rendered as individual pages.
118118
# Ignore any .rst files in the venv/ directory.
119-
exclude_patterns = ['includes/*.rst', 'venv/*', 'README.rst']
119+
exclude_patterns = ['includes/*.rst', 'venv/*', 'venv-pdf/*', 'README.rst']
120120
venvdir = os.getenv('VENVDIR')
121121
if venvdir is not None:
122122
exclude_patterns.append(venvdir + '/*')

0 commit comments

Comments
 (0)