Python versioning with scm and git tags

Python has a versioning module that will automatically get its version from your latest git tag, and put that version in a pip repository.

Briefly, here are the components

Setup.py

In setuptools.py you need to add a line:

use_scm_version=True,

Git

Next, once you are happy with your repo, add a new tag. Lets start by listing all the tags

git tag -l

and then add a new tag and comment

git tag -a 1.8 -m 'incrementing for new release'

Note here the -a adds the tag, and the -m is a comment.

Finally, you need to push that tag to github:

git push origin 1.8

Setup

Finally, you need to create a new version of your code. You can start by checking the proposed version

python setup.py --version

This will show the suggested version. Note that scm makes some guesses based on the changes since the last tag, and so if you see .dev1+geed5d83 it means that you have commits since the 1.8 tag release. See “Default versioning scheme” on [the scm help page](https://github.com/pypa/setuptools_scm/#default-versioning-scheme) for more details.

Finally, create a release and upload it to pypi!