How to upload your Python package to PyPI in 30 seconds

Prerequisite: Install twine:

sudo pip3 install twine

Before the next step, ensure you have no uncommitted files, because those will be deleted!

Also, ensure that your package is ready for release. Ensure that you have the correct version listed in setup.py

sudo chown -R $USER: . # Fix permission issues introduced by sudo python3 setup.py install
git clean -xdf # Remove uncommitted files and other fuzz
python3 setup.py sdist # Build source package
twine upload dist/* # This will ask you for user PyPI username and password and then upload the package.

Variant if you don’t have python3:

sudo chown -R $USER: . # Fix permission issues introduced by sudo python3 setup.py install
git clean -xdf # Remove uncommitted files and other fuzz
python setup.py sdist # Build source package
twine upload dist/* # This will ask you for user PyPI username and password and then upload the package.

For more detailed instructions see this post.