Use PyPI to distribute Python packages

This procedure is for PyPI Warehouse.

Assuming a Python package named “myprogram”, have a directory structure like


A minimal pyproject.toml is all that’s required for a PyPI Python package. The package “version” number must be distinct for each release, or PyPI will prevent upload.

Ensure prereqs are installed:

pip install --upgrade twine build

One-time setup: sign up for a PyPI account. Create ~/.pypirc with the PyPI token.

In the project directory, create the package:

python -m build

Upload the package to PyPI:

python -m twine upload dist/*

Now the package is live to the world on PyPI, installable via pip install.