setup.py: handle case of a tagged dirty workdir

This commit is contained in:
Benjamin Dauvergne 2019-02-08 12:57:03 +01:00
parent 7ac96b4f1e
commit 70c1a1b5db
1 changed files with 5 additions and 1 deletions

View File

@ -75,7 +75,11 @@ def get_version():
if p.returncode == 0:
result = result.decode('ascii').strip()[1:] # strip spaces/newlines and initial v
if '-' in result: # not a tagged version
real_number, commit_count, commit_hash = result.split('-', 2)
try:
real_number, commit_count, commit_hash = result.split('-', 2)
except ValueError:
real_number, commit_hash = result.split('-', 2)
commit_count = 0
version = '%s.post%s+%s' % (real_number, commit_count, commit_hash)
else:
version = result