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.
  • 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. .github/workflows/audit.yml reruns them 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.
  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.

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.1.tar.gz (7.3 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.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file python_package_blueprint-1.0.1.tar.gz.

File metadata

  • Download URL: python_package_blueprint-1.0.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_package_blueprint-1.0.1.tar.gz
Algorithm Hash digest
SHA256 03c8f691e79c7a280e4817f56944f68d01bcfc068e1c8e362159b4eb859025bf
MD5 3677d3c25b72b13aba0ba7e54ea55e5c
BLAKE2b-256 5bdbcac6a432a8f88c59486f437e950e23a1b21ea748f3b7bf11ccff59f3aba1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_package_blueprint-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_package_blueprint-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f09fa80665ec9aeb7ec54478b306db127034f9e60e869dc96eee93ee03de8b0
MD5 49377e5360dc91d1725a9725ac667a8d
BLAKE2b-256 7c2520eddf6732b03474a7cb4920f1adffd1be054fc56064fa1b2d1b821beceb

See more details on using hashes here.

Supported by

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