py2exe: restructure - .906 locale changes, now builds in packaging/windows

This commit is contained in:
gimick 2010-08-26 22:11:42 +01:00
parent 62bd04661a
commit a28b0d8dbb
2 changed files with 324 additions and 351 deletions

View File

@ -1,239 +1,238 @@
PY2EXE walkthrough for Python 2.6 & FPDB 0.20 PY2EXE walkthrough for Python 2.6 & FPDB 0.20
created on 22nd June 2010 by Gimick created on 22nd June 2010 by Gimick
This walkthrough is derived from comments in the py2exe script made by Ray and SqlCoder This walkthrough is derived from comments in the py2exe script made by Ray and SqlCoder
Additional information, formatting, updating to Python 2.6 and sequencing added by Gimick Additional information, formatting, updating to Python 2.6 and sequencing added by Gimick
Content is available under the the GNU Affero General Public License version 3 Content is available under the the GNU Affero General Public License version 3
Step 0 Get a fresh XP installation Step 0 Get a fresh XP installation
---------------------------------- ----------------------------------
0.1/ Using XPhome or Pro 32bit 0.1/ Using XPhome or Pro 32bit
0.2/ Ensure the CPU supports SSE2 instruction set or better. 0.2/ Ensure the CPU supports SSE2 instruction set or better.
Step 1, dependency install Step 1, dependency install
-------------------------- --------------------------
1.1/ install the following in sequence (accept all default options) there should be no errors ! 1.1/ install the following in sequence (accept all default options) there should be no errors !
Python 2.6.5 ... http://www.python.org/ftp/python/2.6.5/python-2.6.5.msi Python 2.6.5 ... http://www.python.org/ftp/python/2.6.5/python-2.6.5.msi
pywin 214 ... http://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/pywin32-214.win32-py2.6.exe/download pywin 214 ... http://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/pywin32-214.win32-py2.6.exe/download
matplotlib 0.99.3 ... http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.3/matplotlib-0.99.3.win32-py2.6.exe/download matplotlib 0.99.3 ... http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.3/matplotlib-0.99.3.win32-py2.6.exe/download
pygtk 2.16.0 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.16/pygtk-2.16.0.win32-py2.6.exe pygtk 2.16.0 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.16/pygtk-2.16.0.win32-py2.6.exe
pycairo 1.8.6 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.8/pycairo-1.8.6.win32-py2.6.exe pycairo 1.8.6 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.8/pycairo-1.8.6.win32-py2.6.exe
pyGobject 2.20.0 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.20/pygobject-2.20.0.win32-py2.6.exe pyGobject 2.20.0 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.20/pygobject-2.20.0.win32-py2.6.exe
py2exe 0.6.9 ... http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.6.exe/download py2exe 0.6.9 ... http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.6.exe/download
psycopg2 ... http://www.stickpeople.com/projects/python/win-psycopg/psycopg2-2.2.1.win32-py2.6-pg8.4.3-release.exe psycopg2 ... http://www.stickpeople.com/projects/python/win-psycopg/psycopg2-2.2.1.win32-py2.6-pg8.4.3-release.exe
(Note: stickpeople is the offical repository, not a community build) (Note: stickpeople is the offical repository, not a community build)
1.2/ MySQL 1.2/ MySQL
MySQL-python-1.2.3.win32-py2.6-fpdb0.20.exe ... http://www.mediafire.com/file/iodnnnznmj1/MySQL-python-1.2.3.win32-py2.6-fpdb0.20.exe MySQL-python-1.2.3.win32-py2.6-fpdb0.20.exe ... http://www.mediafire.com/file/iodnnnznmj1/MySQL-python-1.2.3.win32-py2.6-fpdb0.20.exe
This is an intaller built from source by gimick. There are no official mysql-python2.6 builds for windows. This is an intaller built from source by gimick. There are no official mysql-python2.6 builds for windows.
Community builds are also available from some developers. see www.codegood.com for example. Community builds are also available from some developers. see www.codegood.com for example.
1.3/ pytz fixup to work in an executable package 1.3/ pytz fixup to work in an executable package
pytz needs runtime access to timezone definition files. pytz is hard-coded to search in the directory from which the pytz .py modules are being run. pytz needs runtime access to timezone definition files. pytz is hard-coded to search in the directory from which the pytz .py modules are being run.
In a py2exe package, this directory is actually a library.zip container file, so windows cannot find the timezone definitions, and will crash the app. In a py2exe package, this directory is actually a library.zip container file, so windows cannot find the timezone definitions, and will crash the app.
We need to make a one-line change to pytz to search in the current working directory (which is not a container), and not the application directory. We need to make a one-line change to pytz to search in the current working directory (which is not a container), and not the application directory.
The py2exe script copies the timezone datafiles into the package folder pyfpdb/zoneinfo. The py2exe script copies the timezone datafiles into the package folder pyfpdb/zoneinfo.
Thanks to Jeff Peck <peck.jeff <at> gmail.com> on the py2exe mailing list for documenting this problem and solution. Thanks to Jeff Peck <peck.jeff <at> gmail.com> on the py2exe mailing list for documenting this problem and solution.
1.3.1/ Navigate to C:\Python26\Lib\site-packages\pytz 1.3.1/ Navigate to C:\Python26\Lib\site-packages\pytz
1.3.2/ Edit __init__.py 1.3.2/ Edit __init__.py
1.3.3/ At line 55 replace the following line(s): 1.3.3/ At line 55 replace the following line(s):
filename = os.path.join(os.path.dirname(__file__), filename = os.path.join(os.path.dirname(__file__),
'zoneinfo', *name_parts) 'zoneinfo', *name_parts)
with this line: with this line:
filename = os.path.join(os.getcwd(), 'zoneinfo', *name_parts) filename = os.path.join(os.getcwd(), 'zoneinfo', *name_parts)
1.3.4/ Save and exit 1.3.4/ Save and exit
Step 2 Setup GTK Step 2 Setup GTK
----------------- -----------------
There are quite a few GTK packages needed, and rather than install them individually, I used the official AllinOne from the GTK project. There are quite a few GTK packages needed, and rather than install them individually, I used the official AllinOne from the GTK project.
2,1/ Create a new folder c:\GTK 2,1/ Create a new folder c:\GTK
2.2/ Extract the following zip file into c:\GTK 2.2/ Extract the following zip file into c:\GTK
GTK+ all in one 2.20.0 ... http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.20/gtk+-bundle_2.20.0-20100406_win32.zip GTK+ all in one 2.20.0 ... http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.20/gtk+-bundle_2.20.0-20100406_win32.zip
2.3/ If everything has worked, you should have c:\GTK\bin \etc \lib \src and so on created. 2.3/ If everything has worked, you should have c:\GTK\bin \etc \lib \src and so on created.
Step 3 Set GTK into the PATH variable Step 3 Set GTK into the PATH variable
------------------------------------- -------------------------------------
The path for GTK isn't set by default, so need to let the o/s know where the GTK stuff is. The path for GTK isn't set by default, so need to let the o/s know where the GTK stuff is.
3.1/ Rightclick on mycomputer to show system properties 3.1/ Rightclick on mycomputer to show system properties
3.2/ select advanced/environment Variables 3.2/ select advanced/environment Variables
3.3/ in "system variables" NOT "user variables" do the following 3.3/ in "system variables" NOT "user variables" do the following
3.3.1/ create a new item as name: GTK_BASEPATH value: c:\GTK 3.3.1/ create a new item as name: GTK_BASEPATH value: c:\GTK
3.3.2/ edit the item "path", press home to get to the first character and insert the following text, (no quotes, including semicolon) %GTK_BASEPATH%\bin; 3.3.2/ edit the item "path", press home to get to the first character and insert the following text, (no quotes, including semicolon) %GTK_BASEPATH%\bin;
3.4/ to check, open command prompt and do: 3.4/ to check, open command prompt and do:
dos>path ... system should respond with ... PATH=c:\GTK\bin;C:\WIN........ dos>path ... system should respond with ... PATH=c:\GTK\bin;C:\WIN........
3.5/ Give it a spin to test (hopefully an application will start, if not, something has gone wrong) 3.5/ Give it a spin to test (hopefully an application will start, if not, something has gone wrong)
dos> gtk-demo dos> gtk-demo
Step 4 Get the fpdb GIT tree Step 4 Get the fpdb GIT tree
---------------------------- ----------------------------
4.1/ Best to take a copy to work with; following steps will assume that the fpdb folder is on the Desktop 4.1/ Best to take a copy to work with; following steps will assume that the fpdb folder is on the Desktop
4.2/ Edit the script in packaging/windows/py2exe_setup.py to set the fpdbver variable for this release
5.3/ Install correct Numpy for this build
----------------------------------------- 5.3/ Install correct Numpy for this build
-----------------------------------------
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.
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 downloaded.
For this reason, do not just run the installer downloaded.
5.3.1/ download the package to the Desktop
5.3.1/ download the package to the Desktop
numpy 1.4.1 ... http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1-win32-superpack-python2.6.exe/download
numpy 1.4.1 ... http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1-win32-superpack-python2.6.exe/download
5.3.2/ remove any existing numpy installation
5.3.2/ remove any existing numpy installation
Go to the control panel and uninstall "Python2.6 numpy-1.4.1"
Go to the control panel and uninstall "Python2.6 numpy-1.4.1"
5.3.3/ If you are wanting to build a package which works on all CPU's, install 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.4.1-win32-superpack-python2.6.exe /arch nosse dos> cd Desktop
dos> numpy-1.4.1-win32-superpack-python2.6.exe /arch nosse
5.3.4/ If you are wanting to build a package which works on SSE2 and better CPU's, install SSE2 as follows:
5.3.4/ If you are wanting to build a package which works on SSE2 and better CPU's, install SSE2 as follows:
dos> cd Desktop
dos> numpy-1.4.1-win32-superpack-python2.6.exe /arch sse2 dos> cd Desktop
dos> numpy-1.4.1-win32-superpack-python2.6.exe /arch sse2
5.3.4/ At the end of the installation, click on "show details" to confirm the installation.
5.3.4/ At the end of the installation, click on "show details" to confirm the installation.
For no SSE:
For no SSE:
"Target CPU handles SSE2"
"Target CPU handles SSE3" "Target CPU handles SSE2"
"nosse install (arch value: nosse)" "Target CPU handles SSE3"
"Install NO SSE" "nosse install (arch value: nosse)"
Extract: numpy-1.4.1-nosse.exe... 100% "Install NO SSE"
Execute: "C:\DOCUME~1\user\LOCALS~1\Temp\numpy-1.4.1-nosse.exe" Extract: numpy-1.4.1-nosse.exe... 100%
Completed Execute: "C:\DOCUME~1\user\LOCALS~1\Temp\numpy-1.4.1-nosse.exe"
Completed
For SSE2:
For SSE2:
"Target CPU handles SSE2"
"Target CPU handles SSE3" "Target CPU handles SSE2"
"sse2 install (arch value: sse2)" "Target CPU handles SSE3"
"Install SSE 2" "sse2 install (arch value: sse2)"
Extract: numpy-1.4.1-sse2.exe... 100% "Install SSE 2"
Execute: "C:\DOCUME~1\user\LOCALS~1\Temp\numpy-1.4.1-sse2.exe" Extract: numpy-1.4.1-sse2.exe... 100%
Completed Execute: "C:\DOCUME~1\user\LOCALS~1\Temp\numpy-1.4.1-sse2.exe"
Completed
Step 6 Run py2exe to generate fpdb.exe
-------------------------------------- Step 6 Run py2exe to generate fpdb.exe
--------------------------------------
6.1/ Run the script to create the fpdb.exe bundle
6.1/ Run the script to create the fpdb.exe bundle
dos> cd Desktop\fpdb\pyfpdb
dos> c:\python26\python.exe py2exe_setup.py py2exe dos> cd Desktop\fpdb\packaging\windows
dos> c:\python26\python.exe py2exe_setup.py py2exe
wait a while, watch lots of copying and whatever.
wait a while, watch lots of copying and whatever.
6.2/ You should next get prompted for the GTK folder.
c:\GTK 6.2/ You should next get prompted for the GTK folder.
c:\GTK
6.3/ If there are no errors reported, it has probably worked, we will test soon.
6.3/ If there are no errors reported, it has probably worked, we will test soon.
Build notes:
Build notes:
There is a warning about dll's not included "umath.pyd - c:\Python26\lib\site-packages\numpy\core\umath.pyd" - reason for this is not understood at present. (Umath is apparently included in the built package).
There is a warning about dll's not included "umath.pyd - c:\Python26\lib\site-packages\numpy\core\umath.pyd" - reason for this is not understood at present. (Umath is apparently included in the built package).
Step 7 not currently used
------------------------- Step 7 not currently used
-------------------------
Has been deleted
Has been deleted
Step 8 Drag out the completed bundle
------------------------------------ Step 8 Drag out the completed bundle
------------------------------------
py2exe creates a new folder for the created software bundle, drag this out to the desktop for ease of working.
As far as I know you cannot rerun the build if the fpdb-yyyymmdd-exe exists in the tree, so dragging this out py2exe creates a new folder for the created software bundle, drag this out to the desktop for ease of working.
also allows the build to re-run at step 6.
8.1/ Drag Desktop\fpdb\packaging\windows\fpdb-n.nn.nnn to Desktop\
8.1/ Drag Desktop\fpdb\pyfpdb\fpdb-yyyymmdd-exe to Desktop\
Step 9 Initial run
Step 9 Initial run ------------------
------------------
9.1/ Open the Desktop\fpdb-n.nn.nnn folder
9.1/ Open the Desktop\fpdb-yyyymmdd-exe folder 9.2/ In explorer...tools...folder options...View uncheck "Hide extensions for known file types"
9.2/ In explorer...tools...folder options...View uncheck "Hide extensions for known file types" 9.3/ Double click run_fpdb.bat
9.3/ Double click run_fpdb.bat 9.4/ check the contents of pyfpdb\fpdb.exe.log, deal with any errors thrown
9.4/ check the contents of pyfpdb\fpdb.exe.log, deal with any errors thrown
9.5/ hopefully, fpdb will run
9.5/ hopefully, fpdb will run 9.6/ Try out a few options, deal with any errors reported
9.6/ Try out a few options, deal with any errors reported
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.
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 pruning
Step 11 pruning ---------------
---------------
11.1/ The generated folder is 100+MB and can be pruned by removing the following directories:
11.1/ The generated folder is 100+MB and can be pruned by removing the following directories:
pyfpdb/lib/glib-2.0
pyfpdb/lib/glib-2.0 pyfpdb/lib/pkgconfig
pyfpdb/lib/pkgconfig pyfpdb/share/aclocal
pyfpdb/share/aclocal pyfpdb/share/doc
pyfpdb/share/doc pyfpdb/share/glib-2.0
pyfpdb/share/glib-2.0 pyfpdb/share/gtk-2.0
pyfpdb/share/gtk-2.0 pyfpdb/share/gtk-doc
pyfpdb/share/gtk-doc pyfpdb/share/locale
pyfpdb/share/locale pyfpdb/share/man
pyfpdb/share/man
Step 12 rename folder
Step 12 rename folder ---------------------
---------------------
If needed, rename the folder to something meaningful to the community. If you have built for NoSSE, append anyCPU to the directory name.
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
Step 13 Compress to executable archive --------------------------------------
--------------------------------------
13.1/ Download and install 7zip 914 ... http://sourceforge.net/projects/sevenzip/files/7-Zip/9.14/7z914.exe/download
13.1/ Download and install 7zip 914 ... http://sourceforge.net/projects/sevenzip/files/7-Zip/9.14/7z914.exe/download 13.2/ Rightclick on fpdb executable folder, select 7zip Add to archive... select SFX archive option switch
13.2/ Rightclick on fpdb executable folder, select 7zip Add to archive... select SFX archive option switch 13.3/ Test the created exe file
13.3/ Test the created exe file
Step 14 If you need to build again for a different SSE level
Step 14 If you need to build again for a different SSE level ------------------------------------------------------------
------------------------------------------------------------
Go back to step 5 and run again.
Go back to step 5 and run again.

