A short description of your package.
- Modern tooling:
uvfor deps,rufffor format/lint,mypyin strict mode - CI/CD ready: GitHub Actions for checks, coverage upload, and releases
- Release automation: hatch-vcs + commitizen-driven tagging and changelog
pip install package-namefrom package_name import greet
# Example usage
message = greet("Python")
print(message) # Output: Hello, Python!π Full documentation is available in the docs/ directory
Build and view locally:
doit docs_serve # Opens at http://127.0.0.1:8000Key documentation files:
- Installation Guide - Setup instructions
- Usage Guide - Development workflows and commands
- API Reference - Complete API documentation
- Extensions Guide - Optional tools and extensions
π The fastest way to create a new project from this template:
curl -sSL https://raw.githubusercontent.com/endavis/pyproject-template/main/bootstrap.py | python3The script will:
- β Create a new repository from this template on GitHub
- β Configure repository settings (merge options, features)
- β Set up branch protection rules
- β Replicate labels
- β Run placeholder replacement automatically
- β Provide a checklist of manual steps (secrets, etc.)
Requirements:
- GitHub CLI installed and authenticated (
gh auth login) - Git installed
- Python 3.12+
What you'll need to add manually:
- PyPI tokens (for publishing packages)
- Codecov token (optional, for coverage reports)
- Collaborators/team access
π See New Project Setup for detailed instructions.
First time setup: This is a template repository. If you prefer to clone manually:
# Clone the template
git clone https://github.com/username/package_name.git my-project
cd my-project
# Run the interactive configuration script
python3 tools/pyproject_template/configure.pyThe script will prompt you for:
- Project name, description
- Package name (Python import name)
- PyPI package name
- Author name and email
- GitHub username
It will automatically:
- Rename the package directory
- Update all template placeholders
- Self-destruct after completion
π See New Project Setup for detailed instructions and post-setup steps.
- Python 3.12+
- uv - Fast Python package installer
- direnv - Automatic environment variable loading (optional but recommended)
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone repository
git clone https://github.com/username/package_name.git
cd package_name
# Create virtual environment and install dependencies
uv sync --all-extras --dev
# Install pre-commit hooks
doit pre_commit_install
# Optional: Install direnv for automatic environment management
# macOS:
brew install direnv
# Linux (using doit helper):
doit install_direnv
# Hook direnv into your shell (one-time setup)
# Bash:
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
source ~/.bashrc
# Zsh:
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc
source ~/.zshrc
# Allow direnv to load .envrc
direnv allow
# Optional: Create .envrc.local for personal overrides
cp .envrc.local.example .envrc.localThis project uses automated versioning and releases powered by commitizen and hatch-vcs.
- Single Source of Truth: The Git tag is the definitive version.
pyproject.tomland_version.pyare generated at build time from tags (no manual edits). - Versioning Scheme:
- Production: Standard SemVer (e.g.,
v1.0.0). - Development: SemVer Pre-release (e.g.,
v1.0.0-alpha.1,v1.0.0-beta.0).
- Production: Standard SemVer (e.g.,
Bring your existing Python project into this template:
python tools/pyproject_template/migrate_existing_project.py --target /path/to/your/projectThe script backs up existing files, copies template tooling/workflows/configs, and prints a summary. After running, complete the migration by configuring placeholders, moving your code, and merging dependencies.
π See Migration Guide for the complete step-by-step checklist.
Already using this template? Stay in sync with improvements:
python tools/pyproject_template/check_template_updates.pyThis compares your project against the latest template and shows what's changed.
π See Keeping Up to Date for the update workflow.
Production Release (PyPI):
doit releaseThis automated task will:
- Calculate the next version based on conventional commits.
- Update
CHANGELOG.md, merging any pre-release entries (commitizen--merge-prerelease). - Create a git tag (e.g.,
v1.0.0). - Push commits and tags to GitHub, triggering the
releaseworkflow.
Development/Pre-release (TestPyPI):
doit release_dev # Defaults to alpha
doit release_dev --type beta # Specify type (alpha, beta, rc)This automated task will:
- Bump the version to the next pre-release (e.g.,
v1.0.0-alpha.1). - Update
CHANGELOG.mdfor the prerelease. - Create a prerelease git tag (e.g.,
v1.0.0-alpha.1). - Push to GitHub, triggering the
testpypiworkflow.
This project uses direnv for automatic environment management. After setup:
.envrc(committed) contains project defaults and is loaded automatically.envrc.local(git-ignored) is for personal overrides and credentials- Environment variables are set automatically when you enter the project directory
- Virtual environment is activated automatically
If you prefer not to use direnv:
# Create virtual environment and activate it
uv venv
source .venv/bin/activate
# Set environment variables manually
export UV_CACHE_DIR="$(pwd)/tmp/.uv_cache"
# Install dependencies
uv sync --all-extras --devView all available tasks:
doit list# Testing
doit test # Run tests (parallel execution with pytest-xdist)
doit coverage # Run tests with coverage report
# Code Quality
doit format # Format code with ruff
doit lint # Run linting
doit type_check # Run type checking with mypy
doit check # Run ALL checks (format, lint, type check, test)
# Security
doit security # Run security scan with bandit
doit audit # Run dependency vulnerability audit
doit spell_check # Check for typos with codespell
doit licenses # Check licenses of dependencies
# Code Formatting
doit fmt_pyproject # Format pyproject.toml with pyproject-fmt
# Version Management (Commitizen)
doit commit # Interactive commit with conventional format
doit release # Production release (commitizen-driven)
doit release_dev # Pre-release/TestPyPI (commitizen-driven)
# Documentation
doit docs_serve # Serve docs locally with live reload
doit docs_build # Build documentation site
doit docs_deploy # Deploy docs to GitHub Pages
# Maintenance
doit cleanup # Clean build artifacts and caches
doit update_deps # Update dependencies and run testsSee the Usage Guide for comprehensive documentation of all development workflows.
# Run all tests (parallel execution - fast!)
doit test
# Run with coverage
doit coverage
# View coverage report
open tmp/htmlcov/index.html
# Advanced: Run specific test directly
uv run pytest tests/test_example.py::test_version -vThis project includes comprehensive tooling:
- uv - Fast Python package installer and dependency manager
- ruff - Extremely fast Python linter and formatter
- mypy - Static type checker with strict mode
- pytest - Testing framework with parallel execution (pytest-xdist)
- bandit - Security vulnerability scanner
- codespell - Spell checker for code and documentation
- pip-audit - Dependency vulnerability auditor
- pip-licenses - License compliance checker
- pre-commit - Git hooks for automated quality checks
- pyproject-fmt - Keep pyproject.toml formatted and organized
- commitizen - Enforce conventional commit message standards
- MkDocs - Documentation site generator
- mkdocs-material - Material Design theme for MkDocs
Run all quality checks:
doit checkInstall hooks to run checks automatically before each commit:
doit pre_commit_installHooks include:
- Code formatting (ruff)
- Type checking (mypy)
- Security scanning (bandit)
- Spell checking (codespell)
- YAML/TOML validation
- Trailing whitespace removal
- Private key detection
This project includes configuration for AI coding assistants (Claude Code, Gemini CLI, Codex).
Important: GitHub CLI (
gh) is required for AI-assisted workflows.Many
doittasks useghfor issue creation, PR management, and repository operations. Install and authenticate before using AI agents:# Install (macOS) brew install gh # Install (Linux) - see https://github.com/cli/cli/blob/trunk/docs/install_linux.md # Authenticate gh auth login
- AGENTS.md - Instructions and protocols for AI agents
- Dangerous command blocking - Hooks prevent destructive operations (force push to main, branch deletion, etc.)
- Workflow automation -
doit issueanddoit prfor GitHub operations
See AI Agent Setup and AI Command Blocking for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and checks (
doit check) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CHANGELOG.md for release history.
This project is licensed under the MIT License - see the LICENSE file for details.
- Add acknowledgments here