Skip to contentSkip to conversation

venv migration for docs, migrate Debian/Ubuntu to it, fix epub and latexpdf targets not finding glob images

PATCH Applied Quentin Schulz 3 participants 8 messages Feb 24 – Mar 2

lore
Share & tools
lore
#0 lore raw

v5 cover venv migration for docs, migrate Debian/Ubuntu to it, fix epub and latexpdf targets not finding glob images

This fixes images being improperly handled by our Make targets by switching to a sphinx extension that generates a PNG or PDF of an SVG upon request by Sphinx itself.

To do that, we need sphinxcontrib-svg2pdfconverter>=2.0.0 which is not available for all supported distros, including Debian/Ubuntu which only used packages from their official package feeds until now. This migrates both distros to use pip packages for building the docs such that the same instructions are used for all supported distros.
This however required to use a virtualenv to install packages, since Debian doesn't allow using pip outside of a virtualenv since Bookworm (12). So this migrates the pip package installation to use a virtualenv as well. Since sourcing scripts in RUN commands to make variables accessible in later container layers is not possible in Containerfile, we do the same logic as in the venv bin/activate script manually in the Containerfile.

Unlike agreed upon during review of v4, I actually decided to NOT do a sed on ./yocto-docs-venv in pip3_docs.sh because we don't actually need to. . ($PWD) currently seems to be resolved to / (the default location for WORKDIR if unmodified by us or our base image (listed in FROM)) so that means the venv will be outside of the /docs mount.

We may want to think about migrating the instructions in Containerfile as being run with a non-root user to better match what the user will be doing. I'm not sure this is straightforward (need to create a user within the container likely with a stable UID/GID and make sure it's mapped correctly to the user outside of the container). Just something I thought when working on this.

This was tested by commenting out /temp/host_packages_docs_pdf.sh in Containerfiles because ain't nobody got time for installing all those packages and then running

for distro in almalinux:8 almalinux:9 centos:stream9 fedora:39 fedora:40 fedora:41 fedora:42 leap:15.5 leap:15.6 rockylinux:8 rockylinux:9 debian:12 debian:13 ubuntu:22.04 ubuntu:24.04 ubuntu:25.04 ubuntu:25.10; do

	echo "============$distro==============="
	git clean -ffdx
	CONTAINERCMD=podman tools/build-docs-container $distro html epub || echo $distro >> ../../fail.log

done

Nothing written to fail.log :)

---
Changes in v5:
- switched to relative path for the venv,
- renamed venv to yocto-docs-venv,
- added patch to switch from sphinx-build to python3 -m sphinx for
better working with venv,
- dropped --system-site-packages from venv as it isn't working due
to sphinxcontrib-svg2pdfconverter v2.0.0 breaking sphinxcontrib
namespace,
- slightly reworded commit logs to explain design choices (specifically
why not using --system-site-packages for the venv),
- Link to v4: https://patch.msgid.link/[email protected]

Changes in v4:
- migrate all distros to use virtualenv for installing packages via pip,
- migrate Debian and Ubuntu to use pip installation steps for building
the docs,
- tested all distros build correctly by running the html epub make
targets (all doesn't work for almalinux, rockylinux and centos
stream at the moment),
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- rebased on top of master, rebuilt with make all no build error to be
seen,
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- switched to upstream sphinxcontrib-svg2pdfconverter since the
necessary MR got merged and a new release made,
- removed IMAGEDIRS Make variable as it is now unused,
- added sphinxcontrib-svg2pdfconverter to Pipfile (not tested) and pip installation script,
- Link to v1: https://patch.msgid.link/[email protected]

---
Quentin Schulz (4):
Makefile: use python3 -m sphinx instead of sphinx-build use a venv for installing packages with pip
consistently use pip packages for all distros
convert SVGs to PDF and PNG using sphinxcontrib.rsvgconverter plugin

 documentation/Makefile                             | 33 ++++------------------
 documentation/Pipfile                              |  2 ++
 documentation/conf.py                              |  1 +
 documentation/ref-manual/system-requirements.rst   |  3 ++
 documentation/tools/build-docs-container           |  4 ++-
 .../tools/containerfiles/Containerfile.apt         | 14 +++++++++
 .../tools/containerfiles/Containerfile.dnf         | 11 ++++++++
 .../tools/containerfiles/Containerfile.zypper      | 11 ++++++++
 .../tools/host_packages_scripts/pip3_docs.sh       |  4 ++-
 .../tools/host_packages_scripts/ubuntu_docs.sh     |  2 +-
 10 files changed, 55 insertions(+), 30 deletions(-)

