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
python3-kivy-2.3.1.tar.gz(22.9 MiB)
sha2560833949e3502cdb4abcf9c1da4384674045ad7d85644313aa1ee7573f3b4f9d9
upstream: https://files.pythonhosted.org/packages/source/k/kivy/Kivy-2.3.1.tar.gz
archive copy: sources-4/python-gui--python3-kivy-2.3.1.tar.gzpython3-kivy-vendor-2.3.1.tar.xz(6.0 MiB)
sha256ef78c2984a2c109b7a05749de74516bc50e359ab90b05e5a5411dffbefdcd797
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-4/python-gui--python3-kivy-vendor-2.3.1.tar.xz
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.
cutbuffer-needs-program.patch— Probe the X11 cut buffer only through an xclip or xsel that is installedcython-dict-keys.patch— InRenderContext.apply()ininstructions.pyx, removes the Python 2 branch, which assigned a dictionary’skeys()to a variable declaredcdef list, and keeps the line that wraps them inlist().cython-long.patch— Removes the uses oflong, Python 2’s integer type:hsv_to_rgb()incontext_instructions.pyxcasts with<long>instead of callinglong(), the twoisinstance(…, (long, int))tests inopengl.pyxtestintalone, and the__long__method ofweakproxy.pyxgoes.dbusklipper-copy-bytes.patch— Decode the bytes the Klipper clipboard provider is given to copypython314-ast-str.patch— Inkivy/lang/parser.py, drops the branch that tests forast.Str, which Python 3.14 does not have, and reads every value of an f-string or boolean expression through.value. Without it, parsing any.kvrule that contains an f-string or anand/orraisesAttributeError.
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.
USE_SDL2=1— Build the SDL2 window, image, audio, text and clipboard providers, the only compiled providers this port builds.USE_X11=0— Skip the native X11 window provider, which would linklibX11andlibXrenderdirectly. Windows are SDL’s.USE_WAYLAND=0— Compile out the Wayland handles thatWindow.get_window_info()returns for a Wayland window (wl_display,wl_surface,wl_shell_surface). The window still runs on Wayland through SDL; only that query goes, which also keeps the build off the Wayland headers.USE_EGL=0— Leave EGL off. The switch makes the X11 window provider use EGL instead of GLX, and that provider is not built.USE_GSTREAMER=0— Skip the GStreamer audio and video player. gstreamer is a port but not independs; sound goes through SDL’s mixer.USE_PANGOFT2=0— Skip the Pango text provider. pango is a port but not independs; text is rendered through SDL2_ttf.USE_MESAGL=0— Leave off the header redirection Kivy uses for headless test builds, which stubsglBlendEquationSeparateand maps the GLES depth calls onto desktop GL ones.USE_OPENGL_ES2=0— Compile against desktop OpenGL and linklibGL, from libglvnd, rather than OpenGL ES 2.--no-build-isolation— Build with the Cython, setuptools and wheel already in the build root. Kivy’spyproject.tomlcaps Cython at 3.0.11, older than the release the tree carries, and pins setuptools, wheel and packaging; the C that the capped Cython generates does not follow the C API of the tree’s Python. Under this flag pip does not install or enforce those pins, so the python3-cython port compiles Kivy, and the two Cython patches below are what that newer Cython needs. The pinned Cython, setuptools, wheel and packaging in the vendor bundle, and theflit_corethat builds packaging, are there only becauseports/fetchcollects every declared build requirement;pip3 installnames onlyfiletypeand Kivy, so none of them is installed.
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:
dbusklipper-copy-bytes.patchdecodes the UTF-8 bytesClipboardBase._copypasses to the Klipper provider’sput()before handing them to Klipper’ssetClipboardContents, which takes a string. Without it every copy on a Plasma session raisesTypeError: a bytes-like object is required, not 'str'.cutbuffer-needs-program.patchkeeps only the cut-buffer providers whose program,xcliporxsel, is onPATH, and probes none when neither is. Kivy reaches X11’s primary selection only by running one of them, and neither is a port; without the patch every Kivy program logs a[CRITICAL] [Cutbuffer]line and twoFileNotFoundErrortracebacks at start.
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.