#1499·magika

[python] Consider publishing a source distribution (sdist) for the PyO3-based Python package

Author: reyammerCreated Sep 25, 2026Updated Sep 25, 2026

With the transition of the magika Python package to native Rust bindings via PyO3 and Maturin (removing the legacy pure-Python wheel and sdist jobs), we currently only build and publish pre-compiled abi3-py38 binary wheels across our supported target matrix.

We may want to re-introduce building and publishing a source distribution (sdist) alongside the binary wheels for corner-case users and downstream packagers:

Motivation

  • Fallback on unsupported platforms/architectures: Users on platforms without pre-built wheels (e.g., FreeBSD, OpenBSD, ppc64le, s390x, Linux ARMv6, or musl ARMv7) can install magika from source via pip install magika / uv add magika using a local Rust toolchain instead of failing with No matching distribution found.
  • Downstream distribution maintainers: Maintainers for Linux/BSD distributions (Debian, Fedora, Arch, Alpine, Nixpkgs, Homebrew, conda-forge) typically build packages from the PyPI sdist.

Implementation Notes & Considerations

  • Workspace / path dependencies: maturin sdist supports bundling local relative path dependencies (rust/pyo3, rust/lib, rust/rules, rust/tract-runtime), provided each crate's Cargo.toml include list covers all required build assets (models, rulesets, build.rs).
  • Standalone magika CLI binary: Binary wheels currently bundle the pre-compiled rust/cli binary staged via python/scripts/stage_cli.sh into python/wheel_data/scripts/. Since an sdist is platform-independent and Maturin's PEP 517 build backend only compiles the manifest-path crate (rust/pyo3), we should decide whether sdist installs only provide the magika Python library (or also expose a CLI entrypoint/warning).