Python Standards & References
This page provides links to important Python standards, PEPs (Python Enhancement Proposals), and official documentation that guide the design and configuration of this cookiecutter template.
๐ Official Documentation
Python Packaging Authority
- Python Packaging Guide: https://packaging.python.org/en/latest/
- Official Python packaging documentation
- Best practices for package distribution
- Modern packaging workflows
- Tool recommendations and tutorials
๐ง Configuration Standards
Python Enhancement Proposals (PEPs)
PEP 621 - Project Metadata in pyproject.toml
- Link: https://peps.python.org/pep-0621/
- Purpose: Standardizes how to specify project metadata in
pyproject.toml
- Impact: This template uses PEP 621 for all package metadata configuration
- Benefits:
- Single source of truth for project information
- Better tool interoperability
- Simplified configuration management
PEP 518 - Build System Requirements
- Link: https://peps.python.org/pep-0518/
- Purpose: Specifies how to declare build system requirements
- Impact: Enables modern build tools and dependency management
- Benefits:
- Reproducible builds
- Better dependency isolation
- Support for modern build backends
PEP 484 - Type Hints
- Link: https://peps.python.org/pep-0484/
- Purpose: Introduces syntax for type hints in Python
- Impact: Foundation for static type checking with MyPy
- Benefits:
- Early bug detection
- Better IDE support
- Improved code documentation
Related PEPs
PEP 517 - Build System Interface
- Link: https://peps.python.org/pep-0517/
- Purpose: Standard interface between build frontends and backends
- Impact: Enables modern packaging tools like uv and pip
PEP 440 - Version Identification
- Link: https://peps.python.org/pep-0440/
- Purpose: Standardizes version numbering for Python packages
- Impact: Ensures consistent versioning across the ecosystem
PEP 508 - Dependency Specification
- Link: https://peps.python.org/pep-0508/
- Purpose: Standard format for dependency specifications
- Impact: Used in
pyproject.toml
for declaring dependencies
๐๏ธ Project Structure Standards
Build Backends
- setuptools: https://setuptools.pypa.io/ - Traditional, mature Python build system
- hatchling: https://hatch.pypa.io/ - Modern, fast build backend
- flit: https://flit.pypa.io/ - Simple build backend for pure Python packages
- pdm: https://pdm-project.org/ - Modern dependency management and build backend
src Layout
- Reference: Python Packaging Guide - src layout
- Why adopted:
- Better import testing
- Cleaner package structure
- Prevents accidental imports during development
Modern Configuration Files
pyproject.toml
- Standard: PEP 518, PEP 621
- Purpose: Central configuration file for Python projects
- Contains:
- Project metadata (PEP 621)
- Build system requirements (PEP 518)
- Tool configurations (Ruff, MyPy, pytest, etc.)
๐ Security Standards
Supply Chain Security
- SLSA Framework: https://slsa.dev/
- OpenSSF Best Practices: https://bestpractices.coreinfrastructure.org/
- Python Security Guidelines: https://python.org/dev/security/
๐งช Testing Standards
pytest
- Documentation: https://docs.pytest.org/
- Why chosen: Industry standard for Python testing
- Features: Fixtures, parametrization, plugins
Coverage
- Documentation: https://coverage.readthedocs.io/
- Standard: Measure and report test coverage
- Integration: Works seamlessly with pytest
๐ Code Quality Standards
Style Guides
- PEP 8: https://peps.python.org/pep-0008/ - Style Guide for Python Code
- Black Code Style: https://black.readthedocs.io/en/stable/the_black_code_style/
- Google Python Style Guide: https://google.github.io/styleguide/pyguide.html
Linting Standards
- Ruff Rules: https://docs.astral.sh/ruff/rules/
- flake8 Error Codes: https://flake8.pycqa.org/en/latest/user/error-codes.html
๐ CI/CD Standards
GitHub Actions
- Documentation: https://docs.github.com/en/actions
- Python specific: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
Dependabot
- Documentation: https://docs.github.com/en/code-security/dependabot
- Purpose: Automated dependency updates and security alerts
๐ Why These Standards Matter
For Individual Developers
- Consistency: Standard practices across projects
- Quality: Proven best practices reduce bugs
- Learning: Following standards improves skills
- Tooling: Better IDE and tool support
For Teams
- Onboarding: New team members know what to expect
- Collaboration: Shared understanding of project structure
- Maintenance: Easier to maintain and update projects
- Reviews: Consistent standards improve code review process
For the Ecosystem
- Interoperability: Tools work better together
- Innovation: Standards enable new tool development
- Adoption: Easier to adopt new technologies
- Community: Shared practices strengthen the Python community
๐ Staying Current
How to Keep Updated
- Follow PEP updates: https://peps.python.org/
- Python Packaging Guide: Regularly updated with best practices
- Tool documentation: Follow changelog and release notes
- Community discussions: Python forums, Reddit, Discord
- Conferences: PyCon talks often cover new standards
Template Updates
This cookiecutter template is regularly updated to reflect: - New Python standards and PEPs - Updated tool recommendations - Security best practices - Community feedback and contributions
By following these standards, projects generated from this template are: - โ Future-proof: Based on official Python standards - โ Tool-compatible: Works with the entire Python ecosystem - โ Maintainable: Easy to understand and update - โ Professional: Follows industry best practices