Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

57.4. python3-jinja2-3.1.6

The template engine libplacebo generates its shader sources with

Version 3.1.6, release 1
Shelf python-libs — General-purpose python3-* runtime libraries: text, templating, markup, parsing, config, CLI, system, files, crypto, imaging
Phase 30_foundation (Build Foundation), 54 of 127 in build order
Licence BSD-3-Clause
Homepage https://pypi.org/project/Jinja2/
Build time 0.1 SBU
Installed size 1.3 MiB in 59 files
Recipe ports/core/python-libs/python3-jinja2/kpkgbuild

About

Jinja is a template engine for Python: templates with variables, loops, conditions and inheritance, compiled to Python code, with HTML escaping through python3-markupsafe.

KDOS needs it mostly at build time. libplacebo passes every C file under its src/shaders/, and its renderer.c and shaders.c, through tools/glsl_preproc, a Python preprocessor that renders their GLSL blocks into C from Jinja templates. Its own copy of Jinja, 3rdparty/jinja, is an empty submodule in its release archive, so libplacebo, and through it mpv, needs this port. libcamera, fwupd and libei generate code or manual pages with it as well, and python3-sphinx, python3-flask, qutebrowser and jupyterlab use it at run time.

Why it is in KDOS

The comment above the 3 ports from python3-jinja2 to python3-sphinx in script/phases/30_foundation/packages.txt:

Every file under libplacebo's src/shaders/ is GENERATED from a jinja template at build time, and its vendored copy of jinja is an empty submodule in the release archive.

Sources

Dependencies

Depends on: python3, python3-setuptools, python3-pip, python3-markupsafe.

Required by (14): elogind, fwupd, jupyterlab, libcamera, libei, libplacebo, pandas, python3-flask, python3-glad2, python3-nbconvert, python3-sphinx, qgis, qutebrowser, spyder.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/30_foundation/phase.env && kpkg install python3-jinja2'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/python-libs/python3-jinja2.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/python-libs/python3-jinja2
echo '0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d  python3-jinja2-3.1.6.tar.gz' | sha256sum -c -
echo '4b50686a542345049b24436f5312a970e92313db5d0af1a3445175f5b0b87d06  python3-jinja2-vendor-3.1.6.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/python3-jinja2
SRC=$SRC_ROOT/python3-jinja2-3.1.6
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf python3-jinja2-3.1.6.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

mkdir -p vendor
tar -xf $PORT_SRC/$name-vendor-$version.tar.xz --strip-components=1 -C vendor
pip3 install --ignore-installed --no-deps --no-index --find-links=vendor --root=$PKG --prefix=/usr .

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/python3-jinja2, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf python3-jinja2-3.1.6-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/python3-jinja2, and runs the triggers its paths call for.

Contents

Installed directories: /usr/lib/python3.14/site-packages/jinja2, /usr/lib/python3.14/site-packages/jinja2-3.1.6.dist-info, /usr/share/licenses/python3-jinja2.