Browse code

Merge pull request #12 from jbweston/version-from-git

Add functionality to tell when the version info comes from git

Joseph Weston authored on 15/10/2018 10:56:59 • GitHub committed on 15/10/2018 10:56:59
Showing 1 changed files
... ...
@@ -21,9 +21,7 @@ STATIC_VERSION_FILE = '_static_version.py'
21 21
 
22 22
 
23 23
 def get_version(version_file=STATIC_VERSION_FILE):
24
-    version_info = {}
25
-    with open(os.path.join(package_root, version_file), 'rb') as f:
26
-        exec(f.read(), {}, version_info)
24
+    version_info = get_static_version_info(version_file)
27 25
     version = version_info['version']
28 26
     if version == "__use_git__":
29 27
         version = get_version_from_git()
... ...
@@ -36,6 +34,17 @@ def get_version(version_file=STATIC_VERSION_FILE):
36 34
         return version
37 35
 
38 36
 
37
+def get_static_version_info(version_file=STATIC_VERSION_FILE):
38
+    version_info = {}
39
+    with open(os.path.join(package_root, version_file), 'rb') as f:
40
+        exec(f.read(), {}, version_info)
41
+    return version_info
42
+
43
+
44
+def version_is_from_git(version_file=STATIC_VERSION_FILE):
45
+    return get_static_version_info(version_file)['version'] == '__use_git__'
46
+
47
+
39 48
 def pep440_format(version_info):
40 49
     release, dev, labels = version_info
41 50