setup.py: does not build the distribution tarball if git workdir is not clean

This commit is contained in:
Benjamin Dauvergne 2013-05-15 15:15:41 +02:00
parent cffad1de38
commit 5389975c0a
1 changed files with 2 additions and 1 deletions

View File

@ -64,11 +64,12 @@ def get_version():
assert version is not None
if os.path.exists('.git'):
import subprocess
p = subprocess.Popen(['git','describe'],
p = subprocess.Popen(['git','describe','--dirty'],
stdout=subprocess.PIPE)
result = p.communicate()[0]
assert p.returncode == 0, 'git returned non-zero'
new_version = result.split()[0]
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('-', '.')
return version