python

These are the steps I take when releasing a version of my Python package to PyPI.

First run your checks/cleaning. I have a post about this here. If any fail, start again.

Run tests.

pytest
rm -r .tox; tox  # Continue below while this is running

In a new branch:

Once the release is uploaded, there’s no way to change the README.md on PyPI, or the documentation on Readthedocs, without releasing another version. So take care with these in stable releases.

Commit, push and merge into master.

git commit -a
git push origin head

Pull master, tag the commit and push the tag.

git checkout master
git pull
git tag x.x.x
git push --tags

Create the sdist and upload it.

pip install --upgrade pip setuptools twine
python setup.py sdist
twine check dist/my_package-x.x.x.tar.gz
twine upload dist/my_package-x.x.x.tar.gz

Update coverage badge.

pip install --upgrade pytest-cov coveralls pyyaml
pytest --cov-branch --cov-report term-missing --cov mypackage tests
coveralls

Build readthedocs if there’s been changes.

Update related blog posts/stack overflow posts.