Skip to content

gh-139588: Docs: fix PDF build#145480

Open
m-aciek wants to merge 6 commits intopython:mainfrom
m-aciek:pdf-svg-dedicated-venv
Open

gh-139588: Docs: fix PDF build#145480
m-aciek wants to merge 6 commits intopython:mainfrom
m-aciek:pdf-svg-dedicated-venv

Conversation

@m-aciek
Copy link
Contributor

@m-aciek m-aciek commented Mar 3, 2026

Fix PDF build of documentation.

  • Introduced optional sphinxcontrib-svg2pdfconverter dependency in Doc Makefile for PDF build.
  • Use sphinxcontrib.rsvgconverter from the package for converting of SVG graphics to PDF format.
  • Hide GIF graphics (animations) from PDF (LaTeX) build.

Refs. python/docs-community#182.

Test build is available here: http://github.com/m-aciek/python-docs-offline/actions/runs/22771888107. Artifacts include ZIP to download.

For the reference, problematic docs lines:


📚 Documentation preview 📚: https://cpython-previews--145480.org.readthedocs.build/

@python-cla-bot
Copy link

python-cla-bot bot commented Mar 3, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@m-aciek m-aciek force-pushed the pdf-svg-dedicated-venv branch from a930739 to f6981c9 Compare March 4, 2026 22:40
@m-aciek m-aciek changed the title gh-139588: Docs: PDF: dedicated venv and converting SVG to PDF using sphinxcontrib.rsvgconverter gh-139588: Docs: fix PDF build Mar 4, 2026
@m-aciek m-aciek marked this pull request as ready for review March 4, 2026 22:53
Doc/Makefile Outdated
Comment on lines +188 to +206
.PHONY: venv-pdf
venv-pdf:
@if [ -d $(VENVDIR_PDF) ] ; then \
echo "venv-pdf already exists."; \
echo "To recreate it, remove it first with \`make clean-venv'."; \
else \
set -e; \
echo "Creating venv in $(VENVDIR_PDF)"; \
if $(UV) --version >/dev/null 2>&1; then \
$(UV) venv --python=$(PYTHON) $(VENVDIR_PDF); \
VIRTUAL_ENV=$(VENVDIR_PDF) $(UV) pip install -r requirements-pdf.txt; \
else \
$(PYTHON) -m venv $(VENVDIR_PDF); \
$(VENVDIR_PDF)/bin/python3 -m pip install --upgrade pip; \
$(VENVDIR_PDF)/bin/python3 -m pip install -r requirements-pdf.txt; \
fi; \
echo "The venv has been created in the $(VENVDIR_PDF) directory"; \
fi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is essentially identical to venv, except instead of the REQUIREMENTS variable it hardcodes requirements-pdf.txt.

Can dist-pdf instead invoke venv and set REQUIREMENTS to requirements-pdf.txt?

Copy link
Contributor Author

@m-aciek m-aciek Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, it would be a nice simplification, though after the change two different virtualenvs would share the same location, incorrectly recognising existence of each other.

e.g.
(1) make html -> creates new venv (regular), builds html
(2) then make pdf -> it says venv already exists, therefore we don't rebuild the venv and try to build pdf without extra depenendency

Copy link
Contributor Author

@m-aciek m-aciek Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, actually I can also set VENVDIR, I will try it tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in 9cb3ba4. I kept the venv-pdf target and reverted adding the dependency from dist-pdf to venv-pdf, for consequence with other dist- targets. Though I made venv-pdf reuse existing venv target definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks much better!

I'm wondering if we even need two named venvs.

Right now you can do:

(1) make html -> usual html build
(2) then make htmllive -> will also install the extra sphinx-autobuild dependency

Similarly for (3) make check -> installs pre-commit

Can we follow the same pattern?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching that! Suggested approach is even more minimal. Implemented in 4b90701. I don't think we need to pin the package version as long as PDF build is not included in CPython's CI (otherwise I'd do it, for reproducible builds).

:align: center
:width: 100%

Live mode displays real-time profiling statistics, showing combined
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth this caption is hidden in the PDF build.

Image

:alt: Tachyon live mode with opcode panel
:align: center
:width: 100%
.. only:: not latex
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants