Python Package Blueprint (with an Agent-Ready Development Environment)
A template for starting a new Python package: src/-layout packaging with
hatchling and git-tag-derived versions, uv for
dependency locking, ruff + mypy --strict + a 100%-coverage pytest gate,
and a devcontainer with the same tools baked in for both humans and coding
agents. Every piece is wired up and exercised end to end - see
src/example_package/ and
tests/ for a working (if trivial) example.
What's included
- Packaging:
pyproject.tomlbuilds a real sdist/wheel (uv build) via hatchling; the version comes from git tags (hatch-vcs), not a hand-maintained field.src/example_package/py.typedships type info downstream (PEP 561). - Dependency management:
uv.lockpins exact versions for both runtime ([project.dependencies]) and dev tooling ([dependency-groups], PEP 735).package-lock.jsondoes the same for the npm-based formatters. - Logging:
LOG_LEVEL/LOG_FORMATpick the threshold and the shape - human-readable text, or one JSON object per line (built withjson.dumps, with the timestamp, exception andextra={...}fields a log pipeline expects). Diagnostics go to stderr so stdout stays the command's output. - Quality gates:
ruff(lint + format),mypy --strict,codespell,pytestwith a 100% coverage floor,prettier, andmarkdownlint-cli2- seescripts/below. - Security:
pip-auditandnpm auditcheck locked dependencies against advisory databases;zizmorlints the GitHub Actions workflows; CodeQL scans the source itself (.github/workflows/codeql.yml- public repos only, see the note at the top of that file)..github/workflows/audit.ymlreruns the dependency audits weekly;.github/dependabot.ymlkeeps every pin (Python, npm, the Dockerfile's base images, Actions) current. - CI:
.github/workflows/ci.ymlruns the same gates on every push/PR, plus a build job that verifies the built wheel actually installs and runs. - Local gates:
.githooks/pre-pushruns lint + test before every push (activated automatically inside the devcontainer). - Devcontainer:
.devcontainer/gives both a human's editor and coding agents (Claude Code, Codex) an identical, tool-complete environment.
Quickstart
Open the repo in the devcontainer (VS Code's "Reopen in Container", or any Dev Containers-compatible tool) - everything below is pre-installed there. Outside the devcontainer:
uv sync # Python runtime + dev tooling, from uv.lock
npm ci # prettier / markdownlint-cli2, from package-lock.json
Everyday commands
| Command | What it does |
|---|---|
scripts/lint |
Every read-only check (ruff, mypy, codespell, ...). |
scripts/fix |
Auto-fixes the fixable subset of scripts/lint. |
scripts/test |
The test suite, with coverage enforced (--offline skips tests marked online). |
scripts/audit |
Security audits that need network access. |
Special commands
For local simulation (manual, by-hand checks)
scripts/dev_local_simulation- Builds the package and publishes it to the local pypiserver in
.devcontainer/docker-compose.yml, then installs and runs that build - a manual, by-hand check.
- Builds the package and publishes it to the local pypiserver in
Using this as a template
- Rename
src/example_package/to your real package name and delete the sample code and tests inside it (tests/test_core.py,tests/test_cli.py) - keeptests/test_node_version_consistency.pyandtests/conftest.py.logging_config.py(and its tests) is meant to be kept and adapted rather than deleted. - Update
[project]inpyproject.toml:name,description, thepackagespath under[tool.hatch.build.targets.wheel], and[project.scripts]if you don't want a console script. - Add your runtime dependencies to
[project.dependencies]. - Update this README.
URLs
License
MIT - see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_package_blueprint-1.0.3.tar.gz.
File metadata
- Download URL: python_package_blueprint-1.0.3.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e68fa6b73f797c5df524ec84da83c51e982b2a8177ea5b8372d6549b42d3dc2
|
|
| MD5 |
963712535b704642e7792a5a486b208f
|
|
| BLAKE2b-256 |
d1e4816e63b5aeb83bbe1a7b2799a587fdb3550e5b5a723363a50377e57fef07
|
Provenance
The following attestation bundles were made for python_package_blueprint-1.0.3.tar.gz:
Publisher:
publish.yml on ka-rb0/python-package-blueprint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_package_blueprint-1.0.3.tar.gz -
Subject digest:
9e68fa6b73f797c5df524ec84da83c51e982b2a8177ea5b8372d6549b42d3dc2 - Sigstore transparency entry: 2485560360
- Sigstore integration time:
-
Permalink:
ka-rb0/python-package-blueprint@087ee5a3470994bcef379d32e65abb89616b62bb -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/ka-rb0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@087ee5a3470994bcef379d32e65abb89616b62bb -
Trigger Event:
release
-
Statement type:
File details
Details for the file python_package_blueprint-1.0.3-py3-none-any.whl.
File metadata
- Download URL: python_package_blueprint-1.0.3-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e6d36a6fdfef5146308968f74cb5f651b57100726c1c3832aa8b019f97318a4
|
|
| MD5 |
f2a4e5eaad6444d4442ea3da38eeeb1d
|
|
| BLAKE2b-256 |
8d928e16adaf490ced2370a14d993d7b9fb5c10ac5261fcffdc6915d97bd8085
|
Provenance
The following attestation bundles were made for python_package_blueprint-1.0.3-py3-none-any.whl:
Publisher:
publish.yml on ka-rb0/python-package-blueprint
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
python_package_blueprint-1.0.3-py3-none-any.whl -
Subject digest:
3e6d36a6fdfef5146308968f74cb5f651b57100726c1c3832aa8b019f97318a4 - Sigstore transparency entry: 2485560378
- Sigstore integration time:
-
Permalink:
ka-rb0/python-package-blueprint@087ee5a3470994bcef379d32e65abb89616b62bb -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/ka-rb0
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@087ee5a3470994bcef379d32e65abb89616b62bb -
Trigger Event:
release
-
Statement type: