Yesterday I published something to pypi for the first time in a while:
(it's a fake spotipy library for helping write python unit tests without having to actually call Spotify's API)
The Python Package Index (PyPI) is a repository of software for the Python programming language.
Currently, when you search Google for "
publish to pypi", this is the top post:
but it contains some outdated/deprecated information. Much of the information is still useful, like writing your
setup.py file, and registering for accounts on PyPI and PyPI Test, but when it comes to actually publishing, there are a few changes.
This tutorial is actually much better:
Here's the short version/my notes:
You'll need to create a
setup.py file for your project. Here's the one I made yesterday:
You'll need this
twine library to publish.
pip install twine
3. Source distribution
You have to create a source distribution:
python setup.py sdist
It's good to create a wheel for your project, for faster end-user installation (faster than building from source).
For this you'll need
pip install wheel
There are three types of wheels,
Pure Python, and
See the wheels section of the docs for further info on which type you need.
Mine was universal, so I did:
python setup.py bdist_wheel --universal
The article talks about setting up a
$HOME/.pypirc file so you don't have to enter your credentials everytime, but this seems insecure to me, so I skipped it.
To upload your source distribution (and potentially wheels) to Test PyPI:
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
And to go to real PyPI:
twine upload dist/*