Python/Managing Packages
Pushing a New Version
1) Install/update required dependencies for uploading to pypi:
pip install --upgrade build pip install --upgrade twine
2) Update all internal project references, regarding current project version. At minimum, this will probably be the files:
- docs/source/conf.py
- pyproject.toml
- setup.cfg
May be additional files to update, depending on the actual project setup and internal documentation.
Ex: If previous version was 1.0.0
and you're uploading a bug fix release, then you might update all references to say 1.0.1
.
3) As an optional step, first merge changes into the main
/master
branch, and push to GitHub/BitBucket/GitLab/etc. Then verify ReadTheDocs pulled and built new docs successfully.
4) As another optional step, give a meaningful version name as a git tag. See Programming/Git#Tag_Commands.
5) Build project files to finally push to pypi:
python -m build
After running this command, there should be a dist
folder at project root. Double check that the version listed in the file names seems correct, compared to what was done in step #2 above.
6) Finally push the new project version files to pypi:
python -m twine upload dist/*
At this point, the project should be updated on Pypi. Verify everything has successfully uploaded, and the new version can now be pulled down.