[Numpy-svn] r5546 - in trunk/tools/win32build: . nsis_scripts

numpy-svn@scip... numpy-svn@scip...
Sun Jul 27 21:21:24 CDT 2008


Author: cdavid
Date: 2008-07-27 21:21:17 -0500 (Sun, 27 Jul 2008)
New Revision: 5546

Added:
   trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in
   trunk/tools/win32build/prepare_bootstrap.py
Log:
Add nsis template, and bootstrap script, to bootstrap win32 binary build.

Added: trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in
===================================================================
--- trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in	2008-07-28 02:05:30 UTC (rev 5545)
+++ trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in	2008-07-28 02:21:17 UTC (rev 5546)
@@ -0,0 +1,120 @@
+;--------------------------------
+;Include Modern UI
+
+!include "MUI2.nsh"
+
+;SetCompress off ; Useful to disable compression under development
+
+;--------------------------------
+;General
+
+;Name and file
+Name "Numpy super installer"
+OutFile "@NUMPY_INSTALLER_NAME@"
+
+;Default installation folder
+InstallDir "$TEMP"
+
+;--------------------------------
+;Interface Settings
+
+!define MUI_ABORTWARNING
+
+;--------------------------------
+;Pages
+
+;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
+;!insertmacro MUI_PAGE_COMPONENTS
+;!insertmacro MUI_PAGE_DIRECTORY
+;!insertmacro MUI_PAGE_INSTFILES
+
+;!insertmacro MUI_UNPAGE_CONFIRM
+;!insertmacro MUI_UNPAGE_INSTFILES
+
+;--------------------------------
+;Languages
+
+!insertmacro MUI_LANGUAGE "English"
+
+;--------------------------------
+;Component Sections
+
+!include 'Sections.nsh'
+!include LogicLib.nsh
+
+Var HasSSE2
+Var HasSSE3
+Var CPUSSE
+
+Section "Core" SecCore
+
+        ;SectionIn RO
+        SetOutPath "$INSTDIR"
+
+        ;Create uninstaller
+        ;WriteUninstaller "$INSTDIR\Uninstall.exe"
+
+        DetailPrint "Install dir for actual installers is $INSTDIR"
+
+        StrCpy $CPUSSE "0"
+        CpuCaps::hasSSE2
+        Pop $0
+        StrCpy $HasSSE2 $0
+
+        CpuCaps::hasSSE3
+        Pop $0
+        StrCpy $HasSSE3 $0
+
+        ; Debug
+        StrCmp $HasSSE2 "Y" include_sse2 no_include_sse2
+        include_sse2:
+                DetailPrint '"Target CPU handles SSE2"'
+                StrCpy $CPUSSE "2"
+                goto done_sse2
+        no_include_sse2:
+                DetailPrint '"Target CPU does NOT handle SSE2"'
+                goto done_sse2
+        done_sse2:
+
+        StrCmp $HasSSE3 "Y" include_sse3 no_include_sse3
+        include_sse3:
+                DetailPrint '"Target CPU handles SSE3"'
+                StrCpy $CPUSSE "3"
+                goto done_sse3
+        no_include_sse3:
+                DetailPrint '"Target CPU does NOT handle SSE3"'
+                goto done_sse3
+        done_sse3:
+
+        ClearErrors
+
+        ; Install files conditionaly on detected cpu
+        ${Switch} $CPUSSE
+                ${Case} "3"
+                DetailPrint '"Install SSE 3"'
+                File "@SSE3_BINARY@"
+                ExecWait '"$INSTDIR\@SSE3_BINARY@"'
+                ${Break}
+        ${Case} "2"
+                DetailPrint '"Install SSE 2"'
+                File "@SSE2_BINARY@"
+                ExecWait '"$INSTDIR\@SSE2_BINARY@"'
+                ${Break}
+        ${Default}
+                DetailPrint '"Install NO SSE"'
+                File "@NOSSE_BINARY@"
+                ExecWait '"$INSTDIR\@NOSSE_BINARY@"'
+                ${Break}
+        ${EndSwitch}
+
+        ; Handle errors when executing installers
+        IfErrors error no_error
+
+        error:
+                messageBox MB_OK "Executing numpy installer failed"
+                goto done
+        no_error:
+                goto done
+        done:
+
+SectionEnd

Added: trunk/tools/win32build/prepare_bootstrap.py
===================================================================
--- trunk/tools/win32build/prepare_bootstrap.py	2008-07-28 02:05:30 UTC (rev 5545)
+++ trunk/tools/win32build/prepare_bootstrap.py	2008-07-28 02:21:17 UTC (rev 5546)
@@ -0,0 +1,71 @@
+import os
+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
+
+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
+    # here
+    name = "numpy-%s.zip" % get_numpy_version()
+    return name
+
+def build_sdist():
+    cwd = os.getcwd()
+    try:
+        os.chdir('../..')
+        cmd = ["python", "setup.py", "sdist", "--format=zip"]
+        subprocess.call(cmd)
+    except Exception, e:
+        raise RuntimeError("Error while executing cmd (%s)" % e)
+    finally:
+        os.chdir(cwd)
+
+def prepare_numpy_sources(bootstrap = 'bootstrap'):
+    zid = ZipFile(pjoin('../..', 'dist', get_sdist_tarball()))
+    root = 'numpy-%s' % get_numpy_version()
+
+    # From the sdist-built tarball, extract all files into bootstrap directory,
+    # but removing the numpy-VERSION head path
+    for name in zid.namelist():
+        cnt = zid.read(name)
+        if name.startswith(root):
+            name = name.split(os.sep, 1)[1]
+        newname = pjoin(bootstrap, name)
+
+        if not os.path.exists(dirname(newname)):
+            os.makedirs(dirname(newname))
+        fid = open(newname, 'w')
+        fid.write(cnt)
+
+def prepare_nsis_script(bootstrap, pyver, numver):
+    tpl = os.path.join('nsis_scripts', 'numpy-superinstaller.nsi.in')
+    source = open(tpl, 'r')
+    target = open(pjoin(bootstrap, 'numpy-superinstaller.nsi'), 'w')
+
+    installer_name = 'numpy-%s-win32-superpack-python%s.exe' % (numver, pyver)
+    cnt = "".join(source.readlines())
+    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)))
+
+    target.write(cnt)
+
+def prepare_bootstrap(pyver = "2.5"):
+    bootstrap = "bootstrap-%s" % pyver
+    if os.path.exists(bootstrap):
+        shutil.rmtree(bootstrap)
+    os.makedirs(bootstrap)
+
+    #build_sdist()
+    #prepare_numpy_sources(bootstrap)
+
+    #shutil.copy('build.py', bootstrap)
+    prepare_nsis_script(bootstrap, pyver, get_numpy_version())
+
+if __name__ == '__main__':
+    prepare_bootstrap("2.5")



More information about the Numpy-svn mailing list