Skip to main content

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.toml builds 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.typed ships type info downstream (PEP 561).
  • Dependency management: uv.lock pins exact versions for both runtime ([project.dependencies]) and dev tooling ([dependency-groups], PEP 735). package-lock.json does the same for the npm-based formatters.
  • Logging: LOG_LEVEL / LOG_FORMAT pick the threshold and the shape - human-readable text, or one JSON object per line (built with json.dumps, with the timestamp, exception and extra={...} fields a log pipeline expects). Diagnostics go to stderr so stdout stays the command's output.
  • Quality gates: ruff (lint + format), mypy --strict, codespell, pytest with a 100% coverage floor, prettier, and markdownlint-cli2 - see scripts/ below.
  • Security: pip-audit and npm audit check locked dependencies against advisory databases; zizmor lints 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.yml reruns the dependency audits weekly; .github/dependabot.yml keeps every pin (Python, npm, the Dockerfile's base images, Actions) current.
  • CI: .github/workflows/ci.yml runs the same gates on every push/PR, plus a build job that verifies the built wheel actually installs and runs.
  • Local gates: .githooks/pre-push runs 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.

Using this as a template

  1. 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) - keep tests/test_node_version_consistency.py and tests/conftest.py. logging_config.py (and its tests) is meant to be kept and adapted rather than deleted.
  2. Update [project] in pyproject.toml: name, description, the packages path under [tool.hatch.build.targets.wheel], and [project.scripts] if you don't want a console script.
  3. Add your runtime dependencies to [project.dependencies].
  4. 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

python_package_blueprint-1.0.3.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_package_blueprint-1.0.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

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

Hashes for python_package_blueprint-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9e68fa6b73f797c5df524ec84da83c51e982b2a8177ea5b8372d6549b42d3dc2
MD5 963712535b704642e7792a5a486b208f
BLAKE2b-256 d1e4816e63b5aeb83bbe1a7b2799a587fdb3550e5b5a723363a50377e57fef07

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_package_blueprint-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for python_package_blueprint-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3e6d36a6fdfef5146308968f74cb5f651b57100726c1c3832aa8b019f97318a4
MD5 f2a4e5eaad6444d4442ea3da38eeeb1d
BLAKE2b-256 8d928e16adaf490ced2370a14d993d7b9fb5c10ac5261fcffdc6915d97bd8085

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page