Publishing a Python Distribution Package in a Repository: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 20: Line 20:


More details: {{Internal|Pyproject.toml#Overview|<tt>pyproject.toml</tt>}}
More details: {{Internal|Pyproject.toml#Overview|<tt>pyproject.toml</tt>}}
==Create the Distribution Archives==
<syntaxhighlight lang='bash'>
./.venv/bin/python -m pip install --upgrade build
</syntaxhighlight>

Revision as of 02:48, 6 April 2024

External

Internal

Overview

Procedure

Create the Project Layout

The project is aimed at publishing a Python package, which contains a library. The layout and required initialization work is described here:

Python Project Layout

Since we're aiming at publishing a library, the package will probably need an __init__.py but not a __main__.py.

Choose a Build Backend

Tools like pip or build do not convert the source into a distribution packages, they're just build frontends that delegate the process to a build backend. Several build backends are available, this example uses Hatchling.

Create pyproject.toml

More details:

pyproject.toml

Create the Distribution Archives

./.venv/bin/python -m pip install --upgrade build