1 PY2EXE walkthrough for Python 2.7 & FPDB 0.2x
2 created on 27th Feb 2011 by Gimick
4 This walkthrough is derived from comments in the py2exe script made by Ray and SqlCoder
5 Additional information, formatting, updating to Python 2.6 and Python 2.7 and sequencing added by Gimick
6 Content is available under the the GNU Affero General Public License version 3
10 Step 0 Get a fresh XP installation
11 ----------------------------------
13 0.1/ Using XPhome or Pro 32bit
15 0.2/ Ensure the CPU supports SSE2 instruction set or better.
18 Step 1, dependency install
19 --------------------------
21 1.1/ install the following in sequence (accept all default options) there should be no errors !
23 Python 2.7 ... http://python.org/ftp/python/2.7/python-2.7.msi
24 matplotlib 1.0.1 ... http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0.1/matplotlib-1.0.1.win32-py2.7.exe/download
25 pygtk 2.22 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/pygtk-2.22.0-1.win32-py2.7.exe
26 pycairo 1.8.10 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.8/pycairo-1.8.10.win32-py2.7.exe
27 pyGobject X 2.26 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.26/pygobject-2.26.0-1.win32-py2.7.exe
28 pywin 216 ... http://sourceforge.net/projects/pywin32/files/pywin32/Build216/pywin32-216.win32-py2.7.exe/download
29 winpaths 0.1 ... http://pypi.python.org/packages/any/w/winpaths/winpaths-0.1.win32.exe
31 pypokereval 138 ... http://sourceforge.net/projects/fpdb/files/fpdb/pypoker-eval-win32/pokereval-138.win32-py2.7.exe/download
32 cdecimal 2.2 ... http://www.bytereef.org/software/mpdecimal/releases/cdecimal-2.2.win32-py2.7.msi
33 mysql-python 1.2.3 ... http://sourceforge.net/projects/fpdb/files/fpdb/MySQL-python-1.2.3-win32-py2.7/MySQL-python-1.2.3.win32-py2.7.exe/download
34 psycopg2 ... http://www.stickpeople.com/projects/python/win-psycopg/psycopg2-2.2.1.win32-py2.6-pg8.4.3-release.exe
36 (Note: stickpeople is the offical repository, not a community build)
38 py2exe 0.6.9 ... http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.7.exe/download
42 1.2.1/ The Winpaths package installer requires C++2005 runtime to install. This is not installed by default,
43 and is a complete pain to sort out, so we will instead install winpaths manually. This means that any uninstall
44 of winpaths will need to be done manually too.
46 1.2.2/ download winpaths zip:
47 winpaths 0.1 ... http://pypi.python.org/packages/source/w/winpaths/winpaths-0.1.zip
49 1.2.3/ extract winpaths.py from the zip file and place it in c:\python27\lib\site-packages\
51 1.2.4/ test by running python >>> import winpaths
53 1.3/ pytz fixup to work in an executable package
55 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.
56 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.
58 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.
59 The py2exe script copies the timezone datafiles into the package folder pyfpdb/zoneinfo.
61 Thanks to Jeff Peck <peck.jeff <at> gmail.com> on the py2exe mailing list for documenting this problem and solution.
63 1.3.1/ Navigate to C:\Python27\Lib\site-packages\pytz
64 1.3.2/ Edit __init__.py
65 1.3.3/ At line 55 replace the following line(s):
67 filename = os.path.join(os.path.dirname(__file__),
68 'zoneinfo', *name_parts)
72 filename = os.path.join(os.getcwd(), 'zoneinfo', *name_parts)
77 1.4/ Patch py2exe to stop popup runtime error message
79 see http://www.py2exe.org/index.cgi/StderrLog for technical info.
83 dos> write C:\Python27\Lib\site-packages\py2exe\boot_common.py
86 atexit.register(alert, 0,
87 "See the logfile '%s' for details" % fname,
90 #atexit.register(alert, 0,
91 # "See the logfile '%s' for details" % fname,
101 There are quite a few GTK packages needed, and rather than install them individually, I used the official AllinOne from the GTK project.
103 2,1/ Create a new folder c:\GTK
105 2.2/ Extract the following zip file into c:\GTK
107 gtk+ allinone 2.22.1 ... http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.1-20101227_win32.zip
109 2.3/ If everything has worked, you should have c:\GTK\bin \etc \lib \src and so on created.
111 2.4/ The /share/doc and /share/gtk-doc folders are huge, so can be emptied now (leave the /doc and /gtk-doc folders
112 in place, but delete the content)
115 Step 3 Set GTK into the PATH variable
116 -------------------------------------
118 The path for GTK isn't set by default, so need to let the o/s know where the GTK stuff is.
120 3.1/ Rightclick on mycomputer to show system properties
121 3.2/ select advanced/environment Variables
122 3.3/ in "system variables" NOT "user variables" do the following
123 3.3.1/ create a new item as name: GTK_BASEPATH value: c:\GTK
124 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;
126 3.4/ to check, open command prompt and do:
128 dos>path ... system should respond with ... PATH=c:\GTK\bin;C:\WIN........
130 3.5/ Give it a spin to test (hopefully an application will start, if not, something has gone wrong)
135 Step 4 Get the fpdb GIT tree
136 ----------------------------
138 4.1/ Best to take a copy to work with; following steps will assume that the fpdb folder is on the Desktop
139 4.2/ Edit the script in packaging/windows/py2exe_setup.py to set the fpdbver variable for this release
142 5.3/ Install correct Numpy for this build
143 -----------------------------------------
145 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.
147 For this reason, do not just run the installer. We will force a nosse version, to minimise problems on
150 5.3.1/ download the package to the Desktop
152 numpy 1.5.1 ... http://sourceforge.net/projects/numpy/files/NumPy/1.5.1/numpy-1.5.1-win32-superpack-python2.7.exe/download
154 5.3.3/ You are normally wanting to build a package which works on all CPU's, so install for noSSE as follows:
157 dos> numpy-1.5.1-win32-superpack-python2.7.exe /arch nosse
159 5.3.4/ At the end of the installation, click on "show details" to confirm the installation.
161 "Target CPU handles SSE2"
162 "Target CPU handles SSE3"
163 "nosse install (arch value: nosse)"
165 Extract: numpy-1.5.1-nosse.exe... 100%
166 Execute: "C:\DOCUME~1\user\LOCALS~1\Temp\numpy-1.5.1-nosse.exe"
169 Step 6 compile fpdb_folder_check.exe
170 ------------------------------------
173 Install minGW minimal installation
174 See instructions here....http://www.mingw.org/wiki/InstallationHOWTOforMinGW
177 dos>gcc fpdb_folder_check.c -o fpdb_folder_check.exe
179 Step 7 Run py2exe to generate fpdb.exe
180 --------------------------------------
182 7.0/ Set version number of build folder
183 dos> cd Desktop\fpdb\packaging\windows
184 dos> write py2exe_setup.py
185 change the value of fpdbver and save file
187 7.1/ Run the script to create the fpdb.exe bundle
189 dos> cd Desktop\fpdb\packaging\windows
190 dos> c:\python27\python.exe py2exe_setup.py py2exe
192 wait a while, watch lots of copying and whatever.
194 7.2/ You should next get prompted for the GTK folder.
197 7.3/ If there are no errors reported, it has probably worked, we will test soon.
201 There is a warning about dll's not included "umath.pyd - c:\Python27\lib\site-packages\numpy\core\umath.pyd"
202 - reason for this is not understood at present. (Umath is apparently included in the built package).
206 Step 8 Drag out the completed bundle
207 ------------------------------------
209 py2exe creates a new folder for the created software bundle, drag this out to the desktop for ease of working.
211 8.1/ Drag Desktop\fpdb\packaging\windows\fpdb-n.nn.nnn to Desktop\
217 9.1/ Open the Desktop\fpdb-n.nn.nnn folder
218 9.2/ In explorer...tools...folder options...View uncheck "Hide extensions for known file types"
219 9.3/ Double click run_fpdb.bat
220 9.4/ check the contents of pyfpdb\fpdb.exe.log, deal with any errors thrown
222 9.5/ hopefully, fpdb will run
223 9.6/ Try out a few options, deal with any errors reported
225 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.
234 Step 12 rename folder
235 ---------------------
237 If needed, rename the folder to something meaningful to the community.
239 Step 13 Compress to executable archive
240 --------------------------------------
242 13.1/ Download and install 7zip 914 ... http://sourceforge.net/projects/sevenzip/files/7-Zip/9.14/7z914.exe/download
243 13.2/ Rightclick on fpdb executable folder, select 7zip Add to archive... select SFX archive option switch
244 13.3/ Test the created exe file