This project provides a template from which you can create your own Python packages and projects. It uses modern tools and conventions to ensure a good development experience.
Package structure was inspired by various templates and recommended best practices, such as:
- https://github.com/TezRomacH/python-package-template
- https://github.com/pyscaffold/pyscaffold
- https://github.com/f4str/python-package-template
- https://github.com/audreyfeldroy/cookiecutter-pypackage
- https://github.com/ionelmc/python-nameless
It provides a src directory, under which your own packages sit. Example files for __init__.py, __main__.py and cli.py are already provided.
Tests are placed under the tests directory, and documentation under the docs directory.
To start your new project, you should change its name, URL and metadata details at:
README.mdCHANGELOG.mdsetup.pytests/*.pysrc/*
The .github directory comes with a number of files to configure certain GitHub features.
- Various Issue templates can be found under
ISSUE_TEMPLATE. - A Pull Request template can be found at
PULL_REQUEST_TEMPLATE.md. - Automatically mark issues as stale after a period of inactivity. The configuration file can be found at
.stale.yml. - Keep package dependencies up to date with Dependabot. The configuration file can be found at
dependabot.yml. - Keep Release Drafts automatically up to date with Pull Requests, using the Release Drafter GitHub Action. The configuration file can be found at
release-drafter.ymland the workflow atworkflows/release-drafter.yml. - Automatic package building and publishing when pushing a new version tag to
main. The workflow can be found atworkflows/publish-package.yml.
This package sets up various tox environments for static checks, testing, building and publishing.
It is also configured with pre-commit hooks to perform static checks and automatic formatting.
If you do not use tox, you can build the package with build and install a development version with pip.
Assume cd into the repository's root.
To install the pre-commit hooks:
pre-commit installTo run type checking:
tox -e typecheckTo run linting tools:
tox -e lintTo run automatic formatting:
tox -e formatTo run tests:
toxTo build the package:
tox -e buildTo build the package (with build):
python -m buildTo clean the previous build files:
tox -e cleanTo test package publication (publish to Test PyPI):
tox -e publishTo publish the package to PyPI:
tox -e publish -- --repository pypiTo install an editable version:
pip install -e .