|
| 1 | +# Python Project Template |
| 2 | + |
| 3 | +This is a quickstart project template for Python that already comes attached with the following features: |
| 4 | + |
| 5 | +* Packaging and metadata support |
| 6 | +* Formatting and linting via *pre-commit*, *black*, *usort*, and *flake8* |
| 7 | +* Testing via *pytest* |
| 8 | +* CI via github-actions |
| 9 | + |
| 10 | + |
| 11 | +## Configuration |
| 12 | + |
| 13 | +To tailor this template to your needs, the following steps must be taken: |
| 14 | + |
| 15 | +1. Rename the *myproject* package folder to your project name |
| 16 | +2. Change metadata and project name in *setup.cfg*. |
| 17 | +3. Do not forget to change the version attribute to point to your new package name as well. |
| 18 | +4. Add dependencies to *requirements.txt* |
| 19 | +5. Adjust the *LICENSE* file to your liking. |
| 20 | +6. Adjust this *README.md* file to your liking. |
| 21 | + |
| 22 | +### Formatting and linting |
| 23 | + |
| 24 | +Install *pre-commit* and *pytest* via |
| 25 | +``` |
| 26 | +pip install -r ci_requirements.txt |
| 27 | +``` |
| 28 | + |
| 29 | +To format and lint the entire codebase run: |
| 30 | +``` |
| 31 | +pre-commit run --all-files |
| 32 | +``` |
| 33 | + |
| 34 | +To perform this step automatically during each commit (and fail on errors) run: |
| 35 | +``` |
| 36 | +pre-commit install |
| 37 | +``` |
| 38 | + |
| 39 | +### Testing |
| 40 | +To run the tests execute: |
| 41 | +``` |
| 42 | +pytest |
| 43 | +``` |
| 44 | +in the top-level directory. |
| 45 | +Tests can also be executed individually by running them as regular python script. This requires you to add a small main function to them, c.f. *test/test_myproject.py*. |
| 46 | + |
| 47 | +### Github Actions |
| 48 | +This project defines the following workflows: |
| 49 | +1. *run_linting.yml* will run `pre-commit run --all-files` on every push to develop and pull request |
| 50 | +2. *run_tests.yml* will run `pytest` on Windows, Ubuntu, and MacOS on every push to develop and pull_request |
| 51 | +3. *release_public.yml* and *release_test.yml* can be triggered manually to build a wheel distribution and publish it to PyPI or TestPyPI respectively |
| 52 | + |
| 53 | +For the publising to work, you need to add the PyPI API token as Github secrets: |
| 54 | +* *PYPI_TOKEN* for the official PyPI index |
| 55 | +* *TEST_PYPI_TOKEN* for the TestPyPI index |
0 commit comments