From 4a622529c60a808872d12ec9104a61f26b13f7fe Mon Sep 17 00:00:00 2001 From: gimick Date: Fri, 18 Mar 2011 21:16:34 +0000 Subject: [PATCH 1/3] py2exe: more automation - walkthrough & script changes --- .../windows/py2exeWalkthroughPython27.txt | 34 +++------ packaging/windows/py2exe_setup.py | 71 +++++++++---------- 2 files changed, 46 insertions(+), 59 deletions(-) diff --git a/packaging/windows/py2exeWalkthroughPython27.txt b/packaging/windows/py2exeWalkthroughPython27.txt index c1fe722c..f2ad23f6 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 downloaded. We will force a nosse version, to minimise problems on +For this reason, do not just run the installer. 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/ If you are wanting to build a package which works on all CPU's, install noSSE as follows: +5.3.3/ You are normally wanting to build a package which works on all CPU's, so install for noSSE as follows: dos> cd Desktop dos> numpy-1.5.1-win32-superpack-python2.7.exe /arch nosse @@ -159,6 +159,11 @@ 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 @@ -167,7 +172,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. -c:\GTK +Enter c:\GTK 6.3/ If there are no errors reported, it has probably worked, we will test soon. @@ -205,27 +210,16 @@ 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 pruning +Step 11 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 +Has been deleted 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. - +If needed, rename the folder to something meaningful to the community. Step 13 Compress to executable archive -------------------------------------- @@ -233,9 +227,3 @@ 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.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 64178a01..270bea97 100644 --- a/packaging/windows/py2exe_setup.py +++ b/packaging/windows/py2exe_setup.py @@ -24,32 +24,25 @@ 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-YYYYMMDD-exe which should +#- If it works, you'll have a new dir fpdb-version 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 @@ -61,6 +54,10 @@ 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 @@ -75,12 +72,15 @@ 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',distdir) and os.path.basename(os.getcwd()) == 'windows': - #print "removing directory '"+top+"' ..." + if (top in ('build','dist') or top.startswith(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,8 +111,6 @@ 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/' @@ -172,9 +170,6 @@ 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 @@ -185,7 +180,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 distribution pyfpdb folder ***" +print "*** Renaming dist folder as pyfpdb folder ***" dest = os.path.join(distdir, 'pyfpdb') os.rename( 'dist', dest ) @@ -203,23 +198,27 @@ 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 "*** All done! ***" +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 ***" test_and_remove('build') -print distdir+" is in the pyfpdb dir" -print """ -The following dirs can probably removed to make the final package smaller: -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 "*** 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')) -Use 7-zip to zip up the distribution and create a self extracting archive and that's it! -""" +print "***++++++++++++++++++++++++++++++++++++++++++++++" +print "All done!" +print "The distribution folder "+distdir+" is in the pyfpdb dir" +print "***++++++++++++++++++++++++++++++++++++++++++++++" From 632724d5c035e449018ec69695a9c01b08416eb4 Mon Sep 17 00:00:00 2001 From: gimick Date: Fri, 18 Mar 2011 21:46:21 +0000 Subject: [PATCH 2/3] py2exe: remove two files with windows line endings. To be fixed in next commit --- packaging/windows/py2exe_setup.py | 224 -------------------- packaging/windows/pypoker138walkthrough.txt | 210 ------------------ 2 files changed, 434 deletions(-) delete mode 100644 packaging/windows/py2exe_setup.py delete mode 100644 packaging/windows/pypoker138walkthrough.txt diff --git a/packaging/windows/py2exe_setup.py b/packaging/windows/py2exe_setup.py deleted file mode 100644 index 270bea97..00000000 --- a/packaging/windows/py2exe_setup.py +++ /dev/null @@ -1,224 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -"""setup.py - -Py2exe script for fpdb. -""" -# Copyright 2009-2011, Ray E. Barker -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -######################################################################## - -#TODO: -# think about an installer - -#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 -# contain 2 dirs; gfx and pyfpdb and run_fpdb.bat - -# 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 - -# get out now if parameter not passed -try: - sys.argv[1] <> "" -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 -import matplotlib -import shutil -import cdecimal - -def isSystemDLL(pathname): - #dwmapi appears to be vista-specific file, not XP - if os.path.basename(pathname).lower() in ("dwmapi.dll"): - return 0 - 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', - # 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') or top.startswith(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) - -def copy_tree(source,destination): - source = source.replace('\\', '\\\\') - destination = destination.replace('\\', '\\\\') - print "*** Copying " + source + " to " + destination + " ***" - shutil.copytree( source, destination ) - -def copy_file(source,destination): - source = source.replace('\\', '\\\\') - destination = destination.replace('\\', '\\\\') - print "*** Copying " + source + " to " + destination + " ***" - shutil.copy( source, destination ) - - -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('build') -test_and_remove(distdir) - -print "*** Building now in dist folder ***" - -origIsSystemDLL = py2exe.build_exe.isSystemDLL -py2exe.build_exe.isSystemDLL = isSystemDLL - -setup( - name = 'fpdb', - description = 'Free Poker DataBase', - version = fpdbver, - - windows = [ {'script': pydir+'fpdb.pyw', "icon_resources": [(1, gfxdir+"fpdb_large_icon.ico")]}, - {'script': pydir+'HUD_main.pyw', }, - {'script': pydir+'Configuration.py', } - ], - - console = [ {'script': pydir+'Stove.py', } - ], - - options = {'py2exe': { - 'packages' : ['encodings', 'matplotlib'], - 'includes' : ['gio', 'cairo', 'pango', 'pangocairo', 'atk', 'gobject' - ,'matplotlib.numerix.random_array' - ,'AbsoluteToFpdb', 'BetfairToFpdb' - ,'CarbonToFpdb', 'EverleafToFpdb' - ,'FulltiltToFpdb', 'iPokerToFpdb' - ,'OnGameToFpdb', 'PartyPokerToFpdb' - ,'PkrToFpdb', 'PokerStarsToFpdb' - ,'Win2dayToFpdb', 'WinamaxToFpdb' - ], - 'excludes' : ['_tkagg', '_agg2', 'cocoaagg', 'fltkagg'], - '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 - } - }, - - # files in 2nd value in tuple are moved to dir named in 1st value - # this code will not walk a tree - # Note: cwd for 1st value is packaging/windows/dist (this is confusing BTW) - # Note: only include files here which are to be put into the package pyfpdb folder or subfolders - - data_files = [('', glob.glob(rootdir+'*.txt')) - ,('', [pydir+'HUD_config.xml.example',pydir+'Cards01.png', pydir+'logging.conf']) - ] + matplotlib.get_py2exe_datafiles() -) - -print "*** py2exe build phase complete ***" - -# copy zone info and fpdb translation folders -copy_tree (r'c:\python27\Lib\site-packages\pytz\zoneinfo', os.path.join(r'dist', 'zoneinfo')) -copy_tree (pydir+r'locale', os.path.join(r'dist', 'locale')) - -# create distribution folder and populate with gfx + bat -copy_tree (gfxdir, os.path.join(distdir, 'gfx')) -copy_file (rootdir+'run_fpdb.bat', distdir) - -print "*** Renaming dist folder as pyfpdb folder ***" -dest = os.path.join(distdir, 'pyfpdb') -os.rename( 'dist', dest ) - -print "*** copying GTK runtime ***" -gtk_dir = "" -while not os.path.exists(gtk_dir): - print "Enter directory name for GTK (e.g. c:/gtk) : ", # the comma means no newline - gtk_dir = sys.stdin.readline().rstrip() - -print "*** copying GTK runtime ***" -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 ***" -test_and_remove('build') - -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')) - -print "***++++++++++++++++++++++++++++++++++++++++++++++" -print "All done!" -print "The distribution folder "+distdir+" is in the pyfpdb dir" -print "***++++++++++++++++++++++++++++++++++++++++++++++" diff --git a/packaging/windows/pypoker138walkthrough.txt b/packaging/windows/pypoker138walkthrough.txt deleted file mode 100644 index f4e5f3af..00000000 --- a/packaging/windows/pypoker138walkthrough.txt +++ /dev/null @@ -1,210 +0,0 @@ -pypokereval build for windows stepbystep guide ----------------------------------------------- - -Created by Gimick on 3rd December 2010 -Updated for py27 by Gimick 27th Feb 2011 - -This walkthrough is derived with the assistance of EricBlade and the build notes -supplied by Loic Dachary http://dachary.org/ - -Content is available under the the GNU Affero General Public License version 3 - - -0. Build environ ----------------- - -We are building against the 2008 runtime because Python 2.7 - has the same dependency (msvcr90.dll version 9.0.21022.8) - -Using winXPhome 32 bit - -1 Visual studio ---------------- - -1.1/ Get the ISO CD from here ... http://www.microsoft.com/express/Downloads/#2008-All - -1.2/ Run and install Visual C++ only, don't bother with the additional packages offered - -This package will run 30 days before registration is needed - -2. Python runtime ------------------ - -2.1/ Install python runtime from here ... - -Python 2.7 ... http://python.org/ftp/python/2.7/python-2.7.msi - -3. Source install ------------------ - -3.1/ grab sources from here - -pypoker-eval v138 ... http://download.gna.org/pokersource/sources/pypoker-eval-138.0.tar.gz -poker-eval v138 ... http://download.gna.org/pokersource/sources/poker-eval-138.0.tar.gz - -3.2/ unpack and place the pypoker-eval-138 directory in c:\ -3.2.1/ rename to pypoker-eval - -3.3/ unpack and place the poker-eval-138 directory in c:\ -3.3.1/ rename to poker-eval - -Important: the build will fail with bizarre missing header files if the project is placed - in a directory containing a space character - you have been warned! - -4. Update source file ---------------------- - -4.1/ dos> write c:/pypoker-eval/pypokereval.c - -change this: - -#define VERSION_NAME(W) W##2_4 -#define PYTHON_VERSION "2_4" - -to be this: - -#define VERSION_NAME(W) W##2_7 -#define PYTHON_VERSION "2_7" - -- - - - - - - -Move this block of code: - -#ifdef _DEBUG // for Windows python23_d.lib is not in distribution... ugly but works - #undef _DEBUG - #include - #define _DEBUG -#else - #include -#endif - -To be after this line: - -#include "enumdefs.h" - -4.2/ save and exit - -- - - - - - -4.3/ dos> write c:/pypoker-eval/pokereval.py - -Comment-out this line: - -_pokereval = __import__('_pokereval_' + sys.version[0] + '_' + sys.version[2]) - -Insert this one in its' place: - -import _pokereval_2_7 as _pokereval - - -4.4/ save and exit - - -5. Build pre-preparation ------------------------- - -(Here we are converting the two project definition files to 2008) - -5.1 navigate to directory c:/poker-eval -5.1.1 double click poker-eval.vcproj -5.1.2 Visual studio will launch and make a conversion - accept all defaults -5.1.3 exit and save - -5.2 navigate to directory c:/pypoker-eval -5.2.1 double click pypoker-eval.vcproj -5.2.2 Visual studio will launch and make a conversion - accept all defaults -5.2.3 exit - -6. build preparation --------------------- - -6.2 navigate to directory c:/pypoker-eval -6.2.1 double click pypoker-eval.vcproj - visual studio should launch - -6.2.3 Select Build...configuration manager... - Select "active solution configuration" to "Release" - (The configuration for both projects will change to "Release") - -6.2.3 Close the configuration manager - -6.2.4 In the solution explorer window, hilight pythonpoker-eval / right mouse / properties... - -6.2.5 In the pythonpoker-eval properties dialog, - -change references to "python24" to "python27" in the following: - - = C/C++/Additional Include Directories/ - = linker/general/Additional library directories - = linker/input/Additional Dependencies - -Change the following - - = linker/generate debug info - set to No - -6.2.6 Apply all changes to the properties dialog and close - -6.3 Exit from visual studio - -7. Build poker eval -------------------- - -7.1 navigate to directory c:/poker-eval -7.1.1 double click poker-eval.vcproj -7.1.2 Visual studio will launch - -7.2 In the solution explorer window, hilight poker-eval / right mouse / build - -7.3 There should be no errors - -7.4 Exit from visual studio - - -8. Build pypoker eval ---------------------- - -8.1 navigate to directory c:/pypoker-eval -8.1.1 double click pypoker-eval.vcproj -8.1.2 Visual studio will launch - -8.2 In the solution explorer window, hilight pythonpoker-eval / right mouse / build - -8.3 There should be no errors (but a few warnings) - -8.4 Exit from visual studio - -9. Wrap-up ----------- - -9.1 Navigate to c:/pypoker-eval/release -9.2 the output file is pypokereval.dll -9.3 rename this file to _pokereval_2_7.pyd - -9.4 create a zip file containing : - -_pokereval_2_7.pyd from releases -test.py from pypoker-eval-138.0 -pokereval.py from pypoker-eval-138.0 -poker-eval.vcproj from c:\poker-eval -pypoker-eval.vcproj from c:\pypoker-eval -pypokereval.c from c:\pypoker-eval - -Remember to include the version (138), python 27 and win32 in the package filename - -10. Testing ------------ - -Python 2.7 must be installed - -10.1 Extract the zip file created in 9.4 into a new directory -10.2 Change directory to the directory in 10.1 -10.3 execute dos> c:\Python27\python.exe test.py -10.4 hand-output should scroll down the screen -10.5 start the python interpreter -10.6 >>> import pokereval -10.7 No errors should be seen - -11. Packaging -------------- - -Please follow pypokereval-win32-packaging-walkthrough.txt in the same directory as this walkthrough. - From f0798111e56b6bc886f5c941a120b9bd6889a666 Mon Sep 17 00:00:00 2001 From: gimick Date: Fri, 18 Mar 2011 22:01:51 +0000 Subject: [PATCH 3/3] py2exe: recommit files to correct line endings --- packaging/windows/py2exe_setup.py | 224 ++++++++++++++++++++ packaging/windows/pypoker138walkthrough.txt | 210 ++++++++++++++++++ 2 files changed, 434 insertions(+) create mode 100644 packaging/windows/py2exe_setup.py create mode 100644 packaging/windows/pypoker138walkthrough.txt diff --git a/packaging/windows/py2exe_setup.py b/packaging/windows/py2exe_setup.py new file mode 100644 index 00000000..f472a320 --- /dev/null +++ b/packaging/windows/py2exe_setup.py @@ -0,0 +1,224 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""setup.py + +Py2exe script for fpdb. +""" +# Copyright 2009-2011, Ray E. Barker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +######################################################################## + +#TODO: +# think about an installer + +#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 +# contain 2 dirs; gfx and pyfpdb and run_fpdb.bat + +# 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 + +# get out now if parameter not passed +try: + sys.argv[1] <> "" +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 +import matplotlib +import shutil +import cdecimal + +def isSystemDLL(pathname): + #dwmapi appears to be vista-specific file, not XP + if os.path.basename(pathname).lower() in ("dwmapi.dll"): + return 0 + 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', + # 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') or top.startswith(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) + +def copy_tree(source,destination): + source = source.replace('\\', '\\\\') + destination = destination.replace('\\', '\\\\') + print "*** Copying " + source + " to " + destination + " ***" + shutil.copytree( source, destination ) + +def copy_file(source,destination): + source = source.replace('\\', '\\\\') + destination = destination.replace('\\', '\\\\') + print "*** Copying " + source + " to " + destination + " ***" + shutil.copy( source, destination ) + + +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('build') +test_and_remove(distdir) + +print "*** Building now in dist folder ***" + +origIsSystemDLL = py2exe.build_exe.isSystemDLL +py2exe.build_exe.isSystemDLL = isSystemDLL + +setup( + name = 'fpdb', + description = 'Free Poker DataBase', + version = fpdbver, + + windows = [ {'script': pydir+'fpdb.pyw', "icon_resources": [(1, gfxdir+"fpdb_large_icon.ico")]}, + {'script': pydir+'HUD_main.pyw', }, + {'script': pydir+'Configuration.py', } + ], + + console = [ {'script': pydir+'Stove.py', } + ], + + options = {'py2exe': { + 'packages' : ['encodings', 'matplotlib'], + 'includes' : ['gio', 'cairo', 'pango', 'pangocairo', 'atk', 'gobject' + ,'matplotlib.numerix.random_array' + ,'AbsoluteToFpdb', 'BetfairToFpdb' + ,'CarbonToFpdb', 'EverleafToFpdb' + ,'FulltiltToFpdb', 'iPokerToFpdb' + ,'OnGameToFpdb', 'PartyPokerToFpdb' + ,'PkrToFpdb', 'PokerStarsToFpdb' + ,'Win2dayToFpdb', 'WinamaxToFpdb' + ], + 'excludes' : ['_tkagg', '_agg2', 'cocoaagg', 'fltkagg'], + '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 + } + }, + + # files in 2nd value in tuple are moved to dir named in 1st value + # this code will not walk a tree + # Note: cwd for 1st value is packaging/windows/dist (this is confusing BTW) + # Note: only include files here which are to be put into the package pyfpdb folder or subfolders + + data_files = [('', glob.glob(rootdir+'*.txt')) + ,('', [pydir+'HUD_config.xml.example',pydir+'Cards01.png', pydir+'logging.conf']) + ] + matplotlib.get_py2exe_datafiles() +) + +print "*** py2exe build phase complete ***" + +# copy zone info and fpdb translation folders +copy_tree (r'c:\python27\Lib\site-packages\pytz\zoneinfo', os.path.join(r'dist', 'zoneinfo')) +copy_tree (pydir+r'locale', os.path.join(r'dist', 'locale')) + +# create distribution folder and populate with gfx + bat +copy_tree (gfxdir, os.path.join(distdir, 'gfx')) +copy_file (rootdir+'run_fpdb.bat', distdir) + +print "*** Renaming dist folder as pyfpdb folder ***" +dest = os.path.join(distdir, 'pyfpdb') +os.rename( 'dist', dest ) + +print "*** copying GTK runtime ***" +gtk_dir = "" +while not os.path.exists(gtk_dir): + print "Enter directory name for GTK (e.g. c:/gtk) : ", # the comma means no newline + gtk_dir = sys.stdin.readline().rstrip() + +print "*** copying GTK runtime ***" +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 ***" +test_and_remove('build') + +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')) + +print "***++++++++++++++++++++++++++++++++++++++++++++++" +print "All done!" +print "The distribution folder "+distdir+" is in the pyfpdb dir" +print "***++++++++++++++++++++++++++++++++++++++++++++++" diff --git a/packaging/windows/pypoker138walkthrough.txt b/packaging/windows/pypoker138walkthrough.txt new file mode 100644 index 00000000..62004e7a --- /dev/null +++ b/packaging/windows/pypoker138walkthrough.txt @@ -0,0 +1,210 @@ +pypokereval build for windows stepbystep guide +---------------------------------------------- + +Created by Gimick on 3rd December 2010 +Updated for py27 by Gimick 27th Feb 2011 + +This walkthrough is derived with the assistance of EricBlade and the build notes +supplied by Loic Dachary http://dachary.org/ + +Content is available under the the GNU Affero General Public License version 3 + + +0. Build environ +---------------- + +We are building against the 2008 runtime because Python 2.7 + has the same dependency (msvcr90.dll version 9.0.21022.8) + +Using winXPhome 32 bit + +1 Visual studio +--------------- + +1.1/ Get the ISO CD from here ... http://www.microsoft.com/express/Downloads/#2008-All + +1.2/ Run and install Visual C++ only, don't bother with the additional packages offered + +This package will run 30 days before registration is needed + +2. Python runtime +----------------- + +2.1/ Install python runtime from here ... + +Python 2.7 ... http://python.org/ftp/python/2.7/python-2.7.msi + +3. Source install +----------------- + +3.1/ grab sources from here + +pypoker-eval v138 ... http://download.gna.org/pokersource/sources/pypoker-eval-138.0.tar.gz +poker-eval v138 ... http://download.gna.org/pokersource/sources/poker-eval-138.0.tar.gz + +3.2/ unpack and place the pypoker-eval-138 directory in c:\ +3.2.1/ rename to pypoker-eval + +3.3/ unpack and place the poker-eval-138 directory in c:\ +3.3.1/ rename to poker-eval + +Important: the build will fail with bizarre missing header files if the project is placed + in a directory containing a space character - you have been warned! + +4. Update source file +--------------------- + +4.1/ dos> write c:/pypoker-eval/pypokereval.c + +change this: + +#define VERSION_NAME(W) W##2_4 +#define PYTHON_VERSION "2_4" + +to be this: + +#define VERSION_NAME(W) W##2_7 +#define PYTHON_VERSION "2_7" + +- - - - - - + +Move this block of code: + +#ifdef _DEBUG // for Windows python23_d.lib is not in distribution... ugly but works + #undef _DEBUG + #include + #define _DEBUG +#else + #include +#endif + +To be after this line: + +#include "enumdefs.h" + +4.2/ save and exit + +- - - - - + +4.3/ dos> write c:/pypoker-eval/pokereval.py + +Comment-out this line: + +_pokereval = __import__('_pokereval_' + sys.version[0] + '_' + sys.version[2]) + +Insert this one in its' place: + +import _pokereval_2_7 as _pokereval + + +4.4/ save and exit + + +5. Build pre-preparation +------------------------ + +(Here we are converting the two project definition files to 2008) + +5.1 navigate to directory c:/poker-eval +5.1.1 double click poker-eval.vcproj +5.1.2 Visual studio will launch and make a conversion - accept all defaults +5.1.3 exit and save + +5.2 navigate to directory c:/pypoker-eval +5.2.1 double click pypoker-eval.vcproj +5.2.2 Visual studio will launch and make a conversion - accept all defaults +5.2.3 exit + +6. build preparation +-------------------- + +6.2 navigate to directory c:/pypoker-eval +6.2.1 double click pypoker-eval.vcproj - visual studio should launch + +6.2.3 Select Build...configuration manager... + Select "active solution configuration" to "Release" + (The configuration for both projects will change to "Release") + +6.2.3 Close the configuration manager + +6.2.4 In the solution explorer window, hilight pythonpoker-eval / right mouse / properties... + +6.2.5 In the pythonpoker-eval properties dialog, + +change references to "python24" to "python27" in the following: + + = C/C++/Additional Include Directories/ + = linker/general/Additional library directories + = linker/input/Additional Dependencies + +Change the following + + = linker/generate debug info - set to No + +6.2.6 Apply all changes to the properties dialog and close + +6.3 Exit from visual studio + +7. Build poker eval +------------------- + +7.1 navigate to directory c:/poker-eval +7.1.1 double click poker-eval.vcproj +7.1.2 Visual studio will launch + +7.2 In the solution explorer window, hilight poker-eval / right mouse / build + +7.3 There should be no errors + +7.4 Exit from visual studio + + +8. Build pypoker eval +--------------------- + +8.1 navigate to directory c:/pypoker-eval +8.1.1 double click pypoker-eval.vcproj +8.1.2 Visual studio will launch + +8.2 In the solution explorer window, hilight pythonpoker-eval / right mouse / build + +8.3 There should be no errors (but a few warnings) + +8.4 Exit from visual studio + +9. Wrap-up +---------- + +9.1 Navigate to c:/pypoker-eval/release +9.2 the output file is pypokereval.dll +9.3 rename this file to _pokereval_2_7.pyd + +9.4 create a zip file containing : + +_pokereval_2_7.pyd from releases +test.py from pypoker-eval-138.0 +pokereval.py from pypoker-eval-138.0 +poker-eval.vcproj from c:\poker-eval +pypoker-eval.vcproj from c:\pypoker-eval +pypokereval.c from c:\pypoker-eval + +Remember to include the version (138), python 27 and win32 in the package filename + +10. Testing +----------- + +Python 2.7 must be installed + +10.1 Extract the zip file created in 9.4 into a new directory +10.2 Change directory to the directory in 10.1 +10.3 execute dos> c:\Python27\python.exe test.py +10.4 hand-output should scroll down the screen +10.5 start the python interpreter +10.6 >>> import pokereval +10.7 No errors should be seen + +11. Packaging +------------- + +Please follow pypokereval-win32-packaging-walkthrough.txt in the same directory as this walkthrough. +