A modern Python project template that provides a standardized structure for Python development with best practices for dependency management, code quality, and automation.
- Modern Structure: Clear separation between source code, tests, and notebooks
- Package Management: Uses uv for fast, reliable package management
- Dependency Management: Centralized in
pyproject.tomlfollowing PEP 621 - Build Automation: Makefile with common development tasks
- Code Quality: Pre-commit hooks for consistent code quality
- CLI Support: Ready-to-use Click command-line interface
- Testing: Pytest setup with example tests
.
├── Makefile # Build automation
├── pyproject.toml # Project metadata and dependencies
├── README.md # This file
├── src/ # Source code
│ ├── notebooks/ # Jupyter notebooks
│ └── your_package/ # Main package
│ ├── __init__.py
│ └── cli.py # Command-line interface
└── tests/ # Test suite
└── test_cli.py # CLI tests
- Python 3.12+
- uv package manager
Clone this template and install dependencies:
git clone https://github.com/yourusername/python-project-template.git
cd python-project-template
make installFor development setup (includes test dependencies):
make devRun the sample CLI:
your-cli --name "YourName"Or through make:
makeRun tests with:
make test-
Update project information in
pyproject.toml:- Change
name,version,description - Update
authorswith your information - Modify
dependenciesas needed
- Change
-
Rename directories:
- Change
src/your_packageto your actual package name - Update imports in all files
- Change
-
Update CLI:
- Modify
src/your_package/cli.pywith your actual commands - Update
[project.scripts]inpyproject.tomlwith your CLI name
- Modify
This template supports a smooth development workflow:
- Setup:
make devinstalls all dependencies and pre-commit hooks - Development:
- Write code in
src/your_package/ - Create tests in
tests/ - Use notebooks in
src/notebooks/for exploration
- Write code in
- Code Quality: Pre-commit hooks enforce:
- Code formatting with Black
- Import sorting with isort
- Linting with Ruff
- Testing:
make testruns all tests
-
Dependencies:
- Runtime: click
- Development: pytest, ruff, black, isort, pre-commit, ipykernel, ipywidgets
-
Build System: Uses hatchling for package building
-
Python Version: Requires Python 3.12+
To use this template, fork or clone this repository and customize it for your project.