A Python project template with pytest, tox, Sphinx (with sphinx-apidoc and sphinx-argparse), GitHub Actions, GitLab CI, coveralls, Codecov, and several linters including flake8 (with many plugins), Bandit, Black, pyroma, and others.
This template is the basis of my own Python projects, representing my current preferences. I am not advocating for these choices nor this template specifically, although I am happy to discuss or explain any choices made herein. It is being published both for my own convenience and in case it may be useful to others with similar tastes.
import packagename
packagename.foo()- All module sources are in
srcrather than the top-level directory. I was initially against this idea, but was swayed by Ionel Cristian Mărieș' Packaging a python library, Hynek Schlawack's Testing & Packaging, and pytest Good Integration Practices. - Dependencies are declared in
project.dependencies, optional dependencies inproject.optional-dependencies, and development dependencies independency-groups(from PEP 735). Full, exact, hash-checked, known-good dependency versions are stored inrequirements/*.txt. These can be generated usingpip-compilefrom pip-tools or (if hashes are not required)pip install && pip freezein a fresh virtual environment. - tox (used for CI) is configured to use minimally constrained dependencies.
This is desirable for library packages, since user installs are minimally
constrained. If the package will be deployed as an application using
requirements.txt, consider changingrequirements*.intorequirements*.txtintox.inito test using exact dependency versions.
This package can be installed using pip, by running:
pip install python-project-templateimport packagename
packagename.bar(packagename.baz())The project documentation is hosted on Read the Docs. See the CLI documentation for command-line options and usage, and the API documentation for the Python API.
Contributions are welcome and very much appreciated! See the contributing guidelines for recommendations.
This project is available under the terms of the MIT License. See the summary at TLDRLegal
The template upon which this project is based is available under the terms of CC0 1.0 Universal.