diff options
author | David Cournapeau <cournape@gmail.com> | 2008-07-28 04:22:40 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2008-07-28 04:22:40 +0000 |
commit | 1b4980a842976a037141ff94c2a3accff875a0c9 (patch) | |
tree | 6f63217d9d1b7f132c6c446e45443c393f982f48 /tools | |
parent | 5e47de270b8b7598b277d918d24500f49f8cb18c (diff) | |
download | numpy-1b4980a842976a037141ff94c2a3accff875a0c9.tar.gz |
Bootstrap script now works from scratch.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/win32build/prepare_bootstrap.py | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/tools/win32build/prepare_bootstrap.py b/tools/win32build/prepare_bootstrap.py index 3f8db2446..5e12950d6 100644 --- a/tools/win32build/prepare_bootstrap.py +++ b/tools/win32build/prepare_bootstrap.py @@ -3,8 +3,7 @@ import subprocess import shutil from os.path import join as pjoin, split as psplit, dirname from zipfile import ZipFile - -from build import get_numpy_version, get_binary_name +import re def get_sdist_tarball(): """Return the name of the installer built by wininst command.""" @@ -25,7 +24,7 @@ def build_sdist(): 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 @@ def prepare_numpy_sources(bootstrap = 'bootstrap'): 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 @@ def prepare_nsis_script(bootstrap, pyver, numver): 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 @@ def prepare_bootstrap(pyver = "2.5"): 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") |