[Numpy-svn] r5552 - trunk/tools/win32build

numpy-svn@scip... numpy-svn@scip...
Sun Jul 27 23:22:44 CDT 2008


Author: cdavid
Date: 2008-07-27 23:22:40 -0500 (Sun, 27 Jul 2008)
New Revision: 5552

Modified:
   trunk/tools/win32build/prepare_bootstrap.py
Log:
Bootstrap script now works from scratch.

Modified: trunk/tools/win32build/prepare_bootstrap.py
===================================================================
--- trunk/tools/win32build/prepare_bootstrap.py	2008-07-28 04:21:49 UTC (rev 5551)
+++ trunk/tools/win32build/prepare_bootstrap.py	2008-07-28 04:22:40 UTC (rev 5552)
@@ -3,9 +3,8 @@
 import shutil
 from os.path import join as pjoin, split as psplit, dirname
 from zipfile import ZipFile
+import re
 
-from build import get_numpy_version, get_binary_name
-
 def get_sdist_tarball():
     """Return the name of the installer built by wininst command."""
     # Yeah, the name logic is harcoded in distutils. We have to reproduce it
@@ -25,7 +24,7 @@
         os.chdir(cwd)
 
 def prepare_numpy_sources(bootstrap = 'bootstrap'):
-    zid = ZipFile(pjoin('../..', 'dist', get_sdist_tarball()))
+    zid = ZipFile(pjoin('..', '..', 'dist', get_sdist_tarball()))
     root = 'numpy-%s' % get_numpy_version()
 
     # From the sdist-built tarball, extract all files into bootstrap directory,
@@ -33,12 +32,13 @@
     for name in zid.namelist():
         cnt = zid.read(name)
         if name.startswith(root):
-            name = name.split(os.sep, 1)[1]
+            # XXX: even on windows, the path sep in zip is '/' ?
+            name = name.split('/', 1)[1]
         newname = pjoin(bootstrap, name)
 
         if not os.path.exists(dirname(newname)):
             os.makedirs(dirname(newname))
-        fid = open(newname, 'w')
+        fid = open(newname, 'wb')
         fid.write(cnt)
 
 def prepare_nsis_script(bootstrap, pyver, numver):
@@ -51,11 +51,11 @@
     cnt = cnt.replace('@NUMPY_INSTALLER_NAME@', installer_name)
     for arch in ['nosse', 'sse2', 'sse3']:
         cnt = cnt.replace('@%s_BINARY@' % arch.upper(),
-                          get_binary_name(arch)))
+                          get_binary_name(arch))
 
     target.write(cnt)
 
-def prepare_bootstrap(pyver = "2.5"):
+def prepare_bootstrap(numver, pyver = "2.5"):
     bootstrap = "bootstrap-%s" % pyver
     if os.path.exists(bootstrap):
         shutil.rmtree(bootstrap)
@@ -67,5 +67,32 @@
     shutil.copy('build.py', bootstrap)
     prepare_nsis_script(bootstrap, pyver, get_numpy_version())
 
+def get_binary_name(arch):
+    return "numpy-%s-%s.exe" % (get_numpy_version(), arch)
+
+def get_numpy_version(chdir = pjoin('..', '..')):
+    cwd = os.getcwd()
+    try:
+        if not chdir:
+            chdir = cwd
+        os.chdir(chdir)
+        version = subprocess.Popen(['python', '-c', 'import __builtin__; __builtin__.__NUMPY_SETUP__ = True; from numpy.version import version;print version'], stdout =  subprocess.PIPE).communicate()[0]
+        version = version.strip()
+        if 'dev' in version:
+            out = subprocess.Popen(['svn', 'info'], stdout = subprocess.PIPE).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 ?")
+            version += svnver
+    finally:
+        os.chdir(cwd)
+    return version
+
 if __name__ == '__main__':
     prepare_bootstrap("2.5")



More information about the Numpy-svn mailing list