Git revision numbers for setuptools packages
Adding snapshot versions to setuptools packages from SVN is easy. This post describes how to do it in GIT too.
Adding snapshot versions to your setuptools packages from SVN is easy, using the tag_svn_revision = true
options in setup.cfg. However, getting this working for GIT proved to be more difficult, as there’s no built in support. However, I finally settled on a bash script that does the job quite nicely.
now=`date +%s`
gitversion=`git describe --long --dirty=-$now | sed 's/.\*(\[-\]\[0-9\]\[0-9]\*[-\]\[a-z0-9\]*)/1/'`
python setup.py setopt -o tag_build -s $gitversion -c egg_info
python setup.py sdist
First we generate a unique version string, based on the number of commits since the last GIT tag:
now=`date +%s`
gitversion=`git describe --long --dirty=-$now | sed 's/.\*(\[-\]\[0-9\]\[0-9]\*[-\]\[a-z0-9\]*)/1/'`
Then we just apply it as an option before building the release:
python setup.py setopt -o tag_build -s $gitversion -c egg_info
python setup.py sdist
Share this post
Twitter
Google+
Facebook
Reddit
LinkedIn
StumbleUpon
Pinterest
Email