/tiran-skills:modernize-python-metadatafrom tiran-skills
Moves Python package metadata into a PEP 621 [project] table in pyproject.toml, covering readme, SPDX licenses, trove classifiers, URLs, dependencies, and PEP 735 groups. Includes Poetry/PDM migration guidance.
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.
Status: Experimental — grounded in the current PyPA specifications (linked below); the step order is a new draft. Metadata bugs are quiet (a wrong classifier or a bad cap surfaces later), so verify with the tools in step 11.
This skill is about metadata — it moves author/version/license/deps/URLs into
a declarative [project] table and improves what's there. It is not about
replacing or removing the build backend: setuptools stays a perfectly good
choice, and it reads [project] from pyproject.toml (setuptools ≥ 61). Any
setup.py/setup.cfg build logic (e.g. ext_modules, cmdclass) can remain;
only the metadata moves out. If you separately want to change how the package
builds, that's a different job — see
port-to-scikit-build-core /
port-to-meson-python. Work in the order below.
[project]) —
https://packaging.python.org/en/latest/guides/writing-pyproject-toml/Several fields below only work on recent tool versions — an old backend or
uploader will error or silently drop them. Before adopting them, bump the
relevant tools (and their floors in [build-system].requires):
[project] table → setuptools ≥ 61.license expression + license-files (PEP 639, core metadata 2.4) →
setuptools ≥ 77 / hatchling ≥ 1.27 (recent) and twine ≥ 6.1 to upload it
(older twine rejects Metadata-Version 2.4).[dependency-groups] (PEP 735) → a resolver that supports it (pip ≥ 25.1,
or uv) — it's not build metadata, so the backend version doesn't matter, but old
pip won't understand --group. If a Hatch environment must consume a group
(via the dependency-groups env key), pin Hatch ≥ 1.18.0 — the functional
fix landed in 1.16.3, but tool.hatch.requires-hatch (which enforces the floor
in-tree) exists only from 1.18.0, so use it as the single coherent floor and
keep any CI/dev-group pin on the same bound; older Hatch has no way to read a
group and its features key sees extras only (step 8). This is the Hatch
env-runner version, not hatchling the backend.When in doubt, check each tool's changelog and set conservative floors. Rule of
thumb: use current setuptools/hatchling, build, and twine. The rest of this
skill flags the version-sensitive spots (reference/field-guide.md has a table).
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.
ls pyproject.toml setup.py setup.cfg 2>/dev/null
grep -nE 'name=|version=|install_requires|extras_require|classifiers|url=|author' setup.py setup.cfg 2>/dev/null
grep -nE '^\[tool\.poetry|^\[project\]' pyproject.toml 2>/dev/null # Poetry vs standard layout
Metadata can be static in setup.cfg [metadata], imperative in setup.py
setup(...), or partial in pyproject.toml. The target is a single static
[project] table (PEP 621); only genuinely computed fields stay dynamic. This
is a metadata move, not a backend change — if the project builds with setuptools,
keep setuptools (it reads [project] since v61); build logic like ext_modules
stays where it is (step 9, step 11).
Coming from Poetry? If metadata lives under
[tool.poetry], first translate it to[project]with the field map and the Poetry-operator → PEP 440 floor table inreference/from-poetry.md(this also covers thepoetry-core→ standard-backend andpoetry.lock→uv.lockswaps), then follow the steps below. Poetry ≥ 2.0 projects may already use[project]— then it's mostly a backend/lockfile swap. PDM is already PEP 621-native, so it's the same backend/lockfile swap without the metadata rewrite.
[project] fields[project]
name = "mypkg"
version = "1.2.3" # or dynamic — see the versioning skills
description = "One-line summary of what it does." # → core-metadata Summary
requires-python = ">=3.11" # floor only; prefer >=3.11 (3.10 EOL Oct 2026)
description is the one-line summary (shown on the PyPI search list), not the
long text — that's the README (step 3). Full field reference:
reference/field-guide.md.
open("README.md").read() hacksetup.py used to do long_description=open("README.md").read() (which breaks
when the CWD isn't the project root, e.g. during isolated builds). Declare it
instead — the backend reads and sets the content type:
[project]
readme = "README.md" # content-type inferred from the extension
# or, to be explicit / use a non-standard name:
# readme = { file = "docs/intro.rst", content-type = "text/x-rst" }
If you need to assemble the long description at build time — splice in the
changelog, rewrite relative image links to absolute URLs so they render on PyPI,
or inject the version — use a dynamic readme provider instead of a shell hack:
Hynek's hatch-fancy-pypi-readme
(Hatchling; also a scikit-build-core metadata.fancy_pypi_readme provider). That
makes readme dynamic: dynamic = ["readme"] plus the provider config.
license is a short SPDX expression, never the license text. Put the actual
text in files and point license-files at them. Do not use License :: trove
classifiers (deprecated) or the legacy table form (license = {text=...} /
{file=...}).
[project]
license = "Apache-2.0" # SPDX expression: "MIT", "BSD-3-Clause OR GPL-2.0-only", …
license-files = ["LICENSE*"] # globs → the full text ships from here
Common mistakes to fix: the whole license pasted into license, a filename in
license (e.g. license = "LICENSE"), or license = { text = "MIT License\n\n…" }.
All become license = "<SPDX id>" + license-files = ["LICENSE*"]. For
non-standard terms use a LicenseRef-... expression and still ship the text via
license-files.
[project]
authors = [{ name = "Ada Lovelace", email = "[email protected]" }]
maintainers = [{ name = "…", email = "…" }] # only if different from authors
keywords = ["parsing", "cli", "async"] # search terms, not classifiers
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11", # one row per minor you test in CI
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Free Threading :: 3 - Stable", # only if you test free-threaded CPython
"Intended Audience :: Developers",
"Typing :: Typed", # if you ship a py.typed marker
]
Pick classifiers from the official list (reference/field-guide.md has the
must-haves and how to browse them). List one
Programming Language :: Python :: 3.X row per minor you actually test — these
are a good signal of your tested range on the PyPI page, which requires-python
can't give (it only states the floor, never a ceiling). Keep them in sync with
your CI matrix and drop rows when you drop the version. If you test free-threaded
CPython, advertise it with a Programming Language :: Python :: Free Threading :: 3 - Stable classifier (or 2 - Beta / 1 - Unstable while support is maturing) —
it's how downstreams discover which packages are free-threading-ready. Safety net
for private packages: add
"Private :: Do Not Upload" — PyPI (and Test PyPI) reject any classifier in the
Private :: namespace, so an accidental twine upload of an internal package
fails instead of leaking it. This is a PyPI server-side rule, not a
backend/hatchling feature — client tools don't check it, and a private index
that doesn't enforce the namespace won't stop the upload. Treat it as cheap
defense-in-depth, not the primary control: the real protections are
project-scoped API tokens or Trusted Publishing (so no all-projects credential
exists to leak) and awareness of dependency-confusion risk when a name exists
on both a private index and public PyPI. See
secure-python-release-pipeline.
Populate [project.urls] with labels that normalize to well-known names so
PyPI renders them consistently (labels are matched case/space/punctuation-insensitively):
[project.urls]
Homepage = "https://github.com/you/mypkg"
Source = "https://github.com/you/mypkg"
Documentation = "https://mypkg.readthedocs.io"
Changelog = "https://github.com/you/mypkg/releases" # GitHub Releases as changelog
Issues = "https://github.com/you/mypkg/issues"
Funding = "https://github.com/sponsors/you" # optional
Recognized labels include homepage, source (aliases repository/github),
documentation (docs), changelog (changes/history), issues
(bugs/tracker), funding, security, releasenotes, download. Table with
all aliases: reference/field-guide.md.
[project]
dependencies = [
"httpx>=0.27", # floor: the oldest you actually support
"click>=8.1,!=8.1.4", # exclude a KNOWN-broken release, not a range guess
]
Avoid upper caps (<N) and never cap requires-python on the high side. A
missing cap anyone can fix downstream; an over-tight cap can only be fixed by a
new release from you, and modern resolvers silently backsolve to ancient
versions instead of erroring. Cap only a version you know is incompatible
(treat it like a TODO to remove). Details and the reasoning:
reference/dependencies.md.
Two different tools — pick by who the dependency is for:
[project.optional-dependencies] (extras) — optional features for your
users, installable as pip install mypkg[postgres]. Published in package
metadata.[dependency-groups] (PEP 735) — internal dev sets (lint, test, docs).
Not published to metadata, not installable as an extra; consumed with
pip install --group test / uv. Use these instead of a dev extra.[project.optional-dependencies]
postgres = ["psycopg[binary]>=3.1"]
[dependency-groups]
test = ["pytest>=7", "coverage[toml]>=7"]
docs = ["sphinx>=7"]
dev = [{ include-group = "test" }, { include-group = "docs" }, "ruff"]
Exception — the consumer must support groups. Only move a dev set to
[dependency-groups]if whatever installs it understands PEP 735. The common trap is Hatch environments:[tool.hatch.envs.<name>].features = ["test"]reads[project.optional-dependencies](extras) only — it cannot consume a[dependency-groups]group, so blindly relocating atest/docsset there silently breaks the env wiring. Either keep those dev sets as extras, or rewire the env to the separatedependency-groupskey and pin Hatch ≥ 1.18.0 (the fix landed in 1.16.3, buttool.hatch.requires-hatchenforces the floor in-tree only from 1.18.0 — use it as the single floor). Same caution for any other consumer (tox, nox, CI) that references extras rather than--group. Check how the sets are consumed before moving them.
More (including include-group and the Hatch caveat): reference/dependencies.md.
[build-system] tableEvery modern project needs one — it's what makes the build reproducible and isolated (PEP 517/518). Keep your current backend if it works — for a setuptools project, just declare it (no need to switch to hatchling et al.):
[build-system]
requires = ["setuptools>=61"] # ≥61 reads [project]
build-backend = "setuptools.build_meta:__legacy__"
Which setuptools backend —
:__legacy__vs plain.:__legacy__is what you get by default whenever you don't name a backend, in two distinct cases:
- No
[build-system]table at all — tools assume bothrequires = ["setuptools", "wheel"]andbuild-backend = "setuptools.build_meta:__legacy__".[build-system]present withrequiresbut nobuild-backend— the backend still falls back to:__legacy__, but yourrequiresis honored as written (the "requires is ignored, assume setuptools+wheel" rule fires only when the whole section is absent). So a legacy setup.py-only project can keep justrequires = ["setuptools>=…"]and rely on the implicit default.Either way you land on
setuptools.build_meta:__legacy__— the shim setuptools ships for projects that predate PEP 517, where asetup.pyroutinely imports helpers sitting next to it. It puts the project root onsys.pathso such asetup.py(importing a version helper, a_build.py) keeps working. Plainsetuptools.build_metais stricter and does not add the root tosys.path, so silently switching to it during a migration can break a build that used to work. Default to:__legacy__while asetup.pyremains; move to plainsetuptools.build_metaoncesetup.pyis gone or has no local imports. Seechoose-python-build-backend/reference/backends.md.
# other backends look the same, e.g.:
# requires = ["hatchling"] build-backend = "hatchling.build"
# requires = ["scikit-build-core"] build-backend = "scikit_build_core.build"
Pin the build backend's floor here; add compile-time deps (Cython, numpy
headers, a VCS-version tool). Special case — building against a pre-installed
dependency (e.g. Torch): some compiled extensions must build against the exact
version already in the environment. There, isolated builds are turned off
(pip install . --no-build-isolation) and the heavy dep is not listed in
requires; the project documents "install torch first." Note it in the README
and treat it as a deliberate exception to the isolate-everything rule.
reference/dependencies.md covers it.
Anything computed at build time goes in dynamic and is filled by the backend
(most commonly the version from VCS — see the versioning skills). Everything else
should be static and readable in pyproject.toml.
[project]
dynamic = ["version"]
uvx validate-pyproject pyproject.toml — schema-check the metadata.
(Worth wiring into pre-commit; the Scientific Python guide's sp-repo-review
also lints packaging metadata, e.g. PP004 "no upper cap on requires-python",
PP007 "don't mix License :: classifiers with the license field".)
uvx pyproject-fmt pyproject.toml is the formatter counterpart — it
normalizes and reorders [project] and can keep the
Programming Language :: Python classifiers in sync with requires-python
(step 5). Run it before validate-pyproject, and add both as pre-commit hooks.uv build then uvx twine check dist/* — render-check the README
and metadata as PyPI will see them.METADATA shows the license, URLs, and classifiers.
In CI, Hynek's
build-and-inspect-python-package
action builds sdist + wheel and prints the exact metadata and file contents —
a fast way to catch a wrong license id, missing README, or a file left out of
the sdist (see secure-python-release-pipeline).setup.py / setup.cfg so there's one
source of truth — but keep whatever build logic remains: ext_modules,
cmdclass, custom build_ext, and setuptools-specific tool config are fine
to leave in setup.py/setup.cfg. A pure-metadata setup.cfg [metadata]
section, or a setup.py that only calls setup() with metadata kwargs, can
be deleted once [project] covers it. Don't delete setup.py just to delete
it — this task doesn't require dropping setuptools.While in pyproject.toml, these are the neighboring cleanups the community
guides recommend — mention them, but they're separate tasks:
pyproject.toml ([tool.ruff],
[tool.pytest.ini_options], [tool.mypy], [tool.coverage]) and delete the
scattered pytest.ini / .flake8 / mypy.ini / tox.ini files.src/ layout (strongly recommended, but don't auto-migrate). Moving the
package under src/mypkg/ takes the project root off sys.path, so tests and
tools import the installed package instead of the source tree — surfacing
"forgot to ship a file / sub-package", empty-wheel, and missing-data bugs
locally instead of after release (the same class the sdist→wheel check in step
11 / the release-pipeline skill targets). Endorsed by Hynek Schlawack, James
Bennett, the Scientific Python guide, and pyOpenSci. Only do the move if the
user asks — a relayout rewrites every path and can obscure git blame/log
across the renames; when asked, use git mv in a dedicated, rename-only commit
so history follows.uvx cookiecutter gh:scientific-python/cookie scaffolds a
standards-based project (pick backend, license, VCS versioning) matching the
guide.Definition of done: metadata lives in a static [project] table (no metadata
duplicated in setup.py/setup.cfg); validate-pyproject and twine check
pass; README, SPDX license, authors, keywords, classifiers, and well-known URLs
are populated; dependencies use floors without speculative caps; dev tooling is in
[dependency-groups] (or stays in extras where a consumer like Hatch features
requires it — step 8); the build backend is declared in [build-system] (keeping
setuptools is fine); any remaining setup.py/setup.cfg holds only build logic,
not metadata.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub tiran/agent-skills --plugin tiran-skills12 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)./choose-python-build-backendRecommend the right PEP 517 build backend for a new or existing Python package, and give enough context to migrate. Chooses by three axes: purelib (pure Python) vs platlib (compiled C/C++/Rust/Torch), static vs dynamic/VCS metadata, and native language/build system. Covers uv-build, flit-core, hatchling (incl. compiled via scikit-build-core[hatchling] / a custom build hook), meson-python, scikit-build-core, maturin, and setuptools (legacy). Weighs compiled-project concerns: Cython, PyTorch extensions, pybind11/nanobind bindings, the stable Python ABI (abi3 / limited API), and fast parallel builds (CMake+Ninja, Meson). Use when asked "which build backend should I use", to pick a backend for a new project, or to decide whether to move an existing project off setuptools./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./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).