-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.py
More file actions
27 lines (22 loc) · 775 Bytes
/
version.py
File metadata and controls
27 lines (22 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import subprocess
import os
# Only change the following elements by hand.
# VERSION is constructed from these.
MAJOR = 0
MINOR = 3
PATCH = 1
# Do not bump or change elements below.
def scm_version(silent = False):
try:
return subprocess.check_output(
['git', '-C', os.path.dirname(__file__), 'describe', '--tags', '--dirty=+'],
stderr = subprocess.DEVNULL
).decode('UTF-8').strip()
except subprocess.CalledProcessError as e:
if not silent:
print("Could not get git output:", e)
LISTED = '{MAJOR}.{MINOR}.{PATCH}'.format(
MAJOR=MAJOR, MINOR=MINOR, PATCH=PATCH)
SOURCE = scm_version(silent = True)
# Provide the most explicit available version.
VERSION = SOURCE if SOURCE else LISTED