medius 2.2.1

Host control library for the medius transparent mouse passthrough box
Documentation
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "medius"
version = "2.2.1"
description = "Python bindings for the medius transparent mouse passthrough box"
requires-python = ">=3.8"
license = { text = "MIT" }
authors = [{ name = "medius" }]
keywords = ["medius", "mouse", "hid", "serial", "makcu"]
classifiers = [
    "License :: OSI Approved :: MIT License",
    "Programming Language :: Python :: 3",
    "Programming Language :: Rust",
    "Topic :: System :: Hardware",
]

[project.urls]
Homepage = "https://github.com/K4HVH/medius"

[project.optional-dependencies]
test = ["pytest"]

[tool.hatch.build.targets.wheel]
packages = ["medius"]
# The bundled cdylib makes this platform-specific, but ctypes doesn't link the
# CPython ABI; the build hook tags the wheel py3-none-<platform>.
pure-python = false
# The cdylib is produced and copied in by the build hook below.
artifacts = [
    "medius/libmedius_capi.so",
    "medius/libmedius_capi.dylib",
    "medius/medius_capi.dll",
]

# Global hook so it runs for both the wheel build (cargo + bundle + tag) and the
# sdist build (vendor the Rust sources under _rust/ for a self-contained build).
[tool.hatch.build.hooks.custom]
path = "hatch_build.py"

[tool.hatch.build.targets.sdist]
# The build hook vendors the Rust workspace into the sdist under _rust/, so the
# sdist builds with no access to the rest of the repo (and cibuildwheel builds
# from it). These entries are the Python package itself.
include = ["medius", "hatch_build.py", "pyproject.toml"]

# --- cibuildwheel ---
# Build from the self-contained sdist. Each wheel bundles its own cdylib, so
# `pip install medius` needs no Rust toolchain. The build hook runs
# `cargo build --release -p medius-capi` from the vendored sources, so the
# before-all step installs Rust into the build environment. Arch is whatever the
# runner is (the CI matrix runs one runner per arch).
[tool.cibuildwheel]
# The wheel is tagged py3-none-<platform>, so one interpreter per platform
# produces a wheel that installs on every supported Python 3.x. Build only the
# variants whose toolchain we provide: glibc Linux (manylinux), macOS, and
# 64-bit Windows. musllinux and win32 are skipped (no musl/i686 Rust target set
# up); musl/32-bit users build from the sdist.
build = "cp310-manylinux_* cp310-macosx_* cp310-win_amd64"
build-frontend = "build"
# The bundled wheel has no mock feature, so only smoke-test the import here; the
# mock-backed pytest suite runs against a debug build in the python CI job.
test-command = "python -c \"import medius; print(medius.abi_version(), medius.version_string())\""

[tool.cibuildwheel.linux]
# The cdylib links libudev (via serialport); the manylinux container lacks it.
before-all = "(yum install -y systemd-devel pkgconfig || dnf install -y systemd-devel pkgconfig) && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal"
environment = { PATH = "$HOME/.cargo/bin:$PATH" }

[tool.cibuildwheel.macos]
before-all = "rustup toolchain install stable --profile minimal || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal"

[tool.cibuildwheel.windows]
before-all = "rustup toolchain install stable --profile minimal"