From 8cab75bf2ac48dc559fa6dbad15299f0cbb422e5 Mon Sep 17 00:00:00 2001 From: gimick Date: Sat, 12 Mar 2011 20:46:29 +0000 Subject: [PATCH] Revert "py2exe: add more build automation, activate MS-Windows GTK theme - (merge conflict)" This reverts commit f16e33c398ee3d2a832743745176f17b7e7a4a42. --- .../windows/py2exeWalkthroughPython27.txt | 32 +++++--- packaging/windows/py2exe_setup.py | 73 ++++++++++--------- 2 files changed, 58 insertions(+), 47 deletions(-) diff --git a/packaging/windows/py2exeWalkthroughPython27.txt b/packaging/windows/py2exeWalkthroughPython27.txt index 921b591c..c1fe722c 100644 --- a/packaging/windows/py2exeWalkthroughPython27.txt +++ b/packaging/windows/py2exeWalkthroughPython27.txt @@ -134,14 +134,14 @@ Step 4 Get the fpdb GIT tree Numpy needs special handling, as by default it will install an optimised version for the SSE level of your CPU (SSE3, SSE2 or noSSE). This means that the completed package will not run on an older CPU. -For this reason, do not just run the installer. We will force a nosse version, to minimise problems on +For this reason, do not just run the installer downloaded. We will force a nosse version, to minimise problems on older client PC's 5.3.1/ download the package to the Desktop numpy 1.5.1 ... http://sourceforge.net/projects/numpy/files/NumPy/1.5.1/numpy-1.5.1-win32-superpack-python2.7.exe/download -5.3.3/ You are normally wanting to build a package which works on all CPU's, so install for noSSE as follows: +5.3.3/ If you are wanting to build a package which works on all CPU's, install noSSE as follows: dos> cd Desktop dos> numpy-1.5.1-win32-superpack-python2.7.exe /arch nosse @@ -159,11 +159,6 @@ Completed Step 6 Run py2exe to generate fpdb.exe -------------------------------------- -6.0/ Set version number of build folder -dos> cd Desktop\fpdb\packaging\windows -dos> write py2exe_setup.py -change the value of fpdbver and save file - 6.1/ Run the script to create the fpdb.exe bundle dos> cd Desktop\fpdb\packaging\windows @@ -172,7 +167,7 @@ dos> c:\python27\python.exe py2exe_setup.py py2exe wait a while, watch lots of copying and whatever. 6.2/ You should next get prompted for the GTK folder. -Enter c:\GTK +c:\GTK 6.3/ If there are no errors reported, it has probably worked, we will test soon. @@ -210,16 +205,27 @@ Step 9 Initial run Observe that the msvcp90.dll was provided by the python runtime package, so we don't have to install the separate package from Microsoft. End-users will, however need the dependency. -Step 11 deleted +Step 11 pruning --------------- -Has been deleted +11.1/ The generated folder is 100+MB and can be pruned by removing the following directories: + +pyfpdb/lib/glib-2.0 +pyfpdb/lib/pkgconfig +pyfpdb/share/aclocal +pyfpdb/share/doc +pyfpdb/share/glib-2.0 +pyfpdb/share/gtk-2.0 +pyfpdb/share/gtk-doc +pyfpdb/share/locale +pyfpdb/share/man Step 12 rename folder --------------------- -If needed, rename the folder to something meaningful to the community. +If needed, rename the folder to something meaningful to the community. If you have built for NoSSE, append anyCPU to the directory name. + Step 13 Compress to executable archive -------------------------------------- @@ -228,4 +234,8 @@ Step 13 Compress to executable archive 13.2/ Rightclick on fpdb executable folder, select 7zip Add to archive... select SFX archive option switch 13.3/ Test the created exe file +Step 14 If you need to build again for a different SSE level +------------------------------------------------------------ + +Go back to step 5 and run again. diff --git a/packaging/windows/py2exe_setup.py b/packaging/windows/py2exe_setup.py index 723218ac..25a54c79 100644 --- a/packaging/windows/py2exe_setup.py +++ b/packaging/windows/py2exe_setup.py @@ -24,25 +24,32 @@ Py2exe script for fpdb. ######################################################################## #TODO: +# get rid of all the uneeded libraries (e.g., pyQT) # think about an installer +# done: change GuiAutoImport so that it knows to start HUD_main.exe, when appropriate +# include the lib needed to handle png files in mucked + #HOW TO USE this script: # -#- edit the fpdbver variable in this script (this value will be used to create the distribution folder name) #- cd to the folder where this script is stored, usually ...packaging/windows #- Run the script with python "py2exe_setup.py py2exe" #- You will frequently get messages about missing .dll files.just assume other # person will have them? we have copyright issues including some dll's -#- If it works, you'll have a new dir fpdb-version which should +#- If it works, you'll have a new dir fpdb-YYYYMMDD-exe which should # contain 2 dirs; gfx and pyfpdb and run_fpdb.bat +#- [ This bit is now automated: +# Last, you must copy the etc/, lib/ and share/ folders from your +# gtk/bin/ (just /gtk/?) folder to the pyfpdb folder. (the whole folders, +# not just the contents) ] +#- You can (should) then prune the etc/, lib/ and share/ folders to +# remove components we don't need. (see output at end of program run) # See walkthrough in packaging directory for versions used -# Very useful guide here : http://www.no-ack.org/2010/09/complete-guide-to-py2exe-for-pygtk.html # steffeN: Doesnt seem necessary to gettext-ify this, but feel free to if you disagree # Gimick: restructure to allow script to run from packaging/windows directory, and not to write to source pyfpdb -fpdbver = '0.22' import os import sys @@ -54,10 +61,6 @@ except: print "A parameter is required, quitting now" quit() -if sys.argv[1] <> "py2exe": - print "Parameter 1 is not valid, quitting now" - quit() - from distutils.core import setup import py2exe import glob @@ -72,15 +75,12 @@ def isSystemDLL(pathname): return origIsSystemDLL(pathname) def test_and_remove(top): - #print "Attempting to delete:", top if os.path.exists(top): if os.path.isdir(top): remove_tree(top) else: print "Unexpected file '"+top+"' found. Exiting." exit() - else: - "oops folder not found" def remove_tree(top): # Delete everything reachable from the directory named in 'top', @@ -89,8 +89,8 @@ def remove_tree(top): # could delete all your disk files. # sc: Nicked this from somewhere, added the if statement to try # make it a bit safer - if (top in ('build','dist') or top.startswith(distdir)) and os.path.basename(os.getcwd()) == 'windows': - print "removing directory '"+top+"' ..." + if top in ('build','dist',distdir) and os.path.basename(os.getcwd()) == 'windows': + #print "removing directory '"+top+"' ..." for root, dirs, files in os.walk(top, topdown=False): for name in files: os.remove(os.path.join(root, name)) @@ -111,6 +111,8 @@ def copy_file(source,destination): shutil.copy( source, destination ) +fpdbver = '0.21' + distdir = r'fpdb-' + fpdbver rootdir = r'../../' #cwd is normally /packaging/windows pydir = rootdir+'pyfpdb/' @@ -170,6 +172,9 @@ setup( ] + matplotlib.get_py2exe_datafiles() ) +# ,(distdir, [rootdir+'run_fpdb.bat']) +# ,(distdir+r'\gfx', glob.glob(gfxdir+'*.*')) +# ] + print "*** py2exe build phase complete ***" # copy zone info and fpdb translation folders @@ -180,7 +185,7 @@ copy_tree (pydir+r'locale', os.path.join(r'dist', 'locale')) copy_tree (gfxdir, os.path.join(distdir, 'gfx')) copy_file (rootdir+'run_fpdb.bat', distdir) -print "*** Renaming dist folder as pyfpdb folder ***" +print "*** Renaming dist folder as distribution pyfpdb folder ***" dest = os.path.join(distdir, 'pyfpdb') os.rename( 'dist', dest ) @@ -191,34 +196,30 @@ while not os.path.exists(gtk_dir): gtk_dir = sys.stdin.readline().rstrip() print "*** copying GTK runtime ***" -dest = os.path.join(distdir, 'pyfpdb', ) +dest = os.path.join(distdir, 'pyfpdb') copy_file(os.path.join(gtk_dir, 'bin', 'libgdk-win32-2.0-0.dll'), dest ) copy_file(os.path.join(gtk_dir, 'bin', 'libgobject-2.0-0.dll'), dest) copy_tree(os.path.join(gtk_dir, 'etc'), os.path.join(dest, 'etc')) copy_tree(os.path.join(gtk_dir, 'lib'), os.path.join(dest, 'lib')) copy_tree(os.path.join(gtk_dir, 'share'), os.path.join(dest, 'share')) -print "*** Activating MS-Windows GTK theme ***" -gtkrc = open(os.path.join(distdir, 'pyfpdb', 'etc', 'gtk-2.0', 'gtkrc'), 'w') -print >>gtkrc, 'gtk-theme-name = "MS-Windows"' -gtkrc.close() - -print "*** deleting temporary build folder ***" +print "*** All done! ***" test_and_remove('build') +print distdir+" is in the pyfpdb dir" +print """ +The following dirs can probably removed to make the final package smaller: -print "*** deleting folders to shrink package size ***" -test_and_remove(os.path.join(distdir, 'pyfpdb', 'lib', 'glib-2.0')) -test_and_remove(os.path.join(distdir, 'pyfpdb', 'lib', 'gtk-2.0','include')) -test_and_remove(os.path.join(distdir, 'pyfpdb', 'lib', 'pkgconfig')) -test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'aclocal')) -test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'doc')) -test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'glib-2.0')) -test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'gtk-2.0')) -test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'gtk-doc')) -test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'locale')) -test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'man')) +pyfpdb/lib/glib-2.0 +pyfpdb/lib/gtk-2.0/include +pyfpdb/lib/pkgconfig +pyfpdb/share/aclocal +pyfpdb/share/doc +pyfpdb/share/glib-2.0 +pyfpdb/share/gtk-2.0 +pyfpdb/share/gtk-doc +pyfpdb/share/locale +pyfpdb/share/man +pyfpdb/share/themes/Default -print "***++++++++++++++++++++++++++++++++++++++++++++++" -print "All done!" -print "The distribution folder "+distdir+" is in the pyfpdb dir" -print "***++++++++++++++++++++++++++++++++++++++++++++++" +Use 7-zip to zip up the distribution and create a self extracting archive and that's it! +"""