Python Packaging
Local Test
Install: pip install .
Python Packaging
Official and detailed guide can be found here and here, and a sample can be found here.
A simple guide is:
- Prepare
__init__.py
- Prepare
setup.py
- Buide distribution:
python setup.py sdist bdist_wheel
- Upload to TestPyPI:
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
- Upload to PyPI:
twine upload dist/*
Update Package
When you modify the code and want to release a new version:
- Change the version number in
setup.py
- Build distribution
- Upload to TestPyPI
- Upload to PyPI
Note that only upload the new version in dist/
but not dist/*
, otherwise an error will occur with “File already exists” since the old version has been uploaded and TestPyPI and PyPI do not permit repeated uploading (even the old version is deleted).