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

224.1. python3-kivy-2.3.1

Python UI framework drawing with OpenGL through SDL2

Version 2.3.1, release 2
Shelf python-gui — python3-* GUI toolkit, desktop and D-Bus bindings
Phase 42_graphics (Graphics Stack), 124 of 189 in build order
Licence MIT
Homepage https://kivy.org/
Build time 1.8 SBU
Installed size 17.9 MiB in 914 files
Recipe ports/core/python-gui/python3-kivy/kpkgbuild

About

Kivy is a Python framework for touch-friendly graphical applications. It draws everything itself with OpenGL and gets its window, input, images, sound and fonts from SDL2, which on KDOS is sdl2-compat over SDL 3, so a Kivy program runs as a Wayland client of the compositor. It is an application toolkit; nothing in the desktop links it.

Sources

Dependencies

Depends on: python3, python3-setuptools, python3-pip, python3-wheel, python3-packaging, python3-cython, pkgconf, sdl2-compat, sdl2-image, sdl2-mixer, sdl2-ttf, mesa, libglvnd, python3-docutils, python3-pygments, python3-requests, python3-pillow.

Required by (1): sideband.

Patches

build.sh applies these; kpkg applies nothing by itself.

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/42_graphics/phase.env && kpkg install python3-kivy'

What kpkg does

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

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-gui/python3-kivy
echo '0833949e3502cdb4abcf9c1da4384674045ad7d85644313aa1ee7573f3b4f9d9  python3-kivy-2.3.1.tar.gz' | sha256sum -c -
echo 'ef78c2984a2c109b7a05749de74516bc50e359ab90b05e5a5411dffbefdcd797  python3-kivy-vendor-2.3.1.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-kivy
SRC=$SRC_ROOT/python3-kivy-2.3.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf python3-kivy-2.3.1.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 recipe’s helpers pyrequirements and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

patch -p1 -i "$PORT_SRC/python314-ast-str.patch"

patch -p1 -i "$PORT_SRC/cython-long.patch"
patch -p1 -i "$PORT_SRC/cython-dict-keys.patch"
patch -p1 -i "$PORT_SRC/cutbuffer-needs-program.patch"
patch -p1 -i "$PORT_SRC/dbusklipper-copy-bytes.patch"

export USE_SDL2=1 USE_X11=0 USE_WAYLAND=0 USE_EGL=0 USE_GSTREAMER=0 \
	USE_PANGOFT2=0 USE_MESAGL=0 USE_OPENGL_ES2=0

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 --no-build-isolation \
	--root=$PKG --prefix=/usr \
	filetype .

rm -rf "$PKG/usr/share/kivy-examples"

The switches, and why each is set:

Kivy’s setup.py reads its build options from the environment: each USE_<NAME> variable it finds overrides the matching entry of its c_options table. Left unset, SDL2, Pango and GStreamer are decided by what pkg-config finds in the build root, OpenGL ES 2 by the KIVY_GRAPHICS variable, and X11, Wayland, EGL and MesaGL default to off. build.sh sets all eight, so which compiled providers the package carries does not depend on what happens to be installed in the build root.

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-kivy, 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-kivy-2.3.1-2.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-kivy, and runs the triggers its paths call for.

Contents

Installed programs: filetype.

Installed directories: /usr/lib/python3.14/site-packages/filetype, /usr/lib/python3.14/site-packages/filetype-1.2.0.dist-info, /usr/lib/python3.14/site-packages/kivy, /usr/lib/python3.14/site-packages/kivy-2.3.1.dist-info, /usr/share/licenses/python3-kivy.

Notes

On Linux the clipboard is the first provider that loads of xclip, xsel, dbusklipper and gtk3, then SDL’s. On a Plasma session that is dbusklipper, which copies and pastes through Klipper’s org.kde.klipper D-Bus interface, so a Kivy program shares the desktop’s clipboard. There is no cut buffer: middle-click pasting of a selection inside a Kivy program is X11-only.

Two more patches, each described by its own Subject: line, keep the clipboard working:

The one module Kivy needs that is not a port, filetype, comes from the vendor bundle that ports/fetch makes from pypackages = filetype; pip3 install --no-index installs it and Kivy from vendor/ alone. See The three Python keys.

build.sh deletes /usr/share/kivy-examples, the example programs Kivy’s setup.py installs as data files.