Publishing Python Package to PyPI with Poetry
Table of Contents
Publishing Python Package to PyPI Using Poetry
Publishing to Test PyPI
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry publish -r test-pypi -u <username> -p <password>
The commands here are for authentication without 2FA enabled, so you can use the -u
and -p
flags to pass in your username and password.
Publishing to PyPI
However, if you have activated the 2FA, you need to use the API token to authenticate (you should be given when you registered the project in PyPI). Then, configure the token with the following command, and then publish to PyPI.
Note that poetry build
your project.
poetry config pypi-token.pypi <my-token>
poetry publish