---
base-commit: b70b4599a18ab6261f0c51f51c09f7f1c1bca093
change-id: 20251029-fix-make-multi-target-d2de9d4ff7ec

Best regards,

Signature · 1 line
Quentin Schulz <[email protected]>
#1 lore raw

PATCH v5 1/4 Makefile: use python3 -m sphinx instead of sphinx-build

From: Quentin Schulz <[email protected]>

sphinx-build is a "script"[1][2] which is then made available on the system as a binary, upon installing the sphinx package.

You can have multiple instances of sphinx installed, e.g. system-wide via the traditional distro package manager or in a venv. In the case of a venv, if you have sphinx already installed in your host system, source the venv activate script and then install sphinx via pip inside the venv, sphinx-build command will still point at the sphinx from the host system. The work-around is either to run the venv activate script again, run hash -r or rehash in your current shell, or call python3 -m sphinx instead of the Python script.

Let's do the latter as it's the easiest/least-user-facing solution.

This works because python3 interpreter will be the one from the venv, and it sets the appropriate paths for loading modules (use only packages from the venv by default, or prefer them if --system-site-packages is passed).

[1] https://github.com/sphinx-doc/sphinx/blob/v9.1.0/pyproject.toml#L99
[2] https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#creating-executable-scripts

---
 documentation/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
documentation/Makefile +3 -3
index e144a50b4..5d9fda501 100644
@@ -4,7 +4,7 @@
 # You can set these variables from the command line, and also
 # from the environment for the first two.
 SPHINXOPTS     ?= -W --keep-going -j auto
-SPHINXBUILD    ?= sphinx-build
+SPHINXBUILD    ?= python3 -m sphinx
 # Release notes are excluded because they contain contributor names and commit messages which can't be modified
 VALEOPTS       ?= --no-wrap --glob '!migration-guides/release-notes-*.rst'
 SOURCEDIR      = .
@@ -16,8 +16,8 @@ DESTDIR        = final
 SVG2PNG        = rsvg-convert
 SVG2PDF        = rsvg-convert
 
-ifeq ($(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi),0)
-$(error "The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed")
+ifeq ($(shell if $(SPHINXBUILD) --version >/dev/null 2>&1; then echo 1; else echo 0; fi),0)
+$(error "Sphinx was not found. Make sure you have it installed")
 endif
 
 # Put it first so that "make" without argument is like "make help".
Signature · 1 line
2.53.0
#2 lore raw

PATCH v5 2/4 use a venv for installing packages with pip

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

In a few commits, we'll migrate Debian/Ubuntu to use pip packages. However, Debian rejects pip commands outside of virtual environments.

It is generally best practice to use virtual environments with pip, so let's migrate distros that currently use pip to use virtual environments as well.

Because BitBake is a Python project and requires a few Python packages that we currently install with distro package managers, it would be best to also include system packages via --system-site-packages when creating the virtual environment such that the user would either be able to build the docs or run BitBake, from the same venv.

Unfortunately, one of the packages[1] we'll include in an upcoming commit breaks sphinxcontrib namespace package and thus we cannot have a mix of sphinxcontrib-namespaced packages in and outside the venv. Let's create a completely empty venv for now until the offending package is fixed (see pending merge request[2]).

Let's instruct the user to install the docs venv in a relative directory (likely the root of the yocto-docs git repo) instead of guessing a safe location (/tmp may or may not be an actual volatile directory depending on the distro).

[1] https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter/
[2] https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter/pull/34

---
 documentation/tools/containerfiles/Containerfile.dnf    | 11 +++++++++++
 documentation/tools/containerfiles/Containerfile.zypper | 11 +++++++++++
 documentation/tools/host_packages_scripts/pip3_docs.sh  |  4 +++-
 3 files changed, 25 insertions(+), 1 deletion(-)
