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. .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 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.2.tar.gz (9.6 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.2-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_package_blueprint-1.0.2.tar.gz
  • Upload date:
  • Size: 9.6 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.2.tar.gz
Algorithm Hash digest
SHA256 bd2a329057b78726dd241dc407e189e54b086f9c02fb45931dfcf8ac23fdc08f
MD5 668e6fa396d6dd95c6faa0e5015845fd
BLAKE2b-256 e6958355c6cefb8e7646d03529d0e2d97d30426e5f5e915987b627a40a86c5f9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_package_blueprint-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.9 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5cf107f35065af0d58dd7e78e771e6c96c3363fc053f1e6c18b2ac3da49f8c42
MD5 ddd5b19d0edf1358b7c7ce8325fbc2cd
BLAKE2b-256 28a7c54ce22e0ed5f7acd3b155246a09b3bf6709079a2b5f86295ed14f1138d1

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