Skip to content

Template Summary

What's Been Created

A modern, comprehensive cookiecutter template for Python packages with:

📁 Template Structure

cookiecutter-python-package/
├── cookiecutter.json              # Template configuration with 25+ options
├── README.md                      # Comprehensive documentation
├── docs/                          # Complete documentation site
├── requirements-dev.txt           # Development dependencies
├── hooks/
│   └── post_gen_project.py        # Post-generation cleanup script
├── tests/
│   └── test_template.py           # Template validation tests
└── {{cookiecutter.project_slug}}/  # Generated project structure
    ├── src/{{cookiecutter.project_slug.replace('-', '_')}}/
    │   ├── __init__.py
    │   ├── core.py                 # Main functionality
    │   ├── cli.py                  # CLI interface (Typer/Click/Argparse)
    │   └── py.typed               # Type checking marker
    ├── tests/
    │   ├── __init__.py
    │   ├── test_core.py           # Core tests
    │   └── test_cli.py            # CLI tests
    ├── docs/                      # Documentation
    ├── .github/
    │   ├── workflows/
    │   │   ├── ci.yml             # CI/CD pipeline
    │   │   └── release.yml        # Automated releases
    │   └── dependabot.yml         # Dependency updates
    ├── pyproject.toml             # Modern Python packaging
    ├── README.md                  # Project documentation
    ├── LICENSE                    # License file (multiple options)
    ├── .gitignore                 # Git ignore patterns
    ├── .pre-commit-config.yaml    # Pre-commit hooks
    ├── Makefile                   # Development tasks
    ├── tox.ini                    # Multi-version testing
    ├── noxfile.py                 # Task automation
    ├── mkdocs.yml                 # Documentation config
    ├── Dockerfile                 # Container support
    └── MANIFEST.in                # Package manifest

🛠️ Modern Tools Included

Category Tools Purpose
Package Management uv, pip Ultra-fast package installation and resolution
Packaging pyproject.toml, src layout Modern Python packaging (PEP 621)
Code Quality Ruff, MyPy, Bandit Fast linting, type checking, security
Testing pytest, Coverage Modern testing framework with coverage
Automation pre-commit, GitHub Actions Quality gates and CI/CD
Security Bandit, Safety, Dependabot Vulnerability scanning and updates
Documentation MkDocs/Sphinx Professional documentation
CLI Typer/Click/Argparse Command-line interfaces
Development Tox, Nox, Make Multi-environment testing and tasks

🎯 Key Features

  1. Fully Optional: Every tool can be enabled/disabled
  2. Educational: Comprehensive documentation explaining each tool's importance
  3. Modern: Uses latest Python packaging standards (PEP 621)
  4. Secure: Built-in security scanning and best practices
  5. Automated: CI/CD pipelines and pre-commit hooks
  6. Flexible: Multiple CLI options, documentation systems
  7. Production-Ready: Industry best practices included

🚀 Usage

# Install cookiecutter
pip install cookiecutter

# Generate project
cookiecutter https://github.com/s-celles/cookiecutter-python-package.git

# Follow prompts to configure your package

💡 Why This Template?

  • Saves hours of setup time
  • Incorporates best practices from the Python community
  • Educational - learn modern Python development
  • Scalable - works for small scripts to large packages
  • Team-friendly - consistent standards and automation
  • Future-proof - uses modern, well-supported tools

🔄 Compared to cookiecutter-pypackage

Feature Old Template This Template
Configuration setup.py pyproject.toml (PEP 621)
Documentation reStructuredText Markdown
Linting flake8 Ruff (10-100x faster)
Formatting Manual Ruff (automated)
Type Checking None MyPy (optional)
Security None Bandit + Safety
CLI Options Limited Typer/Click/Argparse
Package Manager pip only uv + pip support
CI/CD Travis GitHub Actions
Automation Limited pre-commit + extensive automation

🎯 Template Philosophy

This template follows modern Python development principles:

  • Convention over Configuration: Sensible defaults that work out of the box
  • Progressive Enhancement: Start simple, add complexity as needed
  • Developer Experience: Tools that make development faster and more enjoyable
  • Security by Default: Built-in security scanning and best practices
  • Community Standards: Uses widely adopted tools and practices

📊 Template Metrics

  • 25+ Configuration Options: Highly customizable
  • 15+ Modern Tools: Best-in-class Python development tools
  • 3 CLI Frameworks: Typer, Click, Argparse support
  • 2 Documentation Systems: MkDocs and Sphinx
  • Cross-Platform: Windows, macOS, Linux support
  • Python 3.9+: Modern Python version support

🎊 Ready to Use!

The template is complete and ready for production use. It includes everything needed for modern Python package development with optional components for teams of any size.

Generated Project Features

Core Structure

  • Source layout (src/ directory) for better import isolation
  • Type hints throughout with py.typed marker
  • Modern pyproject.toml configuration (PEP 621)
  • Comprehensive .gitignore with Python-specific patterns

Quality Assurance

  • Automated testing with pytest and fixtures
  • Code coverage reporting with HTML/XML output
  • Linting and formatting with Ruff (ultra-fast)
  • Type checking with MyPy (optional)
  • Security scanning with Bandit and Safety

Development Workflow

  • Pre-commit hooks for quality gates
  • GitHub Actions for CI/CD
  • Dependabot for dependency updates
  • Make/Nox/Tox for task automation

CLI Applications

  • Entry point configuration in pyproject.toml
  • Argument parsing with Typer, Click, or Argparse
  • Built-in testing for CLI commands
  • Version information and help text

Documentation

  • Professional docs with MkDocs or Sphinx
  • README templates with badges and examples
  • CHANGELOG following Keep a Changelog format
  • Contributing guidelines for open source projects

Deployment

  • Docker support with multi-stage builds
  • PyPI publishing workflows
  • Semantic versioning with automated releases
  • Development containers for VS Code

This comprehensive template ensures your Python package follows modern best practices from day one!