documentation/tools/containerfiles/Containerfile.dnf +11 -0
index fd47fde34..12d97ef6c 100644
@@ -1,6 +1,17 @@
 ARG ARG_FROM=fedora:40 # default value to avoid warning
 FROM $ARG_FROM
 
+# RUN . ./yocto-docs-venv/bin/activate doesn't work because env variables set
+# in RUN don't persist, so set up the virtualenv manually ahead of time.
+# Unsetting env variables in Containerfile is difficult, so we hope it works
+# fine without doing that for PYTHONHOME (see activate script content).
+# Note that the actual location depends on WORKDIR at this layer in the
+# container, and it must match the pwd when pip3_docs.sh is run in a later
+# layer. This *must* be outside of any mount point otherwise it won't be
+# available within the container.
+ENV VIRTUAL_ENV=$PWD/yocto-docs-venv
+ENV PATH="$VIRTUAL_ENV/bin:$PATH"
+
 ARG INCLUDE_ESSENTIAL_PACKAGES=0
 ARG ESSENTIAL=fedora_essential.sh
 ARG DOCS=fedora_docs.sh
documentation/tools/containerfiles/Containerfile.zypper +11 -0
index 3850b9ff9..6e667967c 100644
@@ -1,6 +1,17 @@
 ARG ARG_FROM=opensuse/leap:15.4 # default value to avoid warning
 FROM $ARG_FROM
 
+# RUN . ./yocto-docs-venv/bin/activate doesn't work because env variables set
+# in RUN don't persist, so set up the virtualenv manually ahead of time.
+# Unsetting env variables in Containerfile is difficult, so we hope it works
+# fine without doing that for PYTHONHOME (see activate script content).
+# Note that the actual location depends on WORKDIR at this layer in the
+# container, and it must match the pwd when pip3_docs.sh is run in a later
+# layer. This *must* be outside of any mount point otherwise it won't be
+# available within the container.
+ENV VIRTUAL_ENV=$PWD/yocto-docs-venv
+ENV PATH="$VIRTUAL_ENV/bin:$PATH"
+
 ARG INCLUDE_ESSENTIAL_PACKAGES=0
 ARG ESSENTIAL=opensuse_essential.sh
 ARG DOCS=opensuse_docs.sh
documentation/tools/host_packages_scripts/pip3_docs.sh +3 -1
index 907ecec55..b7f19b7ad 100644
@@ -1 +1,3 @@
-sudo pip3 install sphinx sphinx_rtd_theme pyyaml sphinx-copybutton
+python3 -m venv --clear ./yocto-docs-venv
+. ./yocto-docs-venv/bin/activate
+python3 -m pip install sphinx sphinx_rtd_theme pyyaml sphinx-copybutton
Signature · 1 line
2.53.0
#3 lore raw

Re: [docs] [PATCH v5 2/4] use a venv for installing packages with pip

On Tue Feb 24, 2026 at 5:32 PM CET, Quentin Schulz via lists.yoctoproject.org wrote:
[...]

Quoted 7 lines
documentation/tools/containerfiles/Containerfile.dnf +0 -0
index fd47fde34..12d97ef6c 100644
@@ -1,6 +1,17 @@
 ARG ARG_FROM=fedora:40 # default value to avoid warning
 FROM $ARG_FROM

documentation/tools/containerfiles/Containerfile.dnf line 12

Quoted 10 lines
documentation/tools/containerfiles/Containerfile.dnf +9 -0
 
+# RUN . ./yocto-docs-venv/bin/activate doesn't work because env variables set
+# in RUN don't persist, so set up the virtualenv manually ahead of time.
+# Unsetting env variables in Containerfile is difficult, so we hope it works
+# fine without doing that for PYTHONHOME (see activate script content).
+# Note that the actual location depends on WORKDIR at this layer in the
+# container, and it must match the pwd when pip3_docs.sh is run in a later
+# layer. This *must* be outside of any mount point otherwise it won't be
+# available within the container.
+ENV VIRTUAL_ENV=$PWD/yocto-docs-venv

This produces a warning with docker:

1 warning found (use docker --debug to expand):
- UndefinedVar: Usage of undefined variable '$PWD' (line 12)

Can be solved by adding:

ARG PWD

above

ENV VIRTUAL_ENV=$PWD/yocto-docs-venv