View File

@ -32,14 +32,10 @@ Py2exe script for fpdb.
#HOW TO USE this script: #HOW TO USE this script:
# #
#- cd to the folder where this script is stored, usually .../pyfpdb. #- cd to the folder where this script is stored, usually ...packaging/windows
# [If there are build and dist subfolders present , delete them to get #- Run the script with python "py2exe_setup.py py2exe"
# rid of earlier builds. Update: script now does this for you] #- You will frequently get messages about missing .dll files.just assume other
#- Run the script with "py2exe_setup.py py2exe" # person will have them? we have copyright issues including some dll's
#- You will frequently get messages about missing .dll files. E. g.,
# MSVCP90.dll. These are somewhere in your windows install, so you
# can just copy them to your working folder. (or just assume other
# person will have them? any copyright issues with including them?)
#- If it works, you'll have a new dir fpdb-YYYYMMDD-exe 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 # contain 2 dirs; gfx and pyfpdb and run_fpdb.bat
#- [ This bit is now automated: #- [ This bit is now automated:
@ -49,27 +45,11 @@ Py2exe script for fpdb.
#- You can (should) then prune the etc/, lib/ and share/ folders to #- 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) # remove components we don't need. (see output at end of program run)
# sqlcoder notes: this worked for me with the following notes:
#- I used the following versions:
# python 2.5.4
# gtk+ 2.14.7 (gtk_2.14.7-20090119)
# pycairo 1.4.12-2
# pygobject 2.14.2-2
# pygtk 2.12.1-3
# matplotlib 0.98.3
# numpy 1.4.0
# py2exe-0.6.9 for python 2.5
#
#- I also copied these dlls manually from <gtk>/bin to /dist :
#
# libgobject-2.0-0.dll
# libgdk-win32-2.0-0.dll
#
# Now updated to work with python 2.6 + related dependencies
# See walkthrough in packaging directory for versions used # See walkthrough in packaging directory for versions used
# Updates to this script have broken python 2.5 compatibility (gio module, msvcr71 references now msvcp90)
# steffeN: Doesnt seem necessary to gettext-ify this, but feel free to if you disagree # 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
import os import os
import sys import sys
@ -86,33 +66,14 @@ import py2exe
import glob import glob
import matplotlib import matplotlib
import shutil import shutil
from datetime import date #from datetime import date
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname): def isSystemDLL(pathname):
#dwmapi appears to be vista-specific file, not XP #dwmapi appears to be vista-specific file, not XP
if os.path.basename(pathname).lower() in ("dwmapi.dll"): if os.path.basename(pathname).lower() in ("dwmapi.dll"):
return 0 return 0
return origIsSystemDLL(pathname) return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL
def remove_tree(top):
# Delete everything reachable from the directory named in 'top',
# assuming there are no symbolic links.
# CAUTION: This is dangerous! For example, if top == '/', it
# 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','pyfpdb',dist_dirname) and os.path.basename(os.getcwd()) == 'pyfpdb':
#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))
for name in dirs:
os.rmdir(os.path.join(root, name))
os.rmdir(top)
def test_and_remove(top): def test_and_remove(top):
if os.path.exists(top): if os.path.exists(top):
@ -121,31 +82,64 @@ def test_and_remove(top):
else: else:
print "Unexpected file '"+top+"' found. Exiting." print "Unexpected file '"+top+"' found. Exiting."
exit() exit()
def remove_tree(top):
# Delete everything reachable from the directory named in 'top',
# assuming there are no symbolic links.
# CAUTION: This is dangerous! For example, if top == '/', it
# 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',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))
for name in dirs:
os.rmdir(os.path.join(root, name))
os.rmdir(top)
today = date.today().strftime('%Y%m%d') def copy_tree(source,destination):
print "\n" + r"Output will be created in \pyfpdb\ and \fpdb_"+today+'\\' source = source.replace('\\', '\\\\')
#print "Enter value for XXX (any length): ", # the comma means no newline destination = destination.replace('\\', '\\\\')
#xxx = sys.stdin.readline().rstrip() print "*** Copying " + source + " to " + destination + " ***"
dist_dirname = r'fpdb-' + today + '-exe' shutil.copytree( source, destination )
dist_dir = r'..\fpdb-' + today + '-exe'
print
# remove build and dist dirs if they exist def copy_file(source,destination):
source = source.replace('\\', '\\\\')
destination = destination.replace('\\', '\\\\')
print "*** Copying " + source + " to " + destination + " ***"
shutil.copy( source, destination )
fpdbver = '0.20.906'
distdir = r'fpdb-' + fpdbver
rootdir = r'../../' #cwd is normally /packaging/windows
pydir = rootdir+'pyfpdb/'
gfxdir = rootdir+'gfx/'
sys.path.append( pydir ) # allows fpdb modules to be found by options/includes below
print "\n" + r"Output will be created in "+distdir
print "*** Cleaning working folders ***"
test_and_remove('dist') test_and_remove('dist')
test_and_remove('build') test_and_remove('build')
test_and_remove('pyfpdb') test_and_remove(distdir)
test_and_remove(dist_dirname) print "*** Building now in dist folder ***"
origIsSystemDLL = py2exe.build_exe.isSystemDLL
py2exe.build_exe.isSystemDLL = isSystemDLL
setup( setup(
name = 'fpdb', name = 'fpdb',
description = 'Free Poker DataBase', description = 'Free Poker DataBase',
version = '0.20.903', version = fpdbver,
windows = [ {'script': 'fpdb.pyw', "icon_resources": [(1, "../gfx/fpdb_large_icon.ico")]}, windows = [ {'script': pydir+'fpdb.pyw', "icon_resources": [(1, gfxdir+"fpdb_large_icon.ico")]},
{'script': 'HUD_main.pyw', }, {'script': pydir+'HUD_main.pyw', },
{'script': 'Configuration.py', } {'script': pydir+'Configuration.py', }
], ],
options = {'py2exe': { options = {'py2exe': {
@ -158,74 +152,56 @@ setup(
,'PartyPokerToFpdb', 'PokerStarsToFpdb' ,'PartyPokerToFpdb', 'PokerStarsToFpdb'
,'UltimateBetToFpdb', 'Win2dayToFpdb' ,'UltimateBetToFpdb', 'Win2dayToFpdb'
], ],
'excludes' : ['_tkagg', '_agg2', 'cocoaagg', 'fltkagg'], # surely we need this? '_gtkagg' 'excludes' : ['_tkagg', '_agg2', 'cocoaagg', 'fltkagg'],
'dll_excludes': ['libglade-2.0-0.dll', 'libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll' 'dll_excludes': ['libglade-2.0-0.dll', 'libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll'
, 'msvcr90.dll', 'MSVCP90.dll', 'MSVCR90.dll','msvcr90.dll'], # these are vis c / c++ runtimes, and must not be redistributed , 'msvcr90.dll', 'MSVCP90.dll', 'MSVCR90.dll','msvcr90.dll'], # these are vis c / c++ runtimes, and must not be redistributed
} }
}, },
# files in 2nd value in tuple are moved to dir named in 1st value # files in 2nd value in tuple are moved to dir named in 1st value
#data_files updated for new locations of licences + readme nolonger exists # this code will not walk a tree
data_files = [('', ['HUD_config.xml.example', 'Cards01.png', 'logging.conf', '../agpl-3.0.txt', '../fdl-1.2.txt', '../gpl-3.0.txt', '../gpl-2.0.txt', '../mit.txt', '../readme.txt']) # Note: cwd for 1st value is packaging/windows/dist (this is confusing BTW)
,(dist_dir, [r'..\run_fpdb.bat']) # Note: only include files here which are to be put into the package pyfpdb folder or subfolders
,( dist_dir + r'\gfx', glob.glob(r'..\gfx\*.*') )
# line below has problem with fonts subdir ('not a regular file') data_files = [('', glob.glob(rootdir+'*.txt'))
#,(r'matplotlibdata', glob.glob(r'c:\python25\Lib\site-packages\matplotlib\mpl-data\*')) ,('', [pydir+'HUD_config.xml.example',pydir+'Cards01.png', pydir+'logging.conf'])
] + matplotlib.get_py2exe_datafiles() ] + matplotlib.get_py2exe_datafiles()
) )
# rename completed output package as pyfpdb # ,(distdir, [rootdir+'run_fpdb.bat'])
os.rename('dist', 'pyfpdb') # ,(distdir+r'\gfx', glob.glob(gfxdir+'*.*'))
# ] +
print "*** py2exe build phase complete ***"
# pull pytz zoneinfo into pyfpdb package folder # copy zone info and fpdb translation folders
src_dir = r'c:\python26\Lib\site-packages\pytz\zoneinfo' copy_tree (r'c:\python26\Lib\site-packages\pytz\zoneinfo', os.path.join(r'dist', 'zoneinfo'))
src_dir = src_dir.replace('\\', '\\\\') copy_tree (pydir+r'locale', os.path.join(r'dist', 'locale'))
dest_dir = os.path.join(r'pyfpdb', 'zoneinfo')
shutil.copytree( src_dir, dest_dir )
# shunt pyfpdb package over to the distribution folder # create distribution folder and populate with gfx + bat
dest = os.path.join(dist_dirname, 'pyfpdb') copy_tree (gfxdir, os.path.join(distdir, 'gfx'))
# print "try renaming pyfpdb to", dest copy_file (rootdir+'run_fpdb.bat', distdir)
dest = dest.replace('\\', '\\\\')
# print "dest is now", dest
os.rename( 'pyfpdb', dest )
# prompt for gtk location print "*** Renaming dist folder as distribution pyfpdb folder ***"
dest = os.path.join(distdir, 'pyfpdb')
os.rename( 'dist', dest )
print "*** copying GTK runtime ***"
gtk_dir = "" gtk_dir = ""
while not os.path.exists(gtk_dir): while not os.path.exists(gtk_dir):
print "Enter directory name for GTK (e.g. c:\code\gtk_2.14.7-20090119)\n: ", # the comma means no newline print "Enter directory name for GTK (e.g. c:/gtk) : ", # the comma means no newline
gtk_dir = sys.stdin.readline().rstrip() gtk_dir = sys.stdin.readline().rstrip()
print "\ncopying files and dirs from ", gtk_dir, "to", dest.replace('\\\\', '\\'), "..." print "*** copying GTK runtime ***"
src = os.path.join(gtk_dir, 'bin', 'libgdk-win32-2.0-0.dll') dest = os.path.join(distdir, 'pyfpdb')
src = src.replace('\\', '\\\\') copy_file(os.path.join(gtk_dir, 'bin', 'libgdk-win32-2.0-0.dll'), dest )
shutil.copy( src, 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'))
src = os.path.join(gtk_dir, 'bin', 'libgobject-2.0-0.dll') print "*** All done! ***"
src = src.replace('\\', '\\\\') test_and_remove('build')
shutil.copy( src, dest ) print distdir+" is in the pyfpdb dir"
src_dir = os.path.join(gtk_dir, 'etc')
src_dir = src_dir.replace('\\', '\\\\')
dest_dir = os.path.join(dest, 'etc')
dest_dir = dest_dir.replace('\\', '\\\\')
shutil.copytree( src_dir, dest_dir )
src_dir = os.path.join(gtk_dir, 'lib')
src_dir = src_dir.replace('\\', '\\\\')
dest_dir = os.path.join(dest, 'lib')
dest_dir = dest_dir.replace('\\', '\\\\')
shutil.copytree( src_dir, dest_dir )
src_dir = os.path.join(gtk_dir, 'share')
src_dir = src_dir.replace('\\', '\\\\')
dest_dir = os.path.join(dest, 'share')
dest_dir = dest_dir.replace('\\', '\\\\')
shutil.copytree( src_dir, dest_dir )
print "\nIf py2exe was successful you should now have a new dir"
print dist_dirname+" in your pyfpdb dir"
print """ print """
The following dirs can probably removed to make the final package smaller: The following dirs can probably removed to make the final package smaller:
@ -243,5 +219,3 @@ pyfpdb/share/themes/Default
Use 7-zip to zip up the distribution and create a self extracting archive and that's it! Use 7-zip to zip up the distribution and create a self extracting archive and that's it!
""" """