The last thing one knows in constructing a work is what to put first.
- Blaise Pascal
Creating a new project from scratch is always frustrating because you have to setup for the hundredth time the same structure, often by copy pasting another project and renaming things.
This cookiecutter is here to help you lay a base structure for all of your python packages projects.
This template target is a GitHub Open Source Python library/CLI. I believe with a few tweaks you could adapt it for other uses, and if asked it may be included in the template depending on the maintenance workload implied.
- Python >= 3.10
- Simple package with
clickCLI uvpackage manager- Build-backend with
hatchling, resolve version with VCS tags - Code linting and formatting with
ruff - Type checking with
mypy - Testing with
pytestandtox - Docs with Material for MkDocs, versioned with
mike - Git hooks with
pre-commit/prek - Makefile to easily manage the project's lifecycle
- GitHub issue/merge requests templates
- GitHub action for docs, test, and release workflows
- Contributing guidelines, Code of Conduct.
I recommend using uv.
uv tool install cookiecutterYou could also use pipx.
pipx install cookiecutterGo to the parent directory of where you want to create your project and run:
cookiecutter <this-cookiecutter-path>You may want to generate the project at another location:
cookiecutter <this-cookiecutter-path> -o <project-parent-dir>The generator (cookiecutter) will ask you for some inputs.
The input variables, with their default values (some auto generated) are:
project_name: name of the projectproject_slug: slug of the project, lower-case and hyphen-stylepython_min: minimum version of Python required, by default "3.10"pkg_name: python-friendly name of the package. By default, based on the project nameversion: choose how the package version is resolved- Use the Version Control System, like tags from Git.
- In
pyproject.tomluse the fieldproject.version
description: project single-line descriptionauthor: author firstname and lastnameemail: author emaillicense: choice of open source licensecopyright_year: year of the copyright, current year by defaultcli: whether to create CLI or notprecommit_push_test: whether to run tests before git push or notprecommit_push_docs: whether to generate docs before git push or notgit_branch: git default branch (Examples: main, master)git_user: git usernamegit_init: whether to init the git repository or not
Cookiecutter - Python Package is licensed under the MIT license. A copy of this license is provided in the LICENSE file.