Make sure that you have an account on both PyPI (https://pypi.org/) and TestPyPI (https://test.pypi.org/). Obtain API keys for both (from https://pypi.org/manage/account/ and https://test.pypi.org/manage/account/).
Create .pypirc
in the user directory, ~
on Linux and %USERDIR%
on Windows, with the following format
[pypi]
username = __token__
password = pypi_api_token
[testpypi]
username = __token__
password = testpypi_api_token
Run pip install -r requirements.publish.txt
.
Check that the long description will render correctly on PyPI by running twine check dist/*
or tox r -m testpackage
.
Publish to TestPyPI by running tox r -m testpublish
, or twine upload -r testpypi dist/*
. Remember if using the latter to include -r testpypi
to avoid uploading to the production PyPI.
Note that once a package of a specific version has been uploaded, no revisions can be made to that version, even on TestPyPI. To get around this, before uploading to TestPyPI, edit the version number with some dummy text, such as by appending .devn
for some integer n, and regenerate the packages.
If the version number was edited above, revert it to the actual version number, then regenerate the packages.
Run twine upload dist/*
or tox r -m publish
.
Warning: Once a package of a specific version has been uploaded, no revisions can be made to that version. Any further changes can only be made by increasing the version number.