Python Package Publishing Notes

programming, Python

Foundations

For the most part, the doc How to Publish an Open-Source Python Package to PyPI – Real Python is what I followed. However, had that been it, I wouldn’t need to write this page.

Refinements

Installing twine by itself isn’t enough; wheel is also required:

pip install wheel
pip install twine

If wheel is not installed, I get this error when trying to build:

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] …]
or: setup.py --help [cmd1 cmd2 …]
or: setup.py --help-commands
or: setup.py cmd --help
error: invalid command 'bdist_wheel'

Test Publishing and Installing

To publish to the test repo:

twine upload --repository-url https://test.pypi.org/legacy/ dist/*

To test installing from the test repo:

pip install -i https://test.pypi.org/simple/ <package name>