setup.py: update get_version

This commit is contained in:
Benjamin Dauvergne 2013-05-15 15:34:40 +02:00
parent 5a9eb7fa97
commit 4d3e995e09
1 changed files with 2 additions and 3 deletions

View File

@ -9,7 +9,6 @@ import distutils.core
from glob import glob
from os.path import splitext, basename, join as pjoin
import os
import re
from unittest import TextTestRunner, TestLoader
class TestCommand(distutils.core.Command):
@ -57,11 +56,11 @@ def get_version():
assert version is not None
if os.path.exists('.git'):
import subprocess
p = subprocess.Popen(['git','describe','--dirty'],
p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
stdout=subprocess.PIPE)
result = p.communicate()[0]
assert p.returncode == 0, 'git returned non-zero'
new_version = result.split()[0]
new_version = result.split()[0][1:]
assert not new_version.endswith('-dirty'), 'git workdir is not clean'
assert new_version.split('-')[0] == version, '__version__ must match the last git annotated tag'
version = new_version.replace('-', '.')