Merge branch 'master' into 2767-doc-updates
[arvados.git] / sdk / python / setup_header.py
index c97f94d5b6960f610b182c62b5c99cda8c251515..21b950057c10db539b9263244c32ebfc403b5c06 100644 (file)
@@ -1,9 +1,17 @@
 import shutil
 import os
 import sys
+import re
 
-with os.popen("git log --format=format:%ct.%h -n1 .") as m:
-    minor_version=m.read()
+if os.path.exists("PKG-INFO"):
+    with open("PKG-INFO", "r") as p:
+        for l in p:
+            g = re.match(r'Version: (.*)', l)
+            if g != None:
+                minor_version = g.group(1)
+else:
+    with os.popen("git log --format=format:%ct.%h -n1 .") as m:
+        minor_version = m.read()
 
 # setup.py and setup_fuse.py both share the build/ directory (argh!) so
 # make sure to delete it to avoid scooping up the wrong files.