/tiran-skills:choose-python-build-backendfrom tiran-skills
Recommends a PEP 517 build backend for Python packages based on pure vs compiled code, static vs dynamic metadata, and native build system. Covers uv-build, flit-core, hatchling, meson-python, scikit-build-core, maturin, and setuptools.
Ships in tiran-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub tiran/agent-skills --plugin tiran-skillsStatus: Experimental — grounded in the PyPA tool recommendations and current backend docs (linked below); the decision procedure is a new draft. Backends are swappable (that's the point of PEP 517), so a wrong call is cheap to reverse — but get it right up front and you avoid churn.
A build backend turns your source tree into an sdist and wheel. It does not manage environments, resolve dependencies, or upload — PEP 517 standardizes the interface so any frontend (pip, uv, build, cibuildwheel) drives any backend. That means for a simple pure-Python package the choice barely matters and is trivial to change later; it matters most for compiled projects and for dynamic metadata. This skill picks a backend and points at the migration skill that does the work.
Poetry / poetry-core? Intentionally out of scope. poetry-core is a valid
backend, but choosing it means adopting Poetry's all-in-one workflow, and these
skills prefer a composable, standards-first stack (uv + a purpose-built backend +
PEP 621 metadata). It's a fair tool and partly a matter of taste — the balanced
case, and when Poetry still makes sense for a new product, is in
reference/why-not-poetry.md.
Guardrails. Read
../GUARDRAILS.mdand follow it unless the user says otherwise: work in a project-local.venvwith uv (never global/user site-packages); don't delete content or commit/push without approval (never straight tomain); ask before installing heavy packages or starting a heavy compile (torch/CUDA are multi-GB); match the project's existing style and keep comments/docstrings terse.
# compiled code? (platlib vs purelib)
grep -rnE 'ext_modules|Extension|extension_module|pybind11|nanobind|\.pyx|Cargo.toml|CMakeLists.txt|meson.build' \
setup.py pyproject.toml . 2>/dev/null | head
# current backend / metadata style
grep -nE 'build-backend|^\[project\]|dynamic\s*=|setuptools_scm|hatch-vcs' pyproject.toml setup.py setup.cfg 2>/dev/null
.py, no compiled step) →
purelib. Any C/C++/CUDA/Cython/Fortran/Rust that compiles per-platform →
platlib (many wheels: OS × arch × ABI).[project] (static), or must something be computed at build time —
version from a git tag/VCS, readme assembled, classifiers generated
(dynamic)? See modernize-python-metadata..pyx)? Rust
(Cargo.toml)? An existing CMake or Meson build? A Torch C++/CUDA extension?
Plain hand-written C/C++? This is a primary selector — the language/toolchain,
not just "compiled or not", picks the backend in step 3.For a simple pure-Python library, any PEP 517/621 backend works; pick by
metadata needs and which project manager you use. Full per-backend assessment:
reference/backends.md.
uv_build). Fastest (10–35×),
the default of uv init. Pure-Python only, no dynamic/VCS version,
generated files must pre-exist, enforces one src/<pkg>/ matching the name.__version__ string (dynamic = ["version"]) — the one bit of dynamic it supports. Pure-Python only.Rule of thumb: hatchling is the safe general-purpose choice; drop to flit-core/uv-build only when the package is simple, static, and you want minimalism/speed.
Choose by the native toolchain; each has a dedicated migration skill:
find_package(Torch)) → scikit-build-core. CMake does the build; parallel
by default via Ninja. → port-to-scikit-build-core.port-to-meson-python.reference/backends.md.find_package(Torch)), especially if adopting the stable ABI. →
port-to-torch-stable-abi +
port-to-scikit-build-core.scikit-build-core[hatchling]
(drives CMake as a Hatchling build hook) or a custom
tool.hatch.build.targets.wheel.hooks.custom + hatch_build.py. Keeps
hatchling's metadata/versioning while compiling. Details in reference/backends.md.Extension (a .so/.dll
from Rust/Go/CMake, or a ctypes/cffi lib) → setuptools wrongly tags it purelib
py3-none-any; force platlib (has_ext_modules or a bdist_wheel override).
Recipe in reference/backends.md → "Forcing a platlib wheel".All compiled backends support VCS/dynamic versioning through their own mechanism
(maturin from Cargo.toml/VCS, scikit-build-core via metadata providers,
meson-python computed in meson.build).
Beyond the language, three concerns often decide (or confirm) the pick — details
and a table in reference/backends.md:
pybind11-to-nanobind). pybind11 works with
scikit-build-core (CMake) or meson-python, but is not abi3-capable — you
get a wheel per Python version.wheel.py-api = "cp3x", or nanobind
STABLE_ABI), meson-python (limited-api = true), and maturin (abi3
feature) all support it; flit/uv/hatchling are purelib (abi3 is moot);
setuptools can but it's manual. Free-threaded CPython before 3.15 has no
abi3 — emit per-version free-threaded wheels there. Introduced in Python
3.15, PEP 803 adds abi3t, whose set
of compatible interpreters is a superset of abi3's: a .abi3t.so loads on
both GIL-enabled and free-threaded CPython ≥3.15, so a single wheel with the
combined abi3.abi3t tag (scikit-build-core 1.0
wheel.py-api = "cp315.cp315t", maturin, and meson-python) covers regular and
free-threaded Python from 3.15 — one stable-ABI wheel for everything. Full
model: port-to-python-limited-api.A Torch C++/CUDA extension usually hits several of the above at once: it needs
find_package(Torch) (CMake) → scikit-build-core; if you want one wheel
across Torch/Python versions, adopt the Torch stable ABI + nanobind for
abi3, and get CMake+Ninja parallelism for the heavy CUDA build. See
port-to-torch-stable-abi +
port-to-scikit-build-core +
pybind11-to-nanobind.
setuptools is not deprecated and remains a fully valid PEP 517 backend
(≥61 reads [project]; ≥77 does PEP 639 licenses). What is deprecated is the
legacy python setup.py … workflow and the setuptools-specific editable
fallback. Reasons people move, and reasons to stay, are in
reference/why-not-setuptools.md; the short version:
Reasons to prefer a modern backend (pure-Python especially):
.gitignore
(no MANIFEST.in) and is strict about what goes in the wheel; setuptools
auto-discovers packages and can ship test/tooling dirs by accident.setup.py develop path is being removed from the pip/setuptools stack.setup.py/setup.cfg/MANIFEST.in) and a
real plugin system.reference/why-not-setuptools.md.)Reasons to stay on setuptools:
Extension you don't want to rewrite —
setuptools natively supports C/C++ (and Rust via setuptools-rust). Migrating the
build is the expensive part; don't churn it without a reason.Caveat — parallel builds: setuptools has no isolation against concurrent builds sharing a working dir (they can trample each other / fail non-deterministically). If you build many wheels in parallel from one tree, this alone is a reason to move compiled projects to scikit-build-core (CMake/Ninja handle parallelism natively) or meson-python.
Bottom line: new pure-Python project → hatchling (or uv-build/flit for simple static). New compiled project → the language-appropriate backend above, not setuptools. Existing setuptools pure-Python project → worth modernizing. Existing setuptools C-extension that builds fine → migrate only when you have a reason (parallel builds, abi3, CMake/Meson features).
Switching backends is mostly declarative because PEP 517 standardizes the interface — frontends don't care which backend you use:
Metadata → [project]. Move name/version/deps/etc. into a PEP 621
[project] table (keep it static where you can). Use
modernize-python-metadata.
Swap [build-system]. Set requires + build-backend to the chosen
backend (exact strings per backend in reference/backends.md). PEP 517 builds
are isolated — the backend and everything in requires are installed into a
fresh throwaway env, and nothing is inherited from your dev environment. So
requires must list every build-time dependency: the backend itself plus
Cython, header-providing packages (numpy), a VCS-version tool, etc. If it isn't
in requires, it isn't there at build time. (The one deliberate exception is
building against a pre-installed dep like Torch with --no-build-isolation —
see modernize-python-metadata.)
Migrating setuptools from a bare setup.py: a project with no
[build-system] table is already built with setuptools.build_meta:__legacy__
(pip's implicit fallback), which puts the project root on sys.path so a
setup.py can import a sibling helper. Plain setuptools.build_meta is stricter
and does not — default to :__legacy__ while a setup.py remains, and move
to plain setuptools.build_meta only once it's gone or has no local imports
(reference/backends.md).
Backend-specific config. File selection (tool.hatch.build /
tool.scikit-build / tool.meson-python), dynamic version plugin, etc.
Compiled builds are the real work — authoring CMakeLists.txt /
meson.build / Cargo config — and that's what the dedicated port-to-* skills
cover. A pure-Python backend swap is usually a few lines.
Verify: uv build (or python -m build) produces sdist + wheel; install in a clean env
and import/test; uvx twine check dist/*.
A recommendation stating the backend, why (the three axes), the exact
[build-system] block, whether metadata should be static or dynamic, and — if
migrating — a pointer to the specific migration skill and the mechanical steps
above. For compiled projects, the recommendation names the native build system
(CMake/Meson/Cargo), not just the backend.
12 skills in this plugin
/bootstrap-python-projectScaffold a new Python project from zero: src/ layout, PEP 621 metadata, a chosen build backend (hatchling for pure Python; meson-python / scikit-build-core / maturin for compiled) with dynamic VCS versioning, py.typed, ruff, a type checker, pytest + coverage, tox or nox via uv, and hardened GitHub Actions CI (SHA-pinned, Trusted Publisher, CodeQL/Scorecard/Dependabot). Always writes a README, LICENSE, and .gitignore. Orchestrates the choose-python-build-backend, modernize-python-metadata, ship-type-information, and secure-python-release-pipeline skills. Use when asked to start a new package, scaffold/bootstrap a Python project, set up a repo from zero, turn a loose script into a proper package, or bring an existing project up to this standard (adopt the layout, metadata, tooling, or CI it lacks)./crypto-fips-auditAudit a Python package — and any C/C++/Go/Rust code it ships — for its use of cryptography, across three use cases: inventory what crypto a package uses at all (algorithms, providers, linkage, RNG, CA stores), find insecure or weak cryptography, and assess FIPS 140-3 / NIST compliance. Flags insecure use of approved primitives (AES-ECB, RSA PKCS#1 v1.5, static IV/nonce, `random` for secrets, timing-unsafe compares, disabled TLS verification), weak RSA/EC key sizes, and — for FIPS — refused hashes (MD5, MD4, RIPEMD-160), restricted ones (SHA-1), non-approved primitives (BLAKE2/3, ChaCha20-Poly1305, 3DES, scrypt/Argon2/bcrypt, X25519/X448 key agreement, secp256k1), vendored or statically linked crypto (bundled OpenSSL/BoringSSL/AWS-LC/NSS/GnuTLS/libgcrypt/ nettle/libsodium) that escapes the system validated module, hardcoded TLS versions/ciphers that bypass crypto-policies, bundled CA trust stores, and problematic PyPI deps (bcrypt, pycryptodome, pynacl, ecdsa, rsa, m2crypto, …). Source-first, then confirmed against the built wheel/binaries. Gathers evidence; does not certify compliance./modernize-python-metadataImprove a Python package's metadata and move it into a PEP 621 [project] table in pyproject.toml — filling in what's missing along the way. Covers the readme field (dropping the open().read() hack), SPDX license expressions, trove classifiers, well-known project URLs, authors/keywords/requires-python, dependency version constraints (avoid upper caps), PEP 735 dependency groups vs extras, and the build-system table. Keeps the existing build backend (setuptools is fine). Includes a Poetry → PEP 621 migration lens (the [tool.poetry] field map and caret/tilde → floor translation; PDM too). Use when asked to clean up packaging metadata, move metadata out of setup.py/setup.cfg, migrate a Poetry (or PDM) project to [project]/PEP 621, or improve a project's PyPI page./port-to-free-threaded-pythonMake a Python package work correctly on the free-threaded (no-GIL) CPython build (PEP 703; the cp313t/cp314t "t" ABI) and declare that it does, so importing it does not silently re-enable the GIL. Covers the pure-Python thread-safety pass (mutable global/class state, caches, contextvars vs threading.local) and, for C/C++/Cython/pybind11/nanobind/Rust-PyO3 extensions, declaring support (Py_mod_gil / PyUnstable_Module_SetGIL / the per-binding flag), fixing data races with critical sections (Py_BEGIN_CRITICAL_SECTION), PyMutex, atomics and thread-local state, the borrowed-reference hazards and their strong-reference replacements (PyList_GetItemRef, PyDict_GetItemRef), building cp3Xt wheels (meson-python, scikit-build-core, maturin, setuptools, cibuildwheel), and testing under load with ThreadSanitizer and pytest-run-parallel. Use to add free-threading / no-GIL / nogil / free-threaded / PEP 703 support, ship a cp313t/cp314t wheel, or stop the GIL being re-enabled. For a single stable-ABI abi3t wheel (3.15+) pair it with port-to-python-limited-api./port-to-meson-pythonBuild a Python package (usually with a compiled C/C++/Cython/Fortran/Rust extension) with the meson-python PEP 517 backend, or port one off a bespoke setuptools setup.py. Covers the pyproject.toml backend, the meson.build (project / extension_module / install_sources), VCS/dynamic versioning computed in meson.build, editable installs, config-settings, and abi3 / limited-API wheels. Use when asked to adopt meson-python or Meson, scaffold a new meson-python project, drop setup.py, or produce standards-based wheels./port-to-python-limited-apiPort a hand-written C/C++ CPython extension from the version-specific C API to the Limited API (Py_LIMITED_API) so one stable-ABI abi3 wheel loads on every later Python instead of one per version — and optionally target Python 3.15 abi3t (PEP 803 + PEP 793 PyModExport) for a single wheel across GIL-enabled and free-threaded builds. Covers the usual first step of converting static PyTypeObject types to heap types (PyType_FromSpec / PyType_Slot), module state, multi-phase init, API substitutions, and the build flags / abi3 / abi3.abi3t wheel tags for meson-python, scikit-build-core, maturin, and setuptools. Use to adopt the limited API / stable ABI / abi3 / abi3t, stop rebuilding a C extension per Python version, or convert static types to heap types. Not for pybind11/nanobind (see pybind11-to-nanobind) or the PyTorch C++ ABI (see port-to-torch-stable-abi).