My (somewhat opinionated) Python project template
- minimal configuration in setup.py, only setting the required fields
No one cares about PyPi keywords, descriptions etc.
- there is also an example
pyproject.toml
configuration in misc/pyproject.toml
- there is also an example
- uses
pytest
andmypy
(+coverage) for checks - uses
ruff
with some ignore directives to prevent it from being too annoying about the code style - relies on tox for running tests and checks in isolation
- uses Github Actions for CI
- make sure you can run CI against pull requests from other people (
pull_request
trigger) Note that people who fork it need to go to “Actions” tab on their fork and click “I understand my workflows, go ahead and enable them”. - build matrix for multiple python versions
- trying to keep as little as possible in the CI configuration
Because fuck yaml configs and learning yet another templating syntax
- make sure you can run CI against pull requests from other people (
- automatic PyPi deployments on new tags
- see the config
- running CI locally: use =act= (e.g. try with
act -l
)
Run scripts/release to deploy Python package onto PyPi and test PyPi.
The script expects TWINE_PASSWORD
environment variable to contain the PyPi token (not the password!).
The script can be run manually.
It’s also running as pypi
job in Github Actions config. Packages are deployed on:
- every master commit, onto test pypi
- every new tag, onto production pypi
You’ll need to set TWINE_PASSWORD
and TWINE_PASSWORD_TEST
in secrets
for Github Actions deployment to work.