Skip to content
Snippets Groups Projects
Commit 45c04582 authored by Martin Bauer's avatar Martin Bauer
Browse files

Fixes in setup.py (version stored in file when creating tar balls)

parent 5b8d0d5b
No related merge requests found
This diff is collapsed.
include README.md
include RELEASE-VERSION
\ No newline at end of file
...@@ -4,7 +4,7 @@ import subprocess ...@@ -4,7 +4,7 @@ import subprocess
def version_number_from_git(tag_prefix='release/', sha_length=10, version_format="{version}.dev{commits}+{sha}"): def version_number_from_git(tag_prefix='release/', sha_length=10, version_format="{version}.dev{commits}+{sha}"):
def get_released_versions(): def get_released_versions():
tags = sorted(subprocess.getoutput('git tag').split('\n')) tags = sorted(subprocess.check_output(['git', 'tag'], encoding='utf-8').split('\n'))
versions = [t[len(tag_prefix):] for t in tags if t.startswith(tag_prefix)] versions = [t[len(tag_prefix):] for t in tags if t.startswith(tag_prefix)]
return versions return versions
...@@ -16,7 +16,11 @@ def version_number_from_git(tag_prefix='release/', sha_length=10, version_format ...@@ -16,7 +16,11 @@ def version_number_from_git(tag_prefix='release/', sha_length=10, version_format
parsed_version[-1] += 1 parsed_version[-1] += 1
return '.'.join(str(i) for i in parsed_version) return '.'.join(str(i) for i in parsed_version)
latest_release = get_released_versions()[-1] try:
latest_release = get_released_versions()[-1]
except subprocess.CalledProcessError:
return open('RELEASE-VERSION', 'r').read()
commits_since_tag = subprocess.getoutput('git rev-list {}..HEAD --count'.format(tag_from_version(latest_release))) commits_since_tag = subprocess.getoutput('git rev-list {}..HEAD --count'.format(tag_from_version(latest_release)))
sha = subprocess.getoutput('git rev-parse HEAD')[:sha_length] sha = subprocess.getoutput('git rev-parse HEAD')[:sha_length]
is_dirty = len(subprocess.getoutput("git status --untracked-files=no -s")) > 0 is_dirty = len(subprocess.getoutput("git status --untracked-files=no -s")) > 0
...@@ -29,6 +33,10 @@ def version_number_from_git(tag_prefix='release/', sha_length=10, version_format ...@@ -29,6 +33,10 @@ def version_number_from_git(tag_prefix='release/', sha_length=10, version_format
if is_dirty: if is_dirty:
version_string += ".dirty" version_string += ".dirty"
with open("RELEASE-VERSION", "w") as f:
f.write(version_string)
return version_string return version_string
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment