|
2 | 2 | [](https://example-package-samuelhomberg.readthedocs.io/en/latest/?badge=latest) |
3 | 3 |
|
4 | 4 |
|
5 | | -# A testing project |
| 5 | +# A project to teach myself how to publish python packages |
6 | 6 |
|
| 7 | +Using the following tools: |
| 8 | +- Testing: [pytest](https://docs.pytest.org/en/8.0.x/index.html) |
| 9 | +- Building: [flit](https://flit.pypa.io/en/stable/) |
| 10 | +- Documentation: [sphinx](https://www.sphinx-doc.org/en/master/index.html), [readthedocs](https://about.readthedocs.com/) |
| 11 | +- Publishing: [TestPyPi](https://test.pypi.org/), Github Actions |
| 12 | + |
| 13 | +Inspired by projects from [Marvin Friede](https://github.com/marvinfriede/template-python-project) and [Martin Buttenschoen](https://github.com/maabuu/posebusters/). |
| 14 | + |
| 15 | +## Configuration |
| 16 | + |
| 17 | +The most important configuration options for everything are found in the [pyproject.toml](pyproject.toml)-file. |
| 18 | + |
| 19 | +## Example code and tests |
| 20 | + |
| 21 | +Following convention, the code for the package **example_package_samuelhomberg** lives at [src/example_package_samuelhomberg/](src/example_package_samuelhomberg) and the corresponding tests at [test/](test). |
| 22 | +Whyle pytest is used for testing, the actual tests are written using the unittest package. The code and tests are of no further importance. |
| 23 | + |
| 24 | +## Documentation |
| 25 | + |
| 26 | +The documentation is configured (path to code, theme, logo and favicon, ...) in [docs/source/conf.py](docs/source/conf.py). |
| 27 | + |
| 28 | +Documentation was written using [sphinx](https://www.sphinx-doc.org/en/master/index.html) and the project the registered at [readthedocs](https://about.readthedocs.com/) for automatically updating documentation. |
| 29 | + |
| 30 | +## Building and manual publishing |
| 31 | + |
| 32 | +I followed [this guide](https://packaging.python.org/en/latest/tutorials/packaging-projects/) to build a package and manually uploaded it to PyPi (or in this case, only to TestPyPi). |
| 33 | +The building backend [flit](https://flit.pypa.io/en/stable/) relies on the configuration in [pyproject.toml](pyproject.toml) and can dynamically load the version number and short project description. |
| 34 | + |
| 35 | +## Automated Testing, Publishing and Releasing |
| 36 | + |
| 37 | +The workflows configuring the github actions are found in [.github/workflows/](.github/workflows/). |
| 38 | + |
| 39 | +### Automated Testing |
| 40 | + |
| 41 | +This is done using the [test.yml](.github/workflows/test.yml) workflow. |
| 42 | +As of now, the tests are not really automated but manually triggered (see [Future Improvements](#future-improvements)). |
| 43 | + |
| 44 | +### Automated Building, Publishing and Releasing |
| 45 | + |
| 46 | +This is done using the [publish_release.yml](.github/workflows/publish_release.yml) workflow, which is heavily based on the [guide found here](https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/). |
| 47 | +This workflow is also manually triggered. To still have version numbers for the GitHub Release, [get_version.py](get_version.py) script saves a file with the version, which can is used in the workflow. |
| 48 | +As before, it would be better to switch to a tagged release scheme (see [Future Improvements](#future-improvements)). |
| 49 | + |
| 50 | +## Future Improvements |
| 51 | + |
| 52 | +- **Instead of using manually controlled workflows (`workflow_dispatch`), it would be better to have a complete [build -> test -> publish -> release] workflow tied to [tagged commits](https://git-scm.com/book/en/v2/Git-Basics-Tagging), as in [this example](https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/) using `${{ github.ref_name }}`.** However, automatic releases apparently create tags with version numbers. |
| 53 | +--- |
| 54 | +- Linting with [ruff](https://github.com/astral-sh/ruff) |
| 55 | +- [codecov](https://about.codecov.io/) |
| 56 | +- ... |
| 57 | +- (more fancy badges?) |
0 commit comments