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

225.1. python3-cantools-44.1.0

Decode a live candump into named signals, and generate the MCU-side C

Version 44.1.0, release 1
Shelf python-hw — python3-* hardware, serial, USB, instrument, CAN and device-protocol modules
Phase 42_graphics (Graphics Stack), 157 of 189 in build order
Licence MIT AND LGPL-3.0-only AND BSD-2-Clause
Homepage https://github.com/cantools/cantools
Build time 1.4 SBU
Installed size 4.3 MiB in 408 files
Recipe ports/core/python-hw/python3-cantools/kpkgbuild

About

cantools reads CAN bus database files (DBC, KCD, SYM, ARXML, CDD) and uses them to encode and decode CAN frames as named signals. On KDOS it is the step after can-utils: candump prints raw frames, and cantools decode turns that output into signal names and values against a database; cantools generate_c_source writes the C a microcontroller decodes the same frames with, and cantools plot draws signals over time with matplotlib.

Why it is in KDOS

The comment above it in script/phases/42_graphics/packages.d/python-hw.txt:

candump puts raw frames on the screen; cantools turns them into named signals against a DBC and generates the C the MCU side decodes them with.

Sources

Dependencies

Depends on: python3, python3-setuptools, python3-pip, python3-setuptools-scm, can-utils, python3-packaging, python3-typing-extensions, matplotlib.

Required by: no port names it.

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

What kpkg does

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

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-hw/python3-cantools
echo 'ddb1538b8ec9353d791da089ba30e1e46ec95f54a55276bbdd3da096876a0a82  python3-cantools-44.1.0.tar.gz' | sha256sum -c -
echo '4d5d10724e0cd717e88b1615625e45e8e2596775c44db0710046fb186c55e016  python3-cantools-vendor-44.1.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-cantools
SRC=$SRC_ROOT/python3-cantools-44.1.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf python3-cantools-44.1.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 recipe’s helpers pyrequirements 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 \
	. argparse-addons bitstruct crccheck python-can textparser wrapt

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

Contents

Installed programs: can_bridge, can_logconvert, can_logger, can_player, can_viewer, cantools.

Installed directories: /usr/lib/python3.14/site-packages/argparse_addons-0.12.0.dist-info, /usr/lib/python3.14/site-packages/bitstruct, /usr/lib/python3.14/site-packages/bitstruct-8.23.0.dist-info, /usr/lib/python3.14/site-packages/can, /usr/lib/python3.14/site-packages/cantools, /usr/lib/python3.14/site-packages/cantools-44.1.0.dist-info, /usr/lib/python3.14/site-packages/crccheck, /usr/lib/python3.14/site-packages/crccheck-1.3.1.dist-info, /usr/lib/python3.14/site-packages/python_can-4.6.1.dist-info, /usr/lib/python3.14/site-packages/textparser, /usr/lib/python3.14/site-packages/textparser-0.26.2.dist-info, /usr/lib/python3.14/site-packages/wrapt, /usr/lib/python3.14/site-packages/wrapt-1.17.3.dist-info, /usr/share/licenses/python3-cantools.

Notes

The bundle python3-cantools-vendor-<version>.tar.xz holds the source distributions of the modules only cantools uses: argparse-addons, bitstruct, crccheck, python-can (with its own dependency wrapt) and textparser. It also holds the build requirements of those sdists: setuptools, setuptools_scm and vcs_versioning (which setuptools_scm depends on), with packaging and flit_core, the backend packaging builds with. ports/fetch resolves the runtime set from the package’s own metadata (pyrequirements = no: not from a requirements.txt), so the bundle carries typing_extensions as well, a dependency of python-can. Neither packaging nor typing_extensions reaches the package from the bundle: build.sh does not name them, and python-can imports both at run time from their ports in depends. See The three Python keys.

pip3 install names every distribution it installs and passes --no-deps, so the list in build.sh is the whole closure; a module the bundle holds but the list leaves out is not installed. The build is not given --no-build-isolation: pip sets up each sdist’s build requirements in a temporary environment from the bundle alone (--no-index --find-links=vendor), which is why setuptools and setuptools_scm are in it although both are also ports.