python-packaging
Skill3 starsChanged 3 months agoMITView on GitHub
Configures packaging for a Python library — pyproject.toml metadata, build backend, src layout, CLI entry points, uv lockfiles, where dev dependencies go (dependency-groups vs optional-dependencies), wheels and sdists. Use to make a project installable, set up pyproject.toml, build a wheel, move off requirements.txt, or switch to uv. Not for publishing to PyPI or release automation.
- Installs packages
9 other projects use a version of this.
Adopted by
Most recently taken up by
- Quad4-Software/skillstheir own version, first seen Oct 3, 2026
- 2867203296/hermes-agenttheir own version, first seen Aug 19, 2026
- AntheaLaffy/missing-semester-skills-dshtheir own version, first seen Aug 16, 2026
- AntheaLaffy/the-missing-semester-skillstheir own version, first seen Aug 16, 2026
- drzioner/gitwisetheir own version, first seen Jul 22, 2026
- kumaran-is/claude-code-onboardingtheir own version, first seen May 25, 2026
Other versions9 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 9
- kumaran-is/claude-code-onboarding★ 36same name
- xfstudio/skills★ 9same name
- ai4brands-design/claude-skills★ 2same name
- CodeWithBehnam/cc-docs★ 2same name
- AntheaLaffy/the-missing-semester-skills★ 1same name
- drzioner/gitwise★ 1same name
- Quad4-Software/skills★ 1same name
- 2867203296/hermes-agent★ 0same name
- AntheaLaffy/missing-semester-skills-dsh★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-skillSkill
- publish-repoSkill
- agent-guardrailsSkill
- python-ciSkill
- python-lintSkill
- python-precommitSkill
- python-releaseSkill
- python-supply-chainSkill
- python-testingSkill
- python-typingSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 1 is distinctive, and 5 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 54
Do not adopt poetry-core for new projects.
- Very specific: line 66
Keep the upper bound on uv_build: it follows uv's versioning policy, where breaking changes may land in minor releases, so an unbounded …
- Very specific: line 90
Use src/ for libraries: tests and tools then import the *installed* package.
- Very specific: line 144
Commit uv.lock; never hand-edit it.
- Distinctive: line 195
Run the bundled checker (path relative to this skill's folder):
- Very specific: line 228
py.typedin the repo, missing from the wheel: No backend can be assumed to ship arbitrary non-.py files: setuptools needs …
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
python-packaging
Make a Python library installable and buildable with verified artifacts: one
pyproject.toml as the single source of truth, a deliberately chosen PEP 517
build backend, src/ layout, uv-managed dependencies with a committed lockfile,
and an sdist + wheel whose contents are checked rather than assumed. The failures
this skill prevents: declared files (py.typed, data files) silently missing from
the wheel, backends that cannot handle the project's layout or extensions, Poetry
migrations that switch the backend before resolution is verified, and pip calls
that desync a uv-managed environment.
When NOT to use
- Publishing to PyPI, version bumps, changelogs, git tags, trusted publishing — the python-release skill, if installed. Stop after artifacts are verified.
- Type-checker choice or configuration, and whether/how to ship
py.typed— the python-typing skill. This skill only verifies that an existingpy.typedactually lands in the built wheel. [tool.ruff]config — python-lint. pytest/coverage config — python-testing. GitHub Actions — python-ci. Dependency vulnerability audits — python-supply-chain.- Single-file scripts that just need dependencies — PEP 723 inline script metadata
plus
uv run script.pycovers that with no packaging at all.
Workflow
1. Assess what exists
ls setup.py setup.cfg MANIFEST.in requirements*.txt poetry.lock Pipfile uv.lock 2>/dev/null
grep -n "build-backend\|tool.poetry\|dependency-groups\|optional-dependencies" pyproject.toml 2>/dev/null
find . -name "*.pyx" -o -name "*.c" -o -name "Cargo.toml" | grep -v .venv | headRecord three facts before changing anything: (a) native extensions or pure
Python — this decides the backend; (b) flat or src/ layout; (c) which
dev-dependency convention the repo already uses ([dependency-groups],
a dev extra under [project.optional-dependencies], or legacy
[tool.uv] dev-dependencies) — match it or migrate it wholesale, never mix.
2. Choose the build backend
| Backend | Pick when | Avoid when |
uv_build | pure-Python library; zero-config src/ discovery, strict metadata validation | any C/Cython/Rust extension modules (unsupported); VCS-tag dynamic versioning needed |
hatchling | dynamic versioning from git tags via hatch-vcs matters; widely treated as the general-guidance default; plugin ecosystem | you want uv_build's stricter validation and zero config |
setuptools | extension modules (ext_modules), deep legacy config | greenfield pure-Python — looser validation, auto-discovery surprises |
Do not adopt poetry-core for new projects; the ecosystem consolidated on
PEP 621 [project] metadata. Note that uv build is a backend-agnostic PEP 517
frontend — it drives hatchling or setuptools just as well, so adopting uv as the
project manager does not force a backend migration; treat that as a separate,
verified step.
[build-system]
requires = ["uv_build>=0.12,<0.13"]
build-backend = "uv_build"Keep the upper bound on uv_build: it follows uv's versioning policy, where
breaking changes may land in minor releases, so an unbounded requirement can
break your build the day a new version ships. Hatchling and setuptools have more
conservative compatibility norms; a floor (e.g. hatchling>=1.27) is customary.
Risk framing: uv as a whole is pre-1.0, but the uv_build backend specifically
is marked Production/Stable on PyPI and has been the uv init default since
mid-2025 — do not conflate the two in either direction.
Full trade-offs, [tool.uv.build-backend] keys, and per-backend file-inclusion
config: references/build-backends.md.
3. Lay out the package (src/)
my-package/
├── pyproject.toml
├── README.md
├── src/
│ └── my_package/
│ ├── __init__.py
│ └── py.typed # only if the project already ships one
└── tests/Use src/ for libraries: tests and tools then import the installed package.
With a flat layout, import my_package resolves to the working-directory copy
even when the built wheel is broken or missing files — packaging bugs stay
invisible until release. For a new project, uv init --lib my-package scaffolds
src/, py.typed, and the uv_build backend in one step.
uv_build expects src/<module>/__init__.py with the module named after the
normalized project name. If the import name differs, declare it:
[tool.uv.build-backend]
module-name = "actual_import_name"4. Write [project] metadata
Minimal publishable set — validate-pyproject (step 6) will hold you to it:
[project]
name = "my-package"
version = "0.1.0"
description = "One line, benefit first."
readme = "README.md"
license = "MIT" # SPDX expression (PEP 639; needs a current backend)
requires-python = ">=3.10"
authors = [{ name = "Your Name", email = "you@example.com" }]
dependencies = ["httpx>=0.27"]
classifiers = ["Programming Language :: Python :: 3"]
[project.scripts]
my-cli = "my_package.cli:main" # callable must take no required args; parse sys.argv inside
[dependency-groups]
dev = ["pytest>=8"]Dev tooling goes in PEP 735 [dependency-groups] (written by uv add --dev),
not in a published extra: extras under [project.optional-dependencies] are
installable by consumers from PyPI, dependency groups are not. A dev extra
leaks your toolchain into downstream resolvers. Optional runtime features
(e.g. my-package[cli]) are what extras are for.
5. Manage the project with uv
uv init --lib my-package # new projects only (uv >= 0.12 also declares a build system for plain `uv init`; `--no-package` opts out)
uv add httpx # runtime dep -> [project.dependencies] + uv.lock
uv add --dev pytest # dev dep -> [dependency-groups].dev
uv sync # build .venv from uv.lock (--no-dev in production)
uv lock --upgrade-package httpx # targeted upgrade; rest of the lockfile intact
uv run pytest # run tools in the env, no activationCommit uv.lock; never hand-edit it. uv verifies lockfile freshness against
pyproject.toml and environment freshness against the lockfile before every
uv run, which is what makes results reproducible. Never call pip inside a
uv project — it mutates .venv behind the lockfile's back.
Migrations:
- From setup.py/setup.cfg — inventory every section first:
[options]metadata goes to[project],package_data/MANIFEST.indirectives become the backend's file-inclusion config, and tool sections ([tool:pytest],[flake8],[mypy]) move topyproject.tomlor their owning skill. Build once with the old config, once with the new, diff the wheel/sdist listings, and only then deletesetup.py,setup.cfg, andMANIFEST.in(steps 6–8 verify the result). Exception: setuptools with C extensions still needs asetup.pyforext_modules— keep only that part. - From Poetry — run
uvx 'migrate-to-uv==0.12.0'(pin the version: unpinneduvxexecutes whatever was published to PyPI most recently, which is both irreproducible and a supply-chain hole; bump pins deliberately). It maps[tool.poetry.*]to PEP 621 andpoetry.locktouv.lock. Switch[build-system]away frompoetry-corelast, afteruv lock && uv syncresolve cleanly — flipping the backend first is the classic way to debug two migrations at once. - From requirements.txt —
uv add -r requirements.txt(plus-c constraints.txtif present), then delete the file. If downstream tooling still needs one, generate it withuv export.
6. Validate the metadata
uvx --from 'validate-pyproject[all]==0.26' validate-pyproject pyproject.tomlA pyproject.toml that parses as valid TOML can still violate the packaging
PEP schemas (bad license shape, misplaced key, malformed entry point) — this
catches what formatters and TOML parsers do not. Run it after every metadata
edit; it is cheap.
7. Build
uv build # sdist (.tar.gz) + wheel (.whl) into dist/To debug uv_build under any frontend, set RUST_LOG=uv=debug. No-uv fallback
(once, for environments where uv is unavailable): python -m pip install
build==1.6.0 && python -m build produces the same artifacts, and
pip install -e . --group dev (pip >= 25.1; groups are not extras) replaces uv sync for dev installs — at the cost of
lockfile reproducibility.
8. Verify the artifacts — never skip
Run the bundled checker (path relative to this skill's folder):
python3 "${CLAUDE_SKILL_DIR}/scripts/check_wheel.py" --project-root /path/to/project /path/to/project/distIt is read-only and exits non-zero with ERROR lines if: the wheel lacks
METADATA/WHEEL/RECORD; any py.typed present in the source tree is
missing from the wheel; tests/, docs/, or similar directories leaked into
the wheel; or the sdist lacks pyproject.toml. Manual equivalents:
unzip -l dist/*.whl and tar -tzf dist/*.tar.gz.
Then smoke-test the wheel itself (not the source tree):
uv run --isolated --no-project --with dist/my_package-0.1.0-py3-none-any.whl \
python -c "import my_package; print(my_package.__name__)"Output spec — what done looks like
pyproject.tomlis the only packaging config;setup.py/setup.cfg/MANIFEST.in/requirements.txtare gone (exceptsetup.pykept solely forext_modules).validate-pyprojectexits 0.uv buildproduces bothdist/*.tar.gzanddist/*.whl.scripts/check_wheel.pyexits 0 — expected files (includingpy.typedwhen the source ships one) verified inside the wheel; no test/doc leakage.- The built wheel imports in an isolated environment.
uv.lockexists and is committed.
Failure modes & gotchas
py.typedin the repo, missing from the wheel. No backend can be assumed to ship arbitrary non-.pyfiles: setuptools needs[tool.setuptools.package-data], hatchling ships files inside the package dir only if the wheel target points at it, uv_build includes files under the module root. Consumers of a wheel without the marker silently getAnyfor your whole API — verify the artifact, not the source tree. Per-backend snippets in references/build-backends.md.- uv_build "module not found" / metadata validation failure. By default it
expects one module named after the normalized project name at
src/<module>/or./<module>/. Declare a different name, several modules, or a namespace package with[tool.uv.build-backend]module-name = [...]/module-root/namespace(an explicit list is recommended overnamespace = true, which disables the safety checks). - Build breaks after a uv release. Unbounded
requires = ["uv_build"]— restore the>=X,<X+1bound (step 2). - Half-finished Poetry migration.
[build-system]flipped while the real dependency list still sits in[tool.poetry.dependencies]— artifacts build with wrong or missing metadata. Metadata first, resolution verified, backend last. - Heisenbug environments. Someone ran
pip installin the uv project; the nextuv runsilently reverts it. Both directions look like flakiness. Onlyuv add/uv syncmutate the env. - Tests pass, installed package broken. Flat layout imported the
working-directory copy, masking files missing from the wheel.
src/layout plus the step 8 wheel smoke test catches it. tests/ships inside the wheel. setuptools auto-discovery picks up any importable top-level directory. Constrain it ([tool.setuptools.packages.find] where = ["src"]) or move tosrc/layout;check_wheel.pyflags the leak.- Dev extra published to PyPI. Dev tooling declared as
[project.optional-dependencies] devbecomes an installable extra for every consumer. Use[dependency-groups]for tooling; extras for optional runtime features only. - Valid TOML, invalid metadata. Formatters and TOML parsers accept files that violate packaging schemas — that is what step 6 exists for.
- Performance folklore. Large build-speed multipliers claimed for uv_build trace to practitioner blog posts, not controlled benchmarks. Treat as directional; do not repeat specific numbers as fact.
Bundled files
- references/build-backends.md — backend
trade-offs in depth,
[tool.uv.build-backend]reference, per-backend file inclusion (py.typed, data files), migration paths, legacy-tool→uv command map. scripts/check_wheel.py— read-only sdist/wheel verification; run after every build; non-zero exit with machine-readableERRORlines on failure.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

