py2exe: add more build automation, activate MS-Windows GTK theme
This commit is contained in:
parent
8792b427de
commit
0dfe6b3d78
|
@ -1,241 +1,231 @@
|
||||||
PY2EXE walkthrough for Python 2.7 & FPDB 0.2x
|
PY2EXE walkthrough for Python 2.7 & FPDB 0.2x
|
||||||
created on 27th Feb 2011 by Gimick
|
created on 27th Feb 2011 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 Python 2.7 and sequencing added by Gimick
|
Additional information, formatting, updating to Python 2.6 and Python 2.7 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.7 ... http://python.org/ftp/python/2.7/python-2.7.msi
|
Python 2.7 ... http://python.org/ftp/python/2.7/python-2.7.msi
|
||||||
matplotlib 1.0.1 ... http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0.1/matplotlib-1.0.1.win32-py2.7.exe/download
|
matplotlib 1.0.1 ... http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0.1/matplotlib-1.0.1.win32-py2.7.exe/download
|
||||||
pygtk 2.22 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/pygtk-2.22.0-1.win32-py2.7.exe
|
pygtk 2.22 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/pygtk-2.22.0-1.win32-py2.7.exe
|
||||||
pycairo 1.8.10 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.8/pycairo-1.8.10.win32-py2.7.exe
|
pycairo 1.8.10 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.8/pycairo-1.8.10.win32-py2.7.exe
|
||||||
pyGobject X 2.26 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.26/pygobject-2.26.0-1.win32-py2.7.exe
|
pyGobject X 2.26 ... http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.26/pygobject-2.26.0-1.win32-py2.7.exe
|
||||||
pywin 216 ... http://sourceforge.net/projects/pywin32/files/pywin32/Build216/pywin32-216.win32-py2.7.exe/download
|
pywin 216 ... http://sourceforge.net/projects/pywin32/files/pywin32/Build216/pywin32-216.win32-py2.7.exe/download
|
||||||
|
|
||||||
pypokereval 138 ... http://sourceforge.net/projects/fpdb/files/fpdb/pokereval-138.win32-py2.7.exe/download
|
pypokereval 138 ... http://sourceforge.net/projects/fpdb/files/fpdb/pokereval-138.win32-py2.7.exe/download
|
||||||
cdecimal 2.2 ... http://www.bytereef.org/software/mpdecimal/releases/cdecimal-2.2.win32-py2.7.msi
|
cdecimal 2.2 ... http://www.bytereef.org/software/mpdecimal/releases/cdecimal-2.2.win32-py2.7.msi
|
||||||
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)
|
||||||
|
|
||||||
py2exe 0.6.9 ... http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.7.exe/download
|
py2exe 0.6.9 ... http://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/py2exe-0.6.9.win32-py2.7.exe/download
|
||||||
|
|
||||||
1.2/ MySQL
|
1.2/ MySQL
|
||||||
|
|
||||||
Install the following file:
|
Install the following file:
|
||||||
mysql-python 1.2.3 ... http://sourceforge.net/projects/fpdb/files/fpdb/MySQL-python-1.2.3.win32-py2.7.exe/download
|
mysql-python 1.2.3 ... http://sourceforge.net/projects/fpdb/files/fpdb/MySQL-python-1.2.3.win32-py2.7.exe/download
|
||||||
|
|
||||||
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:\Python27\Lib\site-packages\pytz
|
1.3.1/ Navigate to C:\Python27\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
|
||||||
|
|
||||||
|
|
||||||
1.4/ Patch py2exe to stop popup runtime error message
|
1.4/ Patch py2exe to stop popup runtime error message
|
||||||
|
|
||||||
see http://www.py2exe.org/index.cgi/StderrLog for technical info.
|
see http://www.py2exe.org/index.cgi/StderrLog for technical info.
|
||||||
|
|
||||||
1.4.1/
|
1.4.1/
|
||||||
|
|
||||||
dos> write C:\Python27\Lib\site-packages\py2exe\boot_common.py
|
dos> write C:\Python27\Lib\site-packages\py2exe\boot_common.py
|
||||||
|
|
||||||
replace:
|
replace:
|
||||||
atexit.register(alert, 0,
|
atexit.register(alert, 0,
|
||||||
"See the logfile '%s' for details" % fname,
|
"See the logfile '%s' for details" % fname,
|
||||||
"Errors occurred")
|
"Errors occurred")
|
||||||
with:
|
with:
|
||||||
#atexit.register(alert, 0,
|
#atexit.register(alert, 0,
|
||||||
# "See the logfile '%s' for details" % fname,
|
# "See the logfile '%s' for details" % fname,
|
||||||
# "Errors occurred")
|
# "Errors occurred")
|
||||||
|
|
||||||
1.4.2/ save and exit
|
1.4.2/ 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+ allinone 2.22.1 ... http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.1-20101227_win32.zip
|
gtk+ allinone 2.22.1 ... http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.1-20101227_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.
|
||||||
|
|
||||||
2.4/ The /share/doc and /share/gtk-doc folders are huge, so can be emptied now (leave the /doc and /gtk-doc folders
|
2.4/ The /share/doc and /share/gtk-doc folders are huge, so can be emptied now (leave the /doc and /gtk-doc folders
|
||||||
in place, but delete the content)
|
in place, but delete the content)
|
||||||
|
|
||||||
|
|
||||||
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
|
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. 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
|
older client PC's
|
||||||
|
|
||||||
5.3.1/ download the package to the Desktop
|
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
|
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> cd Desktop
|
||||||
dos> numpy-1.5.1-win32-superpack-python2.7.exe /arch nosse
|
dos> numpy-1.5.1-win32-superpack-python2.7.exe /arch nosse
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
"Target CPU handles SSE2"
|
"Target CPU handles SSE2"
|
||||||
"Target CPU handles SSE3"
|
"Target CPU handles SSE3"
|
||||||
"nosse install (arch value: nosse)"
|
"nosse install (arch value: nosse)"
|
||||||
"Install NO SSE"
|
"Install NO SSE"
|
||||||
Extract: numpy-1.5.1-nosse.exe... 100%
|
Extract: numpy-1.5.1-nosse.exe... 100%
|
||||||
Execute: "C:\DOCUME~1\user\LOCALS~1\Temp\numpy-1.5.1-nosse.exe"
|
Execute: "C:\DOCUME~1\user\LOCALS~1\Temp\numpy-1.5.1-nosse.exe"
|
||||||
Completed
|
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.0/ Set version number of build folder
|
||||||
|
dos> cd Desktop\fpdb\packaging\windows
|
||||||
dos> cd Desktop\fpdb\packaging\windows
|
dos> write py2exe_setup.py
|
||||||
dos> c:\python27\python.exe py2exe_setup.py py2exe
|
change the value of fpdbver and save file
|
||||||
|
|
||||||
wait a while, watch lots of copying and whatever.
|
6.1/ Run the script to create the fpdb.exe bundle
|
||||||
|
|
||||||
6.2/ You should next get prompted for the GTK folder.
|
dos> cd Desktop\fpdb\packaging\windows
|
||||||
c:\GTK
|
dos> c:\python27\python.exe py2exe_setup.py py2exe
|
||||||
|
|
||||||
6.3/ If there are no errors reported, it has probably worked, we will test soon.
|
wait a while, watch lots of copying and whatever.
|
||||||
|
|
||||||
Build notes:
|
6.2/ You should next get prompted for the GTK folder.
|
||||||
|
Enter c:\GTK
|
||||||
There is a warning about dll's not included "umath.pyd - c:\Python27\lib\site-packages\numpy\core\umath.pyd"
|
|
||||||
- reason for this is not understood at present. (Umath is apparently included in the built package).
|
6.3/ If there are no errors reported, it has probably worked, we will test soon.
|
||||||
|
|
||||||
|
Build notes:
|
||||||
Step 7 not currently used
|
|
||||||
-------------------------
|
There is a warning about dll's not included "umath.pyd - c:\Python27\lib\site-packages\numpy\core\umath.pyd"
|
||||||
|
- reason for this is not understood at present. (Umath is apparently included in the built package).
|
||||||
Has been deleted
|
|
||||||
|
|
||||||
|
Step 7 not currently used
|
||||||
Step 8 Drag out the completed bundle
|
-------------------------
|
||||||
------------------------------------
|
|
||||||
|
Has been deleted
|
||||||
py2exe creates a new folder for the created software bundle, drag this out to the desktop for ease of working.
|
|
||||||
|
|
||||||
8.1/ Drag Desktop\fpdb\packaging\windows\fpdb-n.nn.nnn to Desktop\
|
Step 8 Drag out the completed bundle
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
Step 9 Initial run
|
py2exe creates a new folder for the created software bundle, drag this out to the desktop for ease of working.
|
||||||
------------------
|
|
||||||
|
8.1/ Drag Desktop\fpdb\packaging\windows\fpdb-n.nn.nnn to Desktop\
|
||||||
9.1/ Open the Desktop\fpdb-n.nn.nnn folder
|
|
||||||
9.2/ In explorer...tools...folder options...View uncheck "Hide extensions for known file types"
|
|
||||||
9.3/ Double click run_fpdb.bat
|
Step 9 Initial run
|
||||||
9.4/ check the contents of pyfpdb\fpdb.exe.log, deal with any errors thrown
|
------------------
|
||||||
|
|
||||||
9.5/ hopefully, fpdb will run
|
9.1/ Open the Desktop\fpdb-n.nn.nnn folder
|
||||||
9.6/ Try out a few options, deal with any errors reported
|
9.2/ In explorer...tools...folder options...View uncheck "Hide extensions for known file types"
|
||||||
|
9.3/ Double click run_fpdb.bat
|
||||||
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.
|
9.4/ check the contents of pyfpdb\fpdb.exe.log, deal with any errors thrown
|
||||||
|
|
||||||
|
9.5/ hopefully, fpdb will run
|
||||||
Step 11 pruning
|
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.
|
||||||
11.1/ The generated folder is 100+MB and can be pruned by removing the following directories:
|
|
||||||
|
|
||||||
pyfpdb/lib/glib-2.0
|
Step 11 deleted
|
||||||
pyfpdb/lib/pkgconfig
|
---------------
|
||||||
pyfpdb/share/aclocal
|
|
||||||
pyfpdb/share/doc
|
Has been deleted
|
||||||
pyfpdb/share/glib-2.0
|
|
||||||
pyfpdb/share/gtk-2.0
|
|
||||||
pyfpdb/share/gtk-doc
|
Step 12 rename folder
|
||||||
pyfpdb/share/locale
|
---------------------
|
||||||
pyfpdb/share/man
|
|
||||||
|
If needed, rename the folder to something meaningful to the community.
|
||||||
|
|
||||||
Step 12 rename folder
|
Step 13 Compress to executable archive
|
||||||
---------------------
|
--------------------------------------
|
||||||
|
|
||||||
If needed, rename the folder to something meaningful to the community. If you have built for NoSSE, append anyCPU to the directory name.
|
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 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.
|
|
||||||
|
|
||||||
|
|
|
@ -24,32 +24,25 @@ Py2exe script for fpdb.
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
#TODO:
|
#TODO:
|
||||||
# get rid of all the uneeded libraries (e.g., pyQT)
|
|
||||||
# think about an installer
|
# 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:
|
#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
|
#- cd to the folder where this script is stored, usually ...packaging/windows
|
||||||
#- Run the script with python "py2exe_setup.py py2exe"
|
#- Run the script with python "py2exe_setup.py py2exe"
|
||||||
#- You will frequently get messages about missing .dll files.just assume other
|
#- You will frequently get messages about missing .dll files.just assume other
|
||||||
# person will have them? we have copyright issues including some dll's
|
# 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
|
# 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
|
# 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
|
# 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
|
# Gimick: restructure to allow script to run from packaging/windows directory, and not to write to source pyfpdb
|
||||||
|
|
||||||
|
fpdbver = '0.22'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -61,6 +54,10 @@ except:
|
||||||
print "A parameter is required, quitting now"
|
print "A parameter is required, quitting now"
|
||||||
quit()
|
quit()
|
||||||
|
|
||||||
|
if sys.argv[1] <> "py2exe":
|
||||||
|
print "Parameter 1 is not valid, quitting now"
|
||||||
|
quit()
|
||||||
|
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
import py2exe
|
import py2exe
|
||||||
import glob
|
import glob
|
||||||
|
@ -75,12 +72,15 @@ def isSystemDLL(pathname):
|
||||||
return origIsSystemDLL(pathname)
|
return origIsSystemDLL(pathname)
|
||||||
|
|
||||||
def test_and_remove(top):
|
def test_and_remove(top):
|
||||||
|
#print "Attempting to delete:", top
|
||||||
if os.path.exists(top):
|
if os.path.exists(top):
|
||||||
if os.path.isdir(top):
|
if os.path.isdir(top):
|
||||||
remove_tree(top)
|
remove_tree(top)
|
||||||
else:
|
else:
|
||||||
print "Unexpected file '"+top+"' found. Exiting."
|
print "Unexpected file '"+top+"' found. Exiting."
|
||||||
exit()
|
exit()
|
||||||
|
else:
|
||||||
|
"oops folder not found"
|
||||||
|
|
||||||
def remove_tree(top):
|
def remove_tree(top):
|
||||||
# Delete everything reachable from the directory named in 'top',
|
# Delete everything reachable from the directory named in 'top',
|
||||||
|
@ -89,8 +89,8 @@ def remove_tree(top):
|
||||||
# could delete all your disk files.
|
# could delete all your disk files.
|
||||||
# sc: Nicked this from somewhere, added the if statement to try
|
# sc: Nicked this from somewhere, added the if statement to try
|
||||||
# make it a bit safer
|
# make it a bit safer
|
||||||
if top in ('build','dist',distdir) and os.path.basename(os.getcwd()) == 'windows':
|
if (top in ('build','dist') or top.startswith(distdir)) and os.path.basename(os.getcwd()) == 'windows':
|
||||||
#print "removing directory '"+top+"' ..."
|
print "removing directory '"+top+"' ..."
|
||||||
for root, dirs, files in os.walk(top, topdown=False):
|
for root, dirs, files in os.walk(top, topdown=False):
|
||||||
for name in files:
|
for name in files:
|
||||||
os.remove(os.path.join(root, name))
|
os.remove(os.path.join(root, name))
|
||||||
|
@ -111,8 +111,6 @@ def copy_file(source,destination):
|
||||||
shutil.copy( source, destination )
|
shutil.copy( source, destination )
|
||||||
|
|
||||||
|
|
||||||
fpdbver = '0.21'
|
|
||||||
|
|
||||||
distdir = r'fpdb-' + fpdbver
|
distdir = r'fpdb-' + fpdbver
|
||||||
rootdir = r'../../' #cwd is normally /packaging/windows
|
rootdir = r'../../' #cwd is normally /packaging/windows
|
||||||
pydir = rootdir+'pyfpdb/'
|
pydir = rootdir+'pyfpdb/'
|
||||||
|
@ -172,9 +170,6 @@ setup(
|
||||||
] + matplotlib.get_py2exe_datafiles()
|
] + matplotlib.get_py2exe_datafiles()
|
||||||
)
|
)
|
||||||
|
|
||||||
# ,(distdir, [rootdir+'run_fpdb.bat'])
|
|
||||||
# ,(distdir+r'\gfx', glob.glob(gfxdir+'*.*'))
|
|
||||||
# ] +
|
|
||||||
print "*** py2exe build phase complete ***"
|
print "*** py2exe build phase complete ***"
|
||||||
|
|
||||||
# copy zone info and fpdb translation folders
|
# 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_tree (gfxdir, os.path.join(distdir, 'gfx'))
|
||||||
copy_file (rootdir+'run_fpdb.bat', distdir)
|
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')
|
dest = os.path.join(distdir, 'pyfpdb')
|
||||||
os.rename( 'dist', dest )
|
os.rename( 'dist', dest )
|
||||||
|
|
||||||
|
@ -196,30 +191,34 @@ while not os.path.exists(gtk_dir):
|
||||||
gtk_dir = sys.stdin.readline().rstrip()
|
gtk_dir = sys.stdin.readline().rstrip()
|
||||||
|
|
||||||
print "*** copying GTK runtime ***"
|
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', 'libgdk-win32-2.0-0.dll'), dest )
|
||||||
copy_file(os.path.join(gtk_dir, 'bin', 'libgobject-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, '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, 'lib'), os.path.join(dest, 'lib'))
|
||||||
copy_tree(os.path.join(gtk_dir, 'share'), os.path.join(dest, 'share'))
|
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')
|
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
|
print "*** deleting folders to shrink package size ***"
|
||||||
pyfpdb/lib/gtk-2.0/include
|
test_and_remove(os.path.join(distdir, 'pyfpdb', 'lib', 'glib-2.0'))
|
||||||
pyfpdb/lib/pkgconfig
|
test_and_remove(os.path.join(distdir, 'pyfpdb', 'lib', 'gtk-2.0','include'))
|
||||||
pyfpdb/share/aclocal
|
test_and_remove(os.path.join(distdir, 'pyfpdb', 'lib', 'pkgconfig'))
|
||||||
pyfpdb/share/doc
|
test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'aclocal'))
|
||||||
pyfpdb/share/glib-2.0
|
test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'doc'))
|
||||||
pyfpdb/share/gtk-2.0
|
test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'glib-2.0'))
|
||||||
pyfpdb/share/gtk-doc
|
test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'gtk-2.0'))
|
||||||
pyfpdb/share/locale
|
test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'gtk-doc'))
|
||||||
pyfpdb/share/man
|
test_and_remove(os.path.join(distdir, 'pyfpdb', 'share', 'locale'))
|
||||||
pyfpdb/share/themes/Default
|
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 "***++++++++++++++++++++++++++++++++++++++++++++++"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user