Build & Publish a Python Package
2025-11-29 17:36:46
Build
Prepare setup.py
An example:
1 | from setuptools import find_packages, setup |
If you have previous build, remember to clean them up by
1 | rm -rf dist build *.egg-info |
run
1 | python -m build # recommended, requires "build" package |
(optional) to test package locally
1 | pip install . |
Publish
Setup info on test.pypi or pypi if not yet. The API key for publishing can be found there.
check:
1 | twine check dist/* # requires "twine" package |
publish to test.pypi:
1 | twine upload -r testpypi dist/* |
publish to pypi:
1 | twine upload dist/* |
For more detail check Youtube tutorial