1#!/usr/bin/env python 2 3# Copyright (C) 2008 Kevin Ollivier All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 15# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 18# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25# 26# Create a Windows installer package for wxPython wxWebKit binaries 27 28import sys, os, string 29import commands 30import datetime 31import glob 32from subprocess import * 33 34import wx 35 36script_dir = os.path.abspath(os.path.dirname(__file__)) 37sys.path.append(os.path.abspath(os.path.join(script_dir, "..", "build"))) 38 39from build_utils import * 40 41wxwk_root = os.path.abspath(os.path.join(script_dir, "..", "..", "..")) 42wxwebkit_dir = os.path.abspath(os.path.join(wxwk_root, "WebKitBuild", get_config(wxwk_root) + git_branch_name())) 43 44# Find InnoSetup executable 45def getInnoSetupPath(): 46 name = "ISCC.exe" 47 retval = "" 48 dirs = os.environ["PATH"].split(":") 49 # Add the default file path 50 dirs.append("C:\\Program Files\\Inno Setup 5") 51 dirs.append("C:\\Program Files (x86)\\Inno Setup 5") 52 53 if os.environ.has_key("INNO5"): 54 retval = os.environ["INNO5"] 55 56 if retval == "": 57 for dir in dirs: 58 filepath = os.path.join(dir, name) 59 if os.path.isfile(filepath): 60 retval = filepath 61 62 return retval 63 64if __name__ == "__main__": 65 innoSetup = getInnoSetupPath() 66 os.chdir(sys.path[0]) 67 68 date = str(datetime.date.today()) 69 70 if not os.path.exists(innoSetup): 71 print "ERROR: Cannot find InnoSetup." 72 #sys.exit(1) 73 74 if not os.path.exists(wxwebkit_dir): 75 print "ERROR: Build dir %s doesn't exist." % wxwebkit_dir 76 sys.exit(1) 77 78 fileList = """ 79CopyMode: alwaysoverwrite; Source: *.pyd; DestDir: "{app}" 80CopyMode: alwaysoverwrite; Source: *.py; DestDir: "{app}" 81""" 82 83 dlls = glob.glob(os.path.join(wxwebkit_dir, "*.dll")) 84 for dll in dlls: 85 if dll.find("wxbase") == -1 and dll.find("wxmsw") == -1: 86 fileList += """CopyMode: alwaysoverwrite; Source: %s; DestDir: "{app}" \n""" % dll 87 88 installerTemplate = open("wxWebKitInstaller.iss.in", "r").read() 89 90 wx_version = '%d.%d' % (wx.MAJOR_VERSION, wx.MINOR_VERSION) 91 if wx.MINOR_VERSION % 2 == 1: 92 wx_version += ".%d" % wx.RELEASE_VERSION 93 installerTemplate = installerTemplate.replace("msw-unicode", "msw") 94 95 installerTemplate = installerTemplate.replace("<<VERSION>>", date) 96 installerTemplate = installerTemplate.replace("<<WXVERSION>>", wx_version) 97 installerTemplate = installerTemplate.replace("<<ROOTDIR>>", wxwebkit_dir ) 98 installerTemplate = installerTemplate.replace("<<PYTHONVER>>", sys.version[0:3] ) 99 installerTemplate = installerTemplate.replace("<<FILES>>", fileList ) 100 101 outputFile = open("wxWebKitInstaller.iss", "w") 102 outputFile.write(installerTemplate) 103 outputFile.close() 104 105 success = os.system('"%s" wxWebKitInstaller.iss' % innoSetup) 106 sys.exit(success) 107