handle possible failure of git describe (#24646)

This commit is contained in:
Emmanuel Cazenave 2018-08-09 17:20:20 +02:00
parent 01473f295f
commit ced979f0ae
1 changed files with 5 additions and 4 deletions

View File

@ -17,11 +17,12 @@ def get_version():
version_file.close()
return version
if os.path.exists('.git'):
p = subprocess.Popen(['git','describe','--match=v*'], stdout=subprocess.PIPE)
p = subprocess.Popen(['git', 'describe', '--dirty', '--match=v*'], stdout=subprocess.PIPE)
result = p.communicate()[0]
version = result.split()[0][1:]
version = version.replace('-', '.')
return version
if p.returncode == 0:
version = str(result.split()[0][1:])
version = version.replace('-', '.')
return version
return '0'
class eo_sdist(sdist):