blob: 78e32e7c95b25c87232a5c39a93e08f878f70b45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import os
import re
import subprocess
VERSION = None
def _get_version():
'''return either the tag on HEAD or the shortened commit id if not found'''
out = subprocess.check_output(['git', 'log', '--format=%h %d', '-1'],
cwd=os.path.dirname(__file__))
version, ref_names = out.split('(')
m = re.match(r'.*tag: (\d{4}\.\d{2}.*?),', ref_names)
if not m:
# might be an older version of git
m = re.match(r'.*HEAD, (\d{4}\.\d{2}.*?),', ref_names)
if m:
version = m.group(1)
return version.strip()
try:
VERSION = _get_version()
except:
VERSION = '???'
|