Are you fine with that? I can add the bit manually if so

Antonin

#4 lore raw

Re: [docs] [PATCH v5 2/4] use a venv for installing packages with pip

Hi Antonin,

Quoted 22 lines · Antonin Godard

On Tue Feb 24, 2026 at 5:32 PM CET, Quentin Schulz via lists.yoctoproject.org wrote:
[...]

Quoted 7 lines
documentation/tools/containerfiles/Containerfile.dnf +0 -0
index fd47fde34..12d97ef6c 100644
@@ -1,6 +1,17 @@
  ARG ARG_FROM=fedora:40 # default value to avoid warning
  FROM $ARG_FROM

documentation/tools/containerfiles/Containerfile.dnf line 12

Quoted 10 lines
documentation/tools/containerfiles/Containerfile.dnf +9 -0
 
+# RUN . ./yocto-docs-venv/bin/activate doesn't work because env variables set
+# in RUN don't persist, so set up the virtualenv manually ahead of time.
+# Unsetting env variables in Containerfile is difficult, so we hope it works
+# fine without doing that for PYTHONHOME (see activate script content).
+# Note that the actual location depends on WORKDIR at this layer in the
+# container, and it must match the pwd when pip3_docs.sh is run in a later
+# layer. This *must* be outside of any mount point otherwise it won't be
+# available within the container.
+ENV VIRTUAL_ENV=$PWD/yocto-docs-venv

This produces a warning with docker:

Quoted 3 lines

1 warning found (use docker --debug to expand):
- UndefinedVar: Usage of undefined variable '$PWD' (line 12)

Ugh.

Quoted 9 lines

Can be solved by adding:

ARG PWD

Quoted 1 line

above

ENV VIRTUAL_ENV=$PWD/yocto-docs-venv

Are you fine with that? I can add the bit manually if so

Nah, that doesn't seem right. PWD is a special shell variable, we shouldn't allow the user to override it via a build-arg.

But that does explain why it's been resolved to / (or rather, the empty string and then have /yocto-docs-venv in the env).

I would suggest to set

WORKDIR /
ENV VIRTUAL_ENV=/yocto-docs-venv

instead, plus some comment in the Containerfile explaining the restrictions. I'm in meetings til tomorrow and my brain cannot come up with a comment right now.

Cheers,
Quentin

#5 lore raw

PATCH v5 3/4 consistently use pip packages for all distros

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

Until now, Debian and Ubuntu had special instructions for installing Python packages to build the docs. Specifically, the packages that all other distros are installing via pip were installed from the package feed (apt).

In the next commit, a new Python module will be required, which isn't available in the package feed. We thus have two options, have a pip3 Debian/Ubuntu-specific set of instructions to install this one package, or migrate packages currently installed through the package manager to use pip like other distros. To lower maintenance burden and the possibility of missing to update both "generic" and "Debian/Ubuntu" variants of pip instructions, the latter was chosen.

---
 documentation/ref-manual/system-requirements.rst         |  3 +++
 documentation/tools/build-docs-container                 |  4 +++-
 documentation/tools/containerfiles/Containerfile.apt     | 14 ++++++++++++++
 documentation/tools/host_packages_scripts/ubuntu_docs.sh |  2 +-
 4 files changed, 21 insertions(+), 2 deletions(-)
documentation/ref-manual/system-requirements.rst +3 -0
index f9f32f2a8..e7c1c3916 100644
@@ -171,6 +171,9 @@ Here are the packages needed to build Project documentation manuals:
 .. literalinclude:: ../tools/host_packages_scripts/ubuntu_docs.sh
    :language: shell
 
+.. literalinclude:: ../tools/host_packages_scripts/pip3_docs.sh
+   :language: shell
+
 In addition to the previous packages, here are the packages needed to build the
 documentation in PDF format:
 
documentation/tools/build-docs-container +3 -1
index 23c3dfe33..f2f54044c 100755
@@ -115,6 +115,7 @@ main ()
       essential=ubuntu_essential.sh
       docs=ubuntu_docs.sh
       docs_pdf=ubuntu_docs_pdf.sh
+      pip3=pip3_docs.sh
       ;;
     "fedora:39"*|\
     "fedora:40"*|\
