improve version specifiers

This commit is contained in:
Thomas Kriechbaumer 2017-01-23 20:22:19 +01:00
parent 86174eb6ad
commit 63beaa18ce
2 changed files with 19 additions and 1 deletions

View File

@ -19,7 +19,21 @@ def dump_system_info():
try:
c = ['git', 'describe', '--tags', '--long']
git_describe = subprocess.check_output(c, stderr=subprocess.STDOUT)
git_describe = git_describe.decode().strip()
last_tag, tag_dist, commit = git_describe.decode().strip().rsplit("-", 2)
if last_tag.startswith('v'):
# remove the 'v' prefix
last_tag = last_tag[1:]
if commit.startswith('g'):
# remove the 'g' prefix added by recent git versions
commit = commit[1:]
# build the same version specifier as used for snapshots by rtool
git_describe = "{version}dev{tag:04}-0x{commit}".format(
version=last_tag,
tag=int(tag_dist),
commit=commit,
)
except:
pass

View File

@ -89,6 +89,10 @@ def get_snapshot_version() -> str:
if tag_dist == 0:
return get_version()
else:
# remove the 'g' prefix added by recent git versions
if commit.startswith('g'):
commit = commit[1:]
# The wheel build tag (we use the commit) must start with a digit, so we include "0x"
return "{version}dev{tag_dist:04}-0x{commit}".format(
version=get_version(), # this should already be the next version