diff --git a/windows_installer.py b/windows_installer.py index 6645f3b3b2..529b74f8d0 100644 --- a/windows_installer.py +++ b/windows_installer.py @@ -25,6 +25,11 @@ from py2exe.build_exe import py2exe as build_exe from libprs500 import __version__ as VERSION from libprs500 import __appname__ as APPNAME +PY2EXE_DIR = os.path.join('build','py2exe') +if os.path.exists(PY2EXE_DIR): + shutil.rmtree(PY2EXE_DIR) + + class NSISInstaller(object): TEMPLATE = r''' SetCompressor lzma @@ -229,6 +234,95 @@ SectionEnd else: os.remove(path) +class WixInstaller(object): + ''' + Make a .msi installer. Can't get the driver installation to play well with + an existing installation of the connect USB driver. + ''' + TEMPLATE=\ +r''' + + + + + + + + + Privileged + + 1 + http://libprs500.kovidgoyal.net + appicon.ico + + + + + %(py2exefiles)s + + + + + + + + + + + + + + + + + + + + + + + + + ''' + CANDLE=r'C:\wix\candle.exe ' + LIGHT=r'C:\wix\light.exe -out %s -loc C:\wix\WixUI_en-us.wxl %s c:\wix\wixui.wixlib "C:\Program Files\Driver Installation Tools 2.01\DIFxApp\English-US\WiXLib\x86\DIFxApp.wixlib"' + + def __init__(self, py2exe_dir, dest_dir='dist'): + self.py2exe_dir = py2exe_dir + self.dest_dir = dest_dir + filelist = [] + print self.py2exe_dir + for root, dirs, files in os.walk(self.py2exe_dir): + for name in files: + path = os.path.abspath(os.path.join(root, name)) + filelist.append(path) + component = "\n" + counter = 0 + for path in filelist: + entry = ''%\ + (counter, counter, path, os.path.basename(path)) + component += entry + "\n" + counter += 1 + component += '' + self.installer = self.TEMPLATE%dict(appname=APPNAME, version=VERSION, + py2exefiles=component) + + def build(self): + f = open('installer.wxs', 'w') + f.write(self.installer) + f.close() + subprocess.check_call(self.CANDLE + ' ' + f.name, shell=True) + subprocess.check_call(self.LIGHT%(os.path.join(self.dest_dir, APPNAME + '-' + VERSION + '.msi'), + ' installer.wixobj'), shell=True) + + os.remove('installer.wxs') + os.remove('installer.wixobj') + class BuildEXE(build_exe): manifest_resource_id = 0 @@ -284,9 +378,6 @@ class BuildEXE(build_exe): console = [dict(dest_base=basenames['console'][i], script=scripts['console'][i]) for i in range(len(scripts['console']))] -PY2EXE_DIR = os.path.join('build','py2exe') -if os.path.exists(PY2EXE_DIR): - shutil.rmtree(PY2EXE_DIR) setup( cmdclass = {'py2exe': BuildEXE}, windows = [{'script' : scripts['gui'][0],