diff options
author | David Cournapeau <cournape@gmail.com> | 2008-07-28 02:21:17 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2008-07-28 02:21:17 +0000 |
commit | c90b955c14395408069b5e382b307c18bb98c249 (patch) | |
tree | 7935cce7d1a7166a005daf3ccabc6242c538c5ce /tools/win32build | |
parent | bd8c4ce81340901cd7322f84cd1911581ce910dd (diff) | |
download | numpy-c90b955c14395408069b5e382b307c18bb98c249.tar.gz |
Add nsis template, and bootstrap script, to bootstrap win32 binary build.
Diffstat (limited to 'tools/win32build')
-rw-r--r-- | tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in | 120 | ||||
-rw-r--r-- | tools/win32build/prepare_bootstrap.py | 71 |
2 files changed, 191 insertions, 0 deletions
diff --git a/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in b/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in new file mode 100644 index 000000000..1ef516d9e --- /dev/null +++ b/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in @@ -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
diff --git a/tools/win32build/prepare_bootstrap.py b/tools/win32build/prepare_bootstrap.py new file mode 100644 index 000000000..81d27714f --- /dev/null +++ b/tools/win32build/prepare_bootstrap.py @@ -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") |