Skip to content
Snippets Groups Projects
Commit e9999ec6 authored by Christoph Groth's avatar Christoph Groth
Browse files

make kwant version conform to PEP 440

parent 0a34e527
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,8 @@ def get_version_from_git(): ...@@ -33,7 +33,8 @@ def get_version_from_git():
# that were merged-in. # that were merged-in.
for opts in [['--first-parent'], []]: for opts in [['--first-parent'], []]:
try: try:
p = subprocess.Popen(['git', 'describe'] + opts, cwd=distr_root, p = subprocess.Popen(['git', 'describe', '--long'] + opts,
cwd=distr_root,
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except OSError: except OSError:
return return
...@@ -41,19 +42,29 @@ def get_version_from_git(): ...@@ -41,19 +42,29 @@ def get_version_from_git():
break break
else: else:
return return
version = p.communicate()[0].rstrip('\n') description = p.communicate()[0].strip('v').rstrip('\n')
if version[0] == 'v': release, dev, git = description.rsplit('-', 2)
version = version[1:] version = [release]
labels = []
if dev != "0":
version.append(".dev{}".format(dev))
labels.append(git)
try: try:
p = subprocess.Popen(['git', 'diff', '--quiet'], cwd=distr_root) p = subprocess.Popen(['git', 'diff', '--quiet'], cwd=distr_root)
except OSError: except OSError:
version += '-confused' # This should never happen. labels.append('confused') # This should never happen.
else: else:
if p.wait() == 1: if p.wait() == 1:
version += '-dirty' labels.append('dirty')
return version
if labels:
version.append('+')
version.append(".".join(labels))
return "".join(version)
from _kwant_version import version from _kwant_version import version
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment