From 34871472212336cd88cb5a5ac6255d3e0c8c4a8e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 21 Feb 2008 20:57:28 +0000 Subject: [PATCH] --- osx_installer.py | 72 +++++++++++++++++++++--------------- upload.py | 50 ++++++++++++++++++------- windows_installer.py | 87 ++++++++++++++++++++++++++------------------ 3 files changed, 131 insertions(+), 78 deletions(-) diff --git a/osx_installer.py b/osx_installer.py index d7f19267a5..f8cc68f4e0 100644 --- a/osx_installer.py +++ b/osx_installer.py @@ -18,7 +18,6 @@ import sys, re, os, shutil, subprocess, stat from setup import VERSION, APPNAME, scripts, main_modules, basenames, main_functions from setuptools import setup -sys.argv[1:2] = ['py2app'] from py2app.build_app import py2app from modulegraph.find_modules import find_modules @@ -222,31 +221,46 @@ sys.frameworks_dir = os.path.join(os.path.dirname(os.environ['RESOURCEPATH']), ' BuildAPP.makedmg(os.path.join(self.dist_dir, APPNAME+'.app'), APPNAME+'-'+VERSION) -setup( - name = APPNAME, - app = [scripts['gui'][0]], - cmdclass = { 'py2app' : BuildAPP }, - options = { 'py2app' : - { - 'optimize' : 2, - 'dist_dir' : 'build/py2app', - 'argv_emulation' : True, - 'iconfile' : 'icons/library.icns', - 'frameworks': ['libusb.dylib', 'libunrar.dylib'], - 'includes' : ['sip', 'pkg_resources', 'PyQt4.QtSvg', - 'mechanize', 'ClientForm', 'usbobserver'], - 'packages' : ['PIL', 'Authorization', 'rtf2xml', 'lxml'], - 'excludes' : ['pydoc'], - 'plist' : { 'CFBundleGetInfoString' : '''libprs500, an E-book management application.''' - ''' Visit http://libprs500.kovidgoyal.net for details.''', - 'CFBundleIdentifier':'net.kovidgoyal.librs500', - 'CFBundleShortVersionString':VERSION, - 'CFBundleVersion':APPNAME + ' ' + VERSION, - 'LSMinimumSystemVersion':'10.4.3', - 'LSMultipleInstancesProhibited':'true', - 'NSHumanReadableCopyright':'Copyright 2006, Kovid Goyal', - }, - }, - }, - setup_requires = ['py2app'], - ) +def main(): + auto = '--auto' in sys.argv + if auto: + sys.argv.remove('--auto') + if auto and not os.path.exists('dist/auto'): + print '%s does not exist'%os.path.abspath('dist/auto') + return 1 + + sys.argv[1:2] = ['py2app'] + setup( + name = APPNAME, + app = [scripts['gui'][0]], + cmdclass = { 'py2app' : BuildAPP }, + options = { 'py2app' : + { + 'optimize' : 2, + 'dist_dir' : 'build/py2app', + 'argv_emulation' : True, + 'iconfile' : 'icons/library.icns', + 'frameworks': ['libusb.dylib', 'libunrar.dylib'], + 'includes' : ['sip', 'pkg_resources', 'PyQt4.QtSvg', + 'mechanize', 'ClientForm', 'usbobserver'], + 'packages' : ['PIL', 'Authorization', 'rtf2xml', 'lxml'], + 'excludes' : ['pydoc'], + 'plist' : { 'CFBundleGetInfoString' : '''libprs500, an E-book management application.''' + ''' Visit http://libprs500.kovidgoyal.net for details.''', + 'CFBundleIdentifier':'net.kovidgoyal.librs500', + 'CFBundleShortVersionString':VERSION, + 'CFBundleVersion':APPNAME + ' ' + VERSION, + 'LSMinimumSystemVersion':'10.4.3', + 'LSMultipleInstancesProhibited':'true', + 'NSHumanReadableCopyright':'Copyright 2006, Kovid Goyal', + }, + }, + }, + setup_requires = ['py2app'], + ) + if auto: + subprocess.call(('sudo', 'shutdown', '-h', '+0')) + return 0 + +if __name__ == '__main__': + sys.exit(main()) \ No newline at end of file diff --git a/upload.py b/upload.py index 88eef977e0..d742c2c48c 100644 --- a/upload.py +++ b/upload.py @@ -1,6 +1,7 @@ #!/usr/bin/python -import sys, os, shutil +import sys, os, shutil, time sys.path.append('src') +import subprocess from subprocess import check_call as _check_call from functools import partial #from pyvix.vix import Host, VIX_SERVICEPROVIDER_VMWARE_WORKSTATION @@ -34,23 +35,49 @@ def tag_release(): client.callback_get_log_message = get_log_message client.copy(base+'/trunk', tag) +def build_installer(installer, vm, timeout=25): + if os.path.exists(installer): + os.unlink(installer) + f = open('dist/auto', 'wb') + f.write('\n') + f.close() + print 'Building installer %s ...'%installer + vmware = ('vmware', '-q', '-x', '-n', vm) + try: + p = subprocess.Popen(vmware) + print 'Waiting...', + minutes = 0 + sys.stdout.flush() + while p.returncode is None and minutes < timeout and not os.path.exists(installer): + p.poll() + time.sleep(60) + minutes += 1 + print minutes, + sys.stdout.flush() + if not os.path.exists(installer): + raise Exception('Failed to build windows installer') + finally: + os.unlink('dist/auto') + + + return os.path.basename(installer) + def build_windows(): from libprs500 import __version__ installer = 'dist/libprs500-%s.exe'%__version__ - if not os.path.exists(installer): - raise Exception('You must build the windows installer before running this script') - - return os.path.basename(installer) + vm = '/vmware/Windows XP/Windows XP Professional.vmx' + return build_installer(installer, vm, 20) + def build_osx(): from libprs500 import __version__ installer = 'dist/libprs500-%s.dmg'%__version__ - if not os.path.exists(installer): - raise Exception('You must build the OSX installer before running this script') - - return os.path.basename(installer) + vm = '/vmware/Mac OSX/Mac OSX.vmx' + return build_installer(installer, vm, 20) +def build_installers(): + return build_windows(), build_osx() def upload_demo(): check_call('''html2lrf --title='Demonstration of html2lrf' --author='Kovid Goyal' ''' @@ -94,10 +121,7 @@ def main(): check_call('svn commit -m "Updated translations" src/libprs500/translations') tag_release() upload_demo() - print 'Building OSX installer...' - dmg = build_osx() - print 'Building Windows installer...' - exe = build_windows() + exe, dmg = build_installers() if upload: print 'Uploading installers...' upload_installers(exe, dmg) diff --git a/windows_installer.py b/windows_installer.py index b0f7c71e8a..4cfd8ebb34 100644 --- a/windows_installer.py +++ b/windows_installer.py @@ -15,9 +15,6 @@ ''' Create a windows installer ''' import sys, re, os, shutil, subprocess from setup import VERSION, APPNAME, entry_points, scripts, basenames -sys.argv[1:2] = ['py2exe'] -if '--verbose' not in ' '.join(sys.argv): - sys.argv.append('--quiet') #py2exe produces too much output by default from distutils.core import setup from distutils.filelist import FileList import py2exe, glob @@ -432,37 +429,55 @@ class BuildEXE(build_exe): return (24, cls.manifest_resource_id, cls.MANIFEST_TEMPLATE % dict(prog=prog, version=VERSION+'.0')) -console = [dict(dest_base=basenames['console'][i], script=scripts['console'][i]) - for i in range(len(scripts['console']))] -setup( - cmdclass = {'py2exe': BuildEXE}, - windows = [ - {'script' : scripts['gui'][0], - 'dest_base' : APPNAME, - 'icon_resources' : [(1, 'icons/library.ico')], - 'other_resources' : [BuildEXE.manifest(APPNAME)], - }, - {'script' : scripts['gui'][1], - 'dest_base' : 'lrfviewer', - 'icon_resources' : [(1, 'icons/viewer.ico')], - 'other_resources' : [BuildEXE.manifest('lrfviewer')], - }, - ], - console = console, - options = { 'py2exe' : {'compressed': 1, - 'optimize' : 2, - 'dist_dir' : PY2EXE_DIR, - 'includes' : ['sip', 'pkg_resources', 'PyQt4.QtSvg', - 'mechanize', 'ClientForm', 'wmi', - 'win32file', 'pythoncom', 'rtf2xml', - 'lxml', 'lxml._elementpath'], - 'packages' : ['PIL'], - 'excludes' : ["Tkconstants", "Tkinter", "tcl", - "_imagingtk", "ImageTk", "FixTk", - 'pydoc'], - 'dll_excludes' : ['mswsock.dll'], - }, - }, - - ) \ No newline at end of file + +def main(): + auto = '--auto' in sys.argv + if auto: + sys.argv.remove('--auto') + sys.argv[1:2] = ['py2exe'] + if '--verbose' not in sys.argv: + sys.argv.append('--quiet') #py2exe produces too much output by default + if auto and not os.path.exists('dist\\auto'): + print os.path.abspath('dist\\auto'), 'does not exist' + return 1 + console = [dict(dest_base=basenames['console'][i], script=scripts['console'][i]) + for i in range(len(scripts['console']))] + + setup( + cmdclass = {'py2exe': BuildEXE}, + windows = [ + {'script' : scripts['gui'][0], + 'dest_base' : APPNAME, + 'icon_resources' : [(1, 'icons/library.ico')], + 'other_resources' : [BuildEXE.manifest(APPNAME)], + }, + {'script' : scripts['gui'][1], + 'dest_base' : 'lrfviewer', + 'icon_resources' : [(1, 'icons/viewer.ico')], + 'other_resources' : [BuildEXE.manifest('lrfviewer')], + }, + ], + console = console, + options = { 'py2exe' : {'compressed': 1, + 'optimize' : 2, + 'dist_dir' : PY2EXE_DIR, + 'includes' : ['sip', 'pkg_resources', 'PyQt4.QtSvg', + 'mechanize', 'ClientForm', 'wmi', + 'win32file', 'pythoncom', 'rtf2xml', + 'lxml', 'lxml._elementpath'], + 'packages' : ['PIL'], + 'excludes' : ["Tkconstants", "Tkinter", "tcl", + "_imagingtk", "ImageTk", "FixTk", + 'pydoc'], + 'dll_excludes' : ['mswsock.dll'], + }, + }, + + ) + if auto: + subprocess.call(('shutdown', '-s', '-f', '-t', '01')) + return 0 + +if __name__ == '__main__': + sys.exit(main())