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

57.5. python3-yaml-6.0.3

Python bindings for YAML, using libyaml

Version 6.0.3, 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), 58 of 127 in build order
Licence MIT
Homepage https://pyyaml.org/
Build time 3.0 SBU
Installed size 751.2 KiB in 45 files
Recipe ports/core/python-libs/python3-yaml/kpkgbuild

About

PyYAML reads and writes YAML from Python. Built against the C library libyaml, the yaml port, it adds the yaml._yaml extension, whose CLoader and CDumper are much faster than the pure-Python parser and emitter.

Many build systems read YAML through it: mesa and libcamera depend on it, and freecad, gnuradio, astropy, picard, qutebrowser and python3-sphinx 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, yaml, python3-pip.

Required by (18): astropy, crawl-tiles, freecad, gnuradio, jupyterlab, libcamera, lirc, mesa, mesa-opencl, picard, python3-esptool, python3-meshtastic, python3-owslib, python3-sphinx, qgis, qutebrowser, spyder, visidata.

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-yaml'

What kpkg does

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

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-yaml
echo 'd76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f  python3-yaml-6.0.3.tar.gz' | sha256sum -c -
echo '2b7d6178f3d6adc734923debe28f105cbd488d66df552791816d7dd1e728805d  python3-yaml-vendor-6.0.3.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-yaml
SRC=$SRC_ROOT/python3-yaml-6.0.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf python3-yaml-6.0.3.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
export PYYAML_FORCE_LIBYAML=1
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-yaml, 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-yaml-6.0.3-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-yaml, and runs the triggers its paths call for.

Contents

Installed directories: /usr/lib/python3.14/site-packages/_yaml, /usr/lib/python3.14/site-packages/pyyaml-6.0.3.dist-info, /usr/lib/python3.14/site-packages/yaml, /usr/share/licenses/python3-yaml.

Notes

The source distribution ships the extension only as Cython source, yaml/_yaml.pyx, with no generated _yaml.c, so the extension cannot be built without Cython. The tree’s Cython port, python3-cython, is built in 40_lang, after this one, which is why Cython comes from the vendor bundle rather than from depends.