<< Back to posts
Publish Python Package on PyPI with Poetry
How to package a Python library using Poetry and publish it on PyPI.
- Add all dependecies to your
pyproject.toml
(fromrequirements.txt
)
poetry add $( cat requirements.txt )
- Build wheel
poetry build
- Publish to Test PyPI
# Optional - only run first time you push
# poetry config repositories.test-pypi https://test.pypi.org/legacy/
# Get an API token from here: https://test.pypi.org/manage/account/token/
export TEST_API_TOKEN='pypi-XXXXXXXXXXXXXX'
poetry publish -r test-pypi -u __token__ -p TEST_API_TOKEN
- Publish to PyPI
# Get an API token from here: https://pypi.org/help/#apitoken
export API_TOKEN='pypi-XXXXXXXXXXXXXX'
poetry publish -u __token__ -p API_TOKEN