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

75.4. python3-obd-0.7.3

Reads and clears engine fault codes over an ELM327 OBD-II adapter

Version 0.7.3, release 1
Shelf python-hw — python3-* hardware, serial, USB, instrument, CAN and device-protocol modules
Phase 40_lang (Languages), 86 of 186 in build order
Licence GPL-2.0-or-later AND BSD-3-Clause
Homepage https://github.com/brendan-w/python-OBD
Build time 0.1 SBU
Installed size 3.5 MiB in 329 files
Recipe ports/core/python-hw/python3-obd/kpkgbuild

About

python-OBD (obd) reads live sensor data and diagnostic trouble codes from a vehicle’s OBD-II port, and clears the codes, through an ELM327-type adapter on a serial port (a USB adapter appears as one); see The device groups and the udev rules. Numeric sensor values are returned as pint quantities carrying their unit, so import obd imports pint.

Why it is in KDOS

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

The one manufacturer-independent engine diagnostic there is, over a serial adapter the dialout group and the CH341/CP210x udev rules already reach.

Sources

Dependencies

Depends on: python3, python3-setuptools, python3-pip, python3-pyserial, python3-typing-extensions, python3-platformdirs, python3-hatchling, python3-hatch-vcs, python3-setuptools-scm.

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/40_lang/phase.env && kpkg install python3-obd'

What kpkg does

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

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

mkdir -p "$SRC_ROOT/vendor"
tar -xf $PORT_SRC/$name-vendor-$version.tar.xz --strip-components=1 -C "$SRC_ROOT/vendor"
pip3 install --ignore-installed --no-deps --no-index --find-links="$SRC_ROOT/vendor" --no-build-isolation \
	--root=$PKG --prefix=/usr \
	pint flexcache flexparser .

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

Contents

Installed programs: pint-convert.

Installed directories: /usr/lib/python3.14/site-packages/flexcache, /usr/lib/python3.14/site-packages/flexcache-0.3.dist-info, /usr/lib/python3.14/site-packages/flexparser, /usr/lib/python3.14/site-packages/flexparser-0.4.dist-info, /usr/lib/python3.14/site-packages/obd, /usr/lib/python3.14/site-packages/obd-0.7.3.dist-info, /usr/lib/python3.14/site-packages/pint, /usr/lib/python3.14/site-packages/pint-0.24.4.dist-info, /usr/share/licenses/python3-obd.

Notes

pint and its two helpers, flexcache and flexparser, have no other consumer in the tree. They are the vendor bundle’s pypackages, with pint pinned there to a release within the pint==0.24.* that obd declares, and installed by name into this package with --no-deps. Their own runtime dependencies, platformdirs and typing-extensions, are ports in depends, and so are their build requirements, setuptools and setuptools-scm (setuptools also builds obd), so the build runs with --no-build-isolation against the installed ports. The three also name wheel as a build requirement, which this setuptools does not need: it builds the wheel itself. The bundle carries sdists of setuptools, setuptools_scm, wheel and their own requirements, which ports/fetch collects as the build requirements; with build isolation off, pip uses none of them.

The bundle is unpacked into $SRC_ROOT/vendor, beside the source tree and not inside it. obd keeps its package at the top of the tree and lists no packages, so setuptools discovers them by itself and would take a vendor directory there for a second top-level package and refuse to build; see Where the bundle goes.