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

57.1. python3-pygments-2.21.0

Python syntax highlighter

Version 2.21.0, 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), 51 of 127 in build order
Licence BSD-2-Clause
Homepage https://pygments.org/
Build time 0.5 SBU
Installed size 8.6 MiB in 697 files
Recipe ports/core/python-libs/python3-pygments/kpkgbuild

About

Pygments is a syntax highlighter written in Python: it splits source code in several hundred languages into tokens and writes them out as HTML, LaTeX, RTF, SVG, images or terminal escape sequences. It installs the pygmentize command beside the module.

KDOS uses it through other programs. python3-docutils and python3-sphinx highlight code blocks with it, python3-rich and ipython colour code in a terminal, and gdb, cppcheck, qutebrowser and jupyterlab name it in their depends too.

Sources

Dependencies

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

Required by (17): calibre, cppcheck, gdb, gtk-doc, ipython, jupyterlab, ocrmypdf, python3-docutils, python3-esptool, python3-jupyterlab-pygments, python3-kivy, python3-nbconvert, python3-rich, 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-pygments'

What kpkg does

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

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-pygments
echo '610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c  python3-pygments-2.21.0.tar.gz' | sha256sum -c -
echo 'edbe9cf8c7504105bf059ab1407e948eac21f7afcc3564353ef0ca9702e370a0  python3-pygments-vendor-2.21.0.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-pygments
SRC=$SRC_ROOT/python3-pygments-2.21.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf python3-pygments-2.21.0.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 .
install -Dm644 doc/pygmentize.1 -t "$PKG/usr/share/man/man1"

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-pygments, 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-pygments-2.21.0-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-pygments, and runs the triggers its paths call for.

Contents

Installed programs: pygmentize.

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

Short descriptions

pygmentize highlights the input file

Notes

pip installs no manual pages. Pygments ships a finished doc/pygmentize.1, so build.sh installs it by hand, as the tree’s rule on manual pages asks of a project whose installer skips them.