@@ -151,6 +152,7 @@ main ()
       essential=ubuntu_essential.sh
       docs=ubuntu_docs.sh
       docs_pdf=ubuntu_docs_pdf.sh
+      pip3=pip3_docs.sh
       ;;
     *)
       echo "$image not supported!"
@@ -166,7 +168,7 @@ main ()
     --build-arg ESSENTIAL="host_packages_scripts/$essential" \
     --build-arg DOCS="host_packages_scripts/$docs" \
     --build-arg DOCS_PDF="host_packages_scripts/$docs_pdf" \
-    --build-arg PIP3="host_packages_scripts/${pip3:-}" \
+    --build-arg PIP3="host_packages_scripts/$pip3" \
     --file "$SCRIPT_DIR/containerfiles/$containerfile" \
     "$SCRIPT_DIR"
 
documentation/tools/containerfiles/Containerfile.apt +14 -0
index a573786f0..7ee168be1 100644
@@ -1,10 +1,22 @@
 ARG ARG_FROM=debian:12 # default value to avoid warning
 FROM $ARG_FROM
 
+# RUN . ./yocto-docs-venv/bin/activate doesn't work because env variables set
+# in RUN don't persist, so set up the virtualenv manually ahead of time.
+# Unsetting env variables in Containerfile is difficult, so we hope it works
+# fine without doing that for PYTHONHOME (see activate script content).
+# Note that the actual location depends on WORKDIR at this layer in the
+# container, and it must match the pwd when pip3_docs.sh is run in a later
+# layer. This *must* be outside of any mount point otherwise it won't be
+# available within the container.
+ENV VIRTUAL_ENV=$PWD/yocto-docs-venv
+ENV PATH="$VIRTUAL_ENV/bin:$PATH"
+
 ARG INCLUDE_ESSENTIAL_PACKAGES=0
 ARG ESSENTIAL=ubuntu_essential.sh
 ARG DOCS=ubuntu_docs.sh
 ARG DOCS_PDF=ubuntu_docs_pdf.sh
+ARG PIP3=pip3_docs.sh
 
 ENV DEBIAN_FRONTEND=noninteractive
 ARG TZ=Europe/Vienna
@@ -13,6 +25,7 @@ ARG TZ=Europe/Vienna
 COPY --chmod=777 ${ESSENTIAL} /temp/host_packages_essential.sh
 COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh
 COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh
+COPY --chmod=777 ${PIP3} /temp/pip3_docs.sh
 
 RUN ln -fs "/usr/share/zoneinfo/$TZ" /etc/localtime \
  && apt-get update \
@@ -20,6 +33,7 @@ RUN ln -fs "/usr/share/zoneinfo/$TZ" /etc/localtime \
  && if [ "$INCLUDE_ESSENTIAL_PACKAGES" = "1" ]; then yes | /temp/host_packages_essential.sh; fi \
  && yes | /temp/host_packages_docs.sh \
  && yes | /temp/host_packages_docs_pdf.sh \
+ && yes | /temp/pip3_docs.sh \
  && apt-get --yes autoremove \
  && apt-get clean \
  && rm -rf /temp
documentation/tools/host_packages_scripts/ubuntu_docs.sh +1 -1
index c322b61e4..db0743021 100644
@@ -1 +1 @@
-sudo apt install git librsvg2-bin locales make python3-saneyaml python3-sphinx-rtd-theme python3-sphinx-copybutton sphinx
+sudo apt install git librsvg2-bin locales make python3-saneyaml python3-pip python3-venv
Signature · 1 line
2.53.0
#6 lore raw

PATCH v5 4/4 convert SVGs to PDF and PNG using sphinxcontrib.rsvgconverter plugin

In reply to Quentin Schulz

From: Quentin Schulz <[email protected]>

The sphinxcontrib.rsvgconverter plugin allows to generate a PDF or PNG from an SVG.
This is what we already do manually via Make targets but it isn't good enough.

Sphinx generates a cache upon first parsing and stores it in a doctrees directory. Sphinx claims that it can be shared between all builders[1]. For glob patterns in image or figure directives, Sphinx will look for all possible matches in the source tree and store those in a "candidates" map for each file, along with the associated mimetype. When building, Sphinx will then look in this map to try to find a match in the current builder's supported_image_types. If none is found, the build will fail.

