setup.py: update get_version
This commit is contained in:
parent
d2e123975b
commit
f49cadf409
5
setup.py
5
setup.py
|
@ -9,7 +9,6 @@ import distutils.core
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from os.path import splitext, basename, join as pjoin
|
from os.path import splitext, basename, join as pjoin
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
from unittest import TextTestRunner, TestLoader
|
from unittest import TextTestRunner, TestLoader
|
||||||
|
|
||||||
class TestCommand(distutils.core.Command):
|
class TestCommand(distutils.core.Command):
|
||||||
|
@ -57,11 +56,11 @@ def get_version():
|
||||||
assert version is not None
|
assert version is not None
|
||||||
if os.path.exists('.git'):
|
if os.path.exists('.git'):
|
||||||
import subprocess
|
import subprocess
|
||||||
p = subprocess.Popen(['git','describe','--dirty'],
|
p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
result = p.communicate()[0]
|
result = p.communicate()[0]
|
||||||
assert p.returncode == 0, 'git returned non-zero'
|
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 not new_version.endswith('-dirty'), 'git workdir is not clean'
|
||||||
assert new_version.split('-')[0] == version, '__version__ must match the last git annotated tag'
|
assert new_version.split('-')[0] == version, '__version__ must match the last git annotated tag'
|
||||||
version = new_version.replace('-', '.')
|
version = new_version.replace('-', '.')
|
||||||
|
|
Loading…
Reference in New Issue