This tutorial starts with a simple module and gradually develops it into a complete Python package. The tutorial covers the following topics:
- use of PYTHONPATH
- role of
__init__.py - the src layout, installation with pip
- README and LICENSE files
- dependency management
- adding a command line client
- documentation: automatic generation and deployment on github pages
- linting with pylint
- tests with pytests
- publication on PyPI, wheel, sdists
- assets
Not all aspects of packaging are covered in this tutorial; in particular, it does not cover the creation of compiled extensions. Furthermore, a choice has been made regarding the tools used (git, github, pylint, pytest, doxygen, etc.), but other choices are perfectly valid.
In addition to this tutorial, a package skeleton has been proposed with other choices regarding tools (it uses gitlab, doxygen and ruff).
Some prerequisites for this tutorial:
- a linux computer with network
- a github acount
- python >= 3.8
- an account on test.pypi.org (and the associated devide for the two factor authentification)
Tutorial begins here.