The latexpdf (using the LaTeXBuilder) target does not support SVGs by default[2]. We used Make to generate PDFs from them before generating the doc PDF though (see PDFs variable and %.pdf in Makefile) and that type is supported by default[2].

The epub (via the Epub3Builder) target does support SVGs by default[3] but we disabled their support in commit ff3876ca4910 ("conf.py: use PNG first in EPUB output"). We used Make to generate PNGs from them before generating the doc epub though (see PNGs variable and %.png in Makefile) and that type is supported (c.f. Epub3Builder.supported_image_types in our conf.py).

The issue is that this is done transparently from Sphinx. When we generate the PDFs or PNGs variants of the SVGs, we put them in-tree directly along their source file. Then, when caching, Sphinx will find both the source file and the appropriate variant. However, the cache isn't updated if there are new files in the tree and the source rST files aren't modified. So, the cache will not have its map updated and we won't be able to find the new variant when building for a non-SVG-compatible builder. Take the following scenario:

- start from a clean source file (fresh clone or git clean -ffdx)
- build the html target (which supports SVGs by default[4])
- sphinx will find all the files in the source tree matching the glob pattern in ".. image:: test.*", in our case only an SVG since the PDFs and PNGs are only generated for the latexpdf and epub targets respectively. The cache will only store the path to the SVG file because it is the only source file that matches the glob,
- attempt to build the epub target (which doesn't support SVGs, only PNGs)
- Sphinx checks for the file to include for '.. image:: test.*' and finds an SVG in the cache map and then check the list of supported image types for the Epub3Builder and find that it doesn't support that. It cannot find anything satisfying the dependency and thus fails to build.

This scenario can easily be reproduced by running the make all command since the html builder will be used first, then epub and finally latexpdf.

The make publish target works by chance, because the epub builder is built first and will cache SVG + PNG for each glob, then the latexpdf builder is built and supports PNGs so that's fine and then html, which supports SVG as well.

To fix this issue, we could simply always generate PDFs and PNGs of all SVGs in the source tree, but this isn't ideal.

Instead, let's use an ImageConverter from a Sphinx plugin. This allows to map a plugin as being able to generate a file of type Y from a file of type X. When Sphinx wants to build an image, it'll try to find the image with the type the current builder supports in the cache. If it cannot, it's going to try to find an ImageConverter plugin that is able to convert one of the image types in cache with one of the image types the current builder supports. Then Sphinx will call this plugin to generate the file and put it into the build directory (not in the source!).

This allows to simplify the Makefile as well and is a much cleaner approach.

The epub target is removed as the catch-all target contains the same instructions as the epub target we remove in this commit.

sphinxcontrib.rsvgconverter is a plugin from sphinxcontrib-svg2pdfconverter python module. SVGs to PNGs is only supported since 2.0.0.

[1] https://www.sphinx-doc.org/en/master/man/sphinx-build.html#cmdoption-sphinx-build-d
[2] https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.latex.LaTeXBuilder.supported_image_types
[3] https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.epub3.Epub3Builder.supported_image_types
[4] https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.html.StandaloneHTMLBuilder

---
 documentation/Makefile                             | 27 +++-------------------
 documentation/Pipfile                              |  2 ++
 documentation/conf.py                              |  1 +
 .../tools/host_packages_scripts/pip3_docs.sh       |  2 +-
 4 files changed, 7 insertions(+), 25 deletions(-)
documentation/Makefile +3 -24
index 5d9fda501..76be4f068 100644
@@ -10,11 +10,8 @@ VALEOPTS       ?= --no-wrap --glob '!migration-guides/release-notes-*.rst'
 SOURCEDIR      = .
 VALEDOCS       ?= $(SOURCEDIR)
 SPHINXLINTDOCS ?= $(SOURCEDIR)
-IMAGEDIRS      = */svg
 BUILDDIR       = _build
 DESTDIR        = final
-SVG2PNG        = rsvg-convert
-SVG2PDF        = rsvg-convert
 
 ifeq ($(shell if $(SPHINXBUILD) --version >/dev/null 2>&1; then echo 1; else echo 0; fi),0)
 $(error "Sphinx was not found. Make sure you have it installed")
@@ -24,7 +21,7 @@ endif
 help:
 	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
 
-.PHONY: all checks help Makefile clean stylecheck publish epub latexpdf
+.PHONY: all checks help Makefile clean stylecheck publish latexpdf
 
 publish: Makefile checks epub latexpdf html singlehtml
 	rm -rf $(BUILDDIR)/$(DESTDIR)/
@@ -35,22 +32,8 @@ publish: Makefile checks epub latexpdf html singlehtml
 	cp $(BUILDDIR)/singlehtml/index.html $(BUILDDIR)/$(DESTDIR)/singleindex.html
 	sed -i -e '[email protected]#@singleindex.html#@g' $(BUILDDIR)/$(DESTDIR)/singleindex.html
 
-# Build a list of SVG files to convert to PDFs
-PDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
-
-# Build a list of SVG files to convert to PNGs
-PNGs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.png,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))
-
-# Pattern rule for converting SVG to PDF
-%.pdf : %.svg
-	$(SVG2PDF) --format=pdf --output=$@ $<
-
-# Pattern rule for converting SVG to PNG
-%.png : %.svg
-	$(SVG2PNG) --format=png --output=$@ $<
-
 clean:
