[Scipy-svn] r5509 - branches/0.7.x/tools/win32/build_scripts

scipy-svn at scipy.org scipy-svn at scipy.org
Thu Jan 22 10:53:32 EST 2009


Author: cdavid
Date: 2009-01-22 09:53:25 -0600 (Thu, 22 Jan 2009)
New Revision: 5509

Added:
   branches/0.7.x/tools/win32/build_scripts/lib.py
Modified:
   branches/0.7.x/tools/win32/build_scripts/pavement.py
Log:
Update paver script to handle rc releases.

Added: branches/0.7.x/tools/win32/build_scripts/lib.py
===================================================================
--- branches/0.7.x/tools/win32/build_scripts/lib.py	2009-01-19 18:48:55 UTC (rev 5508)
+++ branches/0.7.x/tools/win32/build_scripts/lib.py	2009-01-22 15:53:25 UTC (rev 5509)
@@ -0,0 +1,70 @@
+from os.path import join, exists
+import re
+import subprocess
+
+VREGEX = re.compile("version\s*=\s*'(\d+)\.(\d+)\.(\d+)([a-zA-Z0-9]*)'")
+ISRELREGEX = re.compile("release\s*=\s*True")
+ISDEVREGEX = re.compile("release\s*=\s*False")
+RCEX = re.compile("rc(\d)")
+
+def get_svn_version(chdir):
+    out = subprocess.Popen(['svn', 'info'],
+                           stdout = subprocess.PIPE,
+                           cwd = chdir).communicate()[0]
+    r = re.compile('Revision: ([0-9]+)')
+    svnver = None
+    for line in out.split('\n'):
+        m = r.match(line)
+        if m:
+            svnver = m.group(1)
+
+    if not svnver:
+        raise ValueError("Error while parsing svn version ?")
+
+    return svnver
+
+def get_scipy_version(src_root):
+    version_file = join(src_root, "scipy", "version.py")
+    if not exists(version_file):
+        raise IOError("file %s not found" % version_file)
+
+    fid = open(version_file, "r")
+    version, rc, isdev = parse_verstring(fid.readlines())
+
+    verstr = ".".join([str(i) for i in version])
+    if isdev:
+        verstr += ".dev"
+        verstr += get_svn_version(src_root)
+    return verstr
+
+def parse_verstring(lines):
+    isdev = None
+    version = None
+    for line in lines:
+        m = VREGEX.match(line)
+        if m:
+            gr = m.groups()
+            version = [int(i) for i in gr[:3]]
+            m = RCEX.match(gr[3])
+            if m:
+                rc = int(m.group(1))
+            else:
+                rc = 0
+            break
+            
+    if not version:
+        raise ValueError("Error parsing %s" % "".join(lines))
+
+    for line in lines:
+        if ISRELREGEX.match(line):
+            if isdev is None:
+                isdev = False
+            else:
+                raise RuntimeError("isdev already set ?")
+        if ISDEVREGEX.match(line):
+            if isdev is None:
+                isdev = True
+            else:
+                raise RuntimeError("isdev already set ?")
+
+    return version, rc, isdev

Modified: branches/0.7.x/tools/win32/build_scripts/pavement.py
===================================================================
--- branches/0.7.x/tools/win32/build_scripts/pavement.py	2009-01-19 18:48:55 UTC (rev 5508)
+++ branches/0.7.x/tools/win32/build_scripts/pavement.py	2009-01-22 15:53:25 UTC (rev 5509)
@@ -5,6 +5,8 @@
 import re
 from zipfile import ZipFile
 
+from lib import get_svn_version, get_scipy_version
+
 BUILD_MSI = False
 SRC_ROOT = normpath(pjoin(os.getcwd(), os.pardir, os.pardir, os.pardir))
 BUILD_ROOT = os.getcwd()
@@ -157,54 +159,6 @@
 def bootstrap_dir(pyver):
     return pjoin(BUILD_ROOT, "bootstrap-%s" % pyver)
 
-def get_scipy_version(src_root):
-    version_file = pjoin(src_root, "scipy", "version.py")
-    if not pexists(version_file):
-        raise IOError("file %s not found" % version_file)
-
-    fid = open(version_file, "r")
-    vregex = re.compile("version\s*=\s*'(\d+)\.(\d+)\.(\d+)'")
-    isrelregex = re.compile("release\s*=\s*True")
-    isdevregex = re.compile("release\s*=\s*False")
-    isdev = None
-    version = None
-    for line in fid.readlines():
-        m = vregex.match(line)
-        if m:
-            version = [int(i) for i in m.groups()]
-        if isrelregex.match(line):
-            if isdev is None:
-                isdev = False
-            else:
-                raise RuntimeError("isdev already set ?")
-        if isdevregex.match(line):
-            if isdev is None:
-                isdev = True
-            else:
-                raise RuntimeError("isdev already set ?")
-
-    verstr = ".".join([str(i) for i in version])
-    if isdev:
-        verstr += ".dev"
-        verstr += get_svn_version(src_root)
-    return verstr
-
-def get_svn_version(chdir):
-    out = subprocess.Popen(['svn', 'info'],
-                           stdout = subprocess.PIPE,
-                           cwd = chdir).communicate()[0]
-    r = re.compile('Revision: ([0-9]+)')
-    svnver = None
-    for line in out.split('\n'):
-        m = r.match(line)
-        if m:
-            svnver = m.group(1)
-
-    if not svnver:
-        raise ValueError("Error while parsing svn version ?")
-
-    return svnver
-
 def get_python_exec(ver):
     """Return the executable of python for the given version."""
     # XXX Check that the file actually exists




More information about the Scipy-svn mailing list