Skip to content

SamuelHomberg/packaging_tutorial

Repository files navigation

.github/workflows/test Documentation Status

A project to teach myself how to publish python packages

Using the following tools:

Inspired by projects from Marvin Friede and Martin Buttenschoen.

Configuration

The most important configuration options for everything are found in the pyproject.toml-file.

Example code and tests

Following convention, the code for the package example_package_samuelhomberg lives at src/example_package_samuelhomberg/ and the corresponding tests at test/. Whyle pytest is used for testing, the actual tests are written using the unittest package. The code and tests are of no further importance.

Documentation

The documentation is configured (path to code, theme, logo and favicon, ...) in docs/source/conf.py.

Documentation was written using sphinx and the project the registered at readthedocs for automatically updating documentation.

Building and manual publishing

I followed this guide to build a package and manually uploaded it to PyPi (or in this case, only to TestPyPi). The building backend flit relies on the configuration in pyproject.toml and can dynamically load the version number and short project description.

Automated Testing, Publishing and Releasing

The workflows configuring the github actions are found in .github/workflows/.

Automated Testing

This is done using the test.yml workflow. As of now, the tests are not really automated but manually triggered (see Future Improvements).

Automated Building, Publishing and Releasing

This is done using the publish_release.yml workflow, which is heavily based on the guide found here. This workflow is also manually triggered. To still have version numbers for the GitHub Release, get_version.py script saves a file with the version, which can is used in the workflow. As before, it would be better to switch to a tagged release scheme (see Future Improvements).

Future Improvements

  • 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, as in this example using ${{ github.ref_name }}. However, automatic releases apparently create tags with version numbers.