-	@rm -rf $(BUILDDIR) $(PNGs) $(PDFs) poky.yaml sphinx-static/switchers.js releases.rst
+	@rm -rf $(BUILDDIR) poky.yaml sphinx-static/switchers.js releases.rst
 
 checks:
 	$(SOURCEDIR)/tools/check-glossaries --docs-dir $(SOURCEDIR)
@@ -62,14 +45,10 @@ stylecheck:
 sphinx-lint:
 	sphinx-lint $(SPHINXLINTDOCS)
 
-epub: $(PNGs)
-	$(SOURCEDIR)/set_versions.py
-	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
-
 # Note: we need to pass buf_size here (which is also configurable from
 # texmf.cnf), to avoid following error:
 #   Unable to read an entire line---bufsize=200000. Please increase buf_size in texmf.cnf.
-latexpdf: $(PDFs)
+latexpdf:
 	$(SOURCEDIR)/set_versions.py
 	buf_size=10000000 $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
 
documentation/Pipfile +2 -0
index 1fa2df31e..67fce078d 100644
@@ -10,6 +10,8 @@ sphinx = "*"
 sphinx-rtd-theme = "*"
 pyyaml = "*"
 sphinx-copybutton = "*"
+# SVG to PNG only supported since 2.0.0
+sphinxcontrib-svg2pdfconverter = ">=2.0.0"
 
 [requires]
 python_version = "3"
documentation/conf.py +1 -0
index 3d04f9057..5a69977cf 100644
@@ -67,6 +67,7 @@ extensions = [
     'sphinx.ext.extlinks',
     'sphinx.ext.intersphinx',
     'sphinx_copybutton',
+    'sphinxcontrib.rsvgconverter',
     'yocto-vars'
 ]
 autosectionlabel_prefix_document = True
documentation/tools/host_packages_scripts/pip3_docs.sh +1 -1
index b7f19b7ad..852845783 100644
@@ -1,3 +1,3 @@
 python3 -m venv --clear ./yocto-docs-venv
 . ./yocto-docs-venv/bin/activate
-python3 -m pip install sphinx sphinx_rtd_theme pyyaml sphinx-copybutton
+python3 -m pip install sphinx sphinx_rtd_theme pyyaml sphinx-copybutton 'sphinxcontrib-svg2pdfconverter>=2.0.0'
Signature · 1 line
2.53.0
#7 lore raw
In reply to Quentin Schulz

Applied, thanks!

[1/4] Makefile: use python3 -m sphinx instead of sphinx-build

      commit: 8354f3b5b91828db8ef9b7f6bdc120a95df893af
[2/4] use a venv for installing packages with pip
      commit: 16599c4f65d451c47104e7604b68a0658d25ac48
[3/4] consistently use pip packages for all distros
      commit: 4fbae014790373ec2c662325e54cf7f07f507dbc
[4/4] convert SVGs to PDF and PNG using sphinxcontrib.rsvgconverter plugin
      commit: ba351b35480d9c06c870a6f34d8bdbc1856b9511