Mini-tutorial for python packaging, release and publish
Abstract
This mini-tutorial is a beginner's cheatsheet to python packaging. Check Python packaing user guide for an authoritative guidance on the topic.
Classical way
It is good practice to setup an isolated and clean environment e.g. with standard library venv
. After that,
-
install packages for building wheels and source distributions:
-
create
setup.py
where one can specify the requirements and meta-data: -
actually create wheels and source distribution:
Alternatively, with uv
uv
is a modern python dev tool, see features
and
install guide.
It is compliant with PEP 517 1, PEP 518 2.
Use the project interface of uv
to init project and add dependencies.
then
Create a tag and release
This will create a tag named "v0.1.0" with the message "release message". The distribuion files will be displayed as assets for the tag.
Publish
Publish to pypi index requires the developer to setup an account and get the API token. Using uv
, run this
with the dev's API token in place of TOKEN.
-
why
pyproject.toml
? https://peps.python.org/pep-0518/ ↩ -
understand build frontend, build backend. https://peps.python.org/pep-0517 ↩