Skip to content

gemmadanks/python-project-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Python Project Template

Python Version from PEP 621 TOML codecov CI release-please Docs (GitHub Pages) Docs (RTD) Dependabot uv Ruff Conventional Commits License

A comprehensive, opinionated template for modern Python projects -- featuring uv packaging, Ruff for linting and formatting, justfile, pytest testing with code coverage upload to codecov, MkDocs documentation with configuration for Read The Docs, pre-commit hooks, .editorconfig, .devcontainer, GitHub Actions CI, GitHub issue and pull request templates, architectural decision record (ADR) templates and automated semantic releases.

The goal is to help you start writing code immediately without having to spend time deciding what tools or conventions to use.

How to use this template

  1. 🌱 Create a New Repository on GitHub
    1. Click "Use this template".
    2. Choose β€œCreate a new repository”.
    3. Pick a name for your new project (for example, my-awesome-package).
    4. Clone your new repo locally
  2. 🏑 Customise the repository
    1. Rename your package directory cd src; mv package_name my_package
    2. Update pyproject.toml with your package name, author, and description.
    3. Update all references to package_name in:
    4. Update the "package-name" field in release-please-config.json with your package name for automatically bumping the version number in uv.lock (see release-please issue #2561).
    5. Customise this README with a description of your project and planned features.
    6. Customise the documentation configuration in mkdocs.yml (see the Material for MkDocs documentation for details)
    7. Clear the CHANGELOG.
    8. Enable automated releases by permitting GitHub Actions to open PRs (Settings -> Actions -> Workflow permissions) and add an initial commit hash to bootstrap the release-please in .release-please-manifest.json.
    9. Enable publishing to GitHub Pages (Settings -> Pages) and/or add your project to RTD.

πŸš€ Features

πŸ“¦ Installation

Working in a development container

A Dockerfile and configuration in ./devcontainer can be used in VSCode or GitHub Codespaces to work in a pre-configured development environment. It uses a Python 3.14 base image and installs uv, just and all Python dependencies.

To open the project in the container VSCode, you will need to add the Dev Containers extension and download Docker (or Podman -- and configure VSCode to use podman instead of Docker) -- see the VSCode tutorial on devcontainers for more details on using devcontainers. Then run:

Dev Containers: Reopen in Container

Manual installation

  1. Install uv
  2. Clone and install the project using uv:
git clone https://github.com/gemmadanks/python-project-template
cd python-project-template
uv sync --all-groups
  1. Install just.
  2. Install pre-commit hooks (only needs to be done once)
just pre-commit-install

Hook definitions: .pre-commit-config.yaml

🏁 Quickstart

from package_name.greet import say_hello
print(say_hello("World"))

πŸ§ͺ Common Tasks

Several common tasks have been added as recipes to a justfile in the root of the repository:

just install               # uv sync
just test                  # run quick (non-slow) tests
just test-notebooks
just lint                  # ruff check
just format                # ruff format
just type-check            # pyright type-check
just docs-serve            # live docs
just docs-build            # build docs
just pre-commit            # run all pre-commit hooks
just clean                 # remove generated files and folders

πŸ“š Documentation

πŸ”„ Releases

Managed by release-please: (conventional commits drive semantic versioning and an autogenerated CHANGELOG). - Configuration: .github/release-please-config.json - Version source: pyproject.toml

πŸ“‚ Project Structure

.
β”œβ”€β”€ src/
β”‚   └── package_name/              # Source package
β”‚       β”œβ”€β”€ __init__.py
β”‚       └── greet.py               # Example module (replace with real code)
β”œβ”€β”€ tests/                         # Test suite
β”‚   β”œβ”€β”€ conftest.py
β”‚   └── unit/
β”‚       └── test_greet.py          # Example unit test (replace with real tests)
β”œβ”€β”€ docs/                          # Documentation (DiΓ‘taxis layout)
β”‚   β”œβ”€β”€ index.md                   # Documentation homepage
β”‚   β”œβ”€β”€ tags.md                    # Tag index
β”‚   β”œβ”€β”€ reference/
β”‚   β”‚   └── index.md               # API reference (mkdocstrings)
β”‚   β”œβ”€β”€ tutorials/
β”‚   β”‚   └── index.md               # Tutorials overview
β”‚   β”œβ”€β”€ how-to/
β”‚   β”‚   └── index.md               # How-to guides
β”‚   β”œβ”€β”€ explanation/
β”‚   β”‚   └── index.md               # Conceptual guides
β”‚   └── architecture/
β”‚       β”œβ”€β”€ index.md               # Architecture overview
β”‚       └── adr/                   # Architectural decision records
β”‚           β”œβ”€β”€ index.md           # ADRs index
β”‚           β”œβ”€β”€ template.md        # Template for new ADR
β”‚           β”œβ”€β”€ 001-use-architectural-decision-records.md
β”‚           └── 002-manage-dependencies-with-uv.md
β”œβ”€β”€ notebooks/                     # Jupyter notebooks
β”‚   └── example.ipynb
β”œβ”€β”€ .github/
β”‚   β”œβ”€β”€ workflows/
β”‚   β”‚   β”œβ”€β”€ ci.yaml                # Lint / test / build
β”‚   β”‚   └── release-please.yaml    # Automated releases
β”‚   β”œβ”€β”€ ISSUE_TEMPLATE/            # Issue forms
β”‚   β”‚   β”œβ”€β”€ 01-bug.yml
β”‚   β”‚   └── 02-feature.yml
β”‚   β”œβ”€β”€ pull_request_template.md   # Pull request template
β”‚   └── dependabot.yml             # Dependency update automation
β”œβ”€β”€ .pre-commit-config.yaml        # Pre-commit hook definitions
β”œβ”€β”€ .devcontainer/                 # Dev container configuration
β”‚   β”œβ”€β”€ devcontainer.json
β”‚   └── Dockerfile
β”œβ”€β”€ pyproject.toml                 # Project metadata + dependencies (uv)
β”œβ”€β”€ uv.lock                        # Locked dependency versions (uv)
β”œβ”€β”€ README.md                      # Project overview (you are here)
β”œβ”€β”€ mkdocs.yml                     # MkDocs configuration
β”œβ”€β”€ CITATION.cff                   # Citation metadata
β”œβ”€β”€ LICENSE                        # License
β”œβ”€β”€ CHANGELOG.md                   # Generated by release-please (post-release)
β”œβ”€β”€ .release-please-manifest.json  # Release-please state
β”œβ”€β”€ release-please-config.json     # Release-please configuration
β”œβ”€β”€ .python-version                # pyenv version pin
β”œβ”€β”€ justfile                       # justfile containing recipes for common tasks
β”œβ”€β”€ .editorconfig                  # Ensures consistent code style across editors
└── .gitignore

Note that while it is common practice to keep the config files at the root of the repository, and this is what I recommend, it is possible to customise the location of some of them if you prefer (e.g. the path to release-please-config.json [can be specified in the release-please.yaml file for the GitHub action] (https://github.com/googleapis/release-please-action?tab=readme-ov-file#advanced-release-configuration) and the path to the mkdocs.yaml can be configured using the --config-file option and setting the path in the .readthedocs.yaml file.)

🀝 Contributing

Use conventional commit messages (feat:, fix:, docs:, etc.). Ensure:

  • Lint & format clean
  • Tests pass
  • Docs build without warnings
  • ADR drafted for architecturally significant changes

Suggestions and improvements to this template are very welcome β€” feel free to open an issue or pull request if you spot something that could be refined, added or removed.

πŸ“– Citation

If used in research, cite via CITATION.cff.

πŸ›‘ License

BSD-3-Clause – see LICENSE.

Happy coding! πŸš€

About

An opinionated template for modern Python projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •