2025
Comment: Updated links to 0.5.0 final
|
8968
|
Deletions are marked like this. | Additions are marked like this. |
Line 4: | Line 4: |
Its home is here [http://starship.python.net/crew/theller/py2exe/] and on Sourceforge [http://sourceforge.net/projects/py2exe/] | Its home is here [http://www.py2exe.org/] and on Sourceforge [http://sourceforge.net/projects/py2exe/] == How does py2exe work and what are all those files? == Let's start from the needed results going back to how py2exe does its job. Python is an interpreted language and as long as Microsoft will not ship a Python interpreter (and its accompanying class library) with every copy of its flagship operating systems products, there is no direct way to execute a Python script on a vanilla Microsoft OS machine. For most casual user of py2exe, that means that you must create an executable (.exe) file that when clicked on will just run the script. This is what py2exe does for you. After py2exe has done its magic, you should have a "dist" directory with all the files necessary to run your python script. No install necessary. Click and run. No DLL hell, nothing else to download. '''But what are all those files?''' || myprog.exe || The actual executable. You can select a custom icon by using some specific target options (see CustomIcons) || || python??.dll || the python interpreter library. This is the brain of your executable || || library.zip || This is a standard zip file where all the pure source modules will be inserted (using the "zipfile" option, you can also select to put that file in a sub-directory and with a different name) || || *.pyd || The pyd files are actually standard Windows DLL (I used the useful depends.exe to check things around). They are also standard modules for Python. A Python program can import those pyd. Some applications build pyd to provide accelerated features. Also they are necessary to provide support to native functions of the operating system (see also CTypes to never have to use SWIG again!). Those files also follow into the subdirectory where library.zip will be installed|| || *.dll || some pyd probably has some DLL has dependencies, and here they come || || w9xpopen.exe || This is needed on Win9x platform. || To run your program needs all those files as a necessary condition. But it might happen that this is not a sufficient condition. For examples, as encodings are imported "by name". If you use a feature that requires encodings, you will need to put an option to include encodings unconditionally or to import it explicitely from one of your script. (see EncodingsAgain and EvenMoreEncodings). Some other modules (eg [http://pyserial.sourceforge.net/ pyserial-pyparallel]) also conditionally import modules for each platform. You can avoid the warning by putting the correct "ignores" options in py2exe. Last but not least, modules like [http://www.pygtk.org/ pygtk] seem to create a module reference on-the-fly and therefore the corresponding warnings also are harmless (see ExcludingDlls to learn how to correct that). An important point to note: the main script (the one passed as an option to "windows" or "console" in your setup file) is not put with all the other files in the library.zip. Instead it is byte-compiled (see OptimizedBytecode for some details on optimization) and inserted into a named resource in the executable shell. This technique also allows you to insert binary string in the final executable (very nice if you want to add a custom version tag) through the usage of the "other_resources" options for the target (see CustomDataInExe). |
Line 9: | Line 32: |
[http://groups.google.de/groups?dq=&hl=de&lr=&ie=UTF-8&oe=UTF-8&threadm=1ebr001fkuq85al2i8c26ejceu8qvedmdb%404ax.com&prev=/groups%3Fhl%3Dde%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26group%3Dcomp.lang.python announced] by Thomas Heller in November 2003. | [http://groups.google.de/groups?dq=&hl=de&lr=&ie=UTF-8&oe=UTF-8&threadm=1ebr001fkuq85al2i8c26ejceu8qvedmdb%404ax.com&prev=/groups%3Fhl%3Dde%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26group%3Dcomp.lang.python announced] by Thomas Heller in January 2004 |
Line 11: | Line 34: |
As nearly usual in Open Source space, prerelases and beta are of the same quality as .02 releases from some commercial software develeoping companies - rather full functional, with small obstacles. | As nearly usual in Open Source space, prerelases and beta are of the same quality as .02 releases from some commercial software developing companies - rather full functional, with small obstacles. |
Line 15: | Line 38: |
["py2exe and windows services"] - some gained knowledge |
|
Line 17: | Line 43: |
* ListOfOptions How to see the list of available options for your setup.py script * RunningSetup How to run the setup script once you've written it |
|
Line 18: | Line 46: |
* EvenMoreEncodings They really keep bugging. Solution to problem with different site.py | |
Line 19: | Line 48: |
* PathModul Using Jason Jorendorffs python PathModul together with Py2Exe 0.5 | * PathModul Using Jason Orendorffs python PathModul together with Py2Exe 0.5 |
Line 23: | Line 52: |
* TkInter I do not need any tkinter / tcl-Libs in my Setup * FilenameCaseMatters Some windows filing systems mangle case, break py2exe programs * WinBatch A short Windows Batch File to fast provide the EXE File * ExcludingDlls Stopping py2exe from picking up unwanted DLLs * ShippingEmbedded How to use py2exe to ship embedded Python modules * SingleFileExecutable with NSIS * OptimizedBytecode How to get optimized bytecode for all modules * CustomDataInExe Add custom data in the executable? * HowToDetermineIfRunningFromExe - Simple functions to determine if you're in an .exe or .py === py2exe and PyQt === * Py2exeAndPyQt If you're getting `File "qt.pyc", line 7, in __load Import Error: No module named sip`, read this === py2exe and wxPython === * Py2exeAndwxPython If you're getting ''wxObjectPtr not found'', read this === py2exe and PyGTK === * ["Py2exeAndPyGTK"] A recipe for py2exe and PyGTK === py2exe and PIL === * ["PIL and py2exe"] If you're getting ''cannot identify image file'', read this === py2exe and reportlab === * ["PIL and reportlab"] If you've read ["PIL and py2exe"] and still get ''cannot identify image file'', read this === py2exe and Python ADODB modules === * ADODB package Modules named adodb_xxx (like adodb_mysql) are not added automatically, must be added explicitly === py2exe and PyXML === * ["Py2exeAndPyXML"] If you're getting ''File "xml\sax\saxexts.pyc", line 77, in make_parser; xml.sax._exceptions.SAX''''''Reader''''''Not''''''Available: No parsers found'', read this. |
|
Line 25: | Line 77: |
* IncludingTypelibs allowing use of makepy generated typelibs | |
Line 29: | Line 82: |
=== py2exe and Biopython === * ConfigImportProblems Fixing problems with importing Bio.Config files from library.zip === py2exe and SciPy === * ScipyImportProblems Using py2exe with scipy ends up with missing {{{cephes}}} and {{{__cvs_version__}}} messages. Here is a fix. === py2exe and PythonCard === * PythonCardSetup Getting pythoncard to work by editing setup.py === py2exe and Quixote === Quixote is a pythonivc toolkit for webpages which allows one to execute ptl files using ihooks. You can distribute your web application with medusa or twisted and hence you can create a web application without IIS or Apache. I like to distribute my application with py2exe but I can not make py2exe setup script to recognize that x.ptl is a valid python files. Any idea how to do this? - impossible: ["Quixote & py2exe"] HAM20040602 === py2exe and MatPlotLib === * MatPlotLib - Fixing and including configuration information for this plotting package. === py2exe and Tix === * TixSetup - Including the Tix DLL and Tcl files to make Tix apps work. === the runtime enviroment === * Py2exeEnvironment - information about the environment for the executable === py2exe and subprocess === * Py2ExeSubprocessInteractions - getting subprocess module to work with py2exe. === py2exe and logging module === * LoggingModule - Getting the %(filename)s format string working in the python logging module. === py2exe and win32pipe === * IssuesWithWin32pipe (from pywin32) in a bundle. === p2exe and Python Eggs === * ExeWithEggs - A recipe for creating an .exe out of eggs |
|
Line 32: | Line 110: |
* GuiApps with options 'windows' still open a console window for errors | |
Line 35: | Line 113: |
* SpeedUp using psyco to speed up code compilation | |
Line 36: | Line 115: |
* Generation of .com and .exe files in one run ---- CategoryHomepage |
py2exe
Py2Exe is an additional command to DistUtils, that creates standalone distributions for Win32.
Its home is here [http://www.py2exe.org/] and on Sourceforge [http://sourceforge.net/projects/py2exe/]
How does py2exe work and what are all those files?
Let's start from the needed results going back to how py2exe does its job.
Python is an interpreted language and as long as Microsoft will not ship a Python interpreter (and its accompanying class library) with every copy of its flagship operating systems products, there is no direct way to execute a Python script on a vanilla Microsoft OS machine. For most casual user of py2exe, that means that you must create an executable (.exe) file that when clicked on will just run the script. This is what py2exe does for you. After py2exe has done its magic, you should have a "dist" directory with all the files necessary to run your python script. No install necessary. Click and run. No DLL hell, nothing else to download.
But what are all those files?
myprog.exe |
The actual executable. You can select a custom icon by using some specific target options (see CustomIcons) |
python??.dll |
the python interpreter library. This is the brain of your executable |
library.zip |
This is a standard zip file where all the pure source modules will be inserted (using the "zipfile" option, you can also select to put that file in a sub-directory and with a different name) |
*.pyd |
The pyd files are actually standard Windows DLL (I used the useful depends.exe to check things around). They are also standard modules for Python. A Python program can import those pyd. Some applications build pyd to provide accelerated features. Also they are necessary to provide support to native functions of the operating system (see also CTypes to never have to use SWIG again!). Those files also follow into the subdirectory where library.zip will be installed |
*.dll |
some pyd probably has some DLL has dependencies, and here they come |
w9xpopen.exe |
This is needed on Win9x platform. |
To run your program needs all those files as a necessary condition. But it might happen that this is not a sufficient condition. For examples, as encodings are imported "by name". If you use a feature that requires encodings, you will need to put an option to include encodings unconditionally or to import it explicitely from one of your script. (see EncodingsAgain and EvenMoreEncodings). Some other modules (eg [http://pyserial.sourceforge.net/ pyserial-pyparallel]) also conditionally import modules for each platform. You can avoid the warning by putting the correct "ignores" options in py2exe. Last but not least, modules like [http://www.pygtk.org/ pygtk] seem to create a module reference on-the-fly and therefore the corresponding warnings also are harmless (see ExcludingDlls to learn how to correct that).
An important point to note: the main script (the one passed as an option to "windows" or "console" in your setup file) is not put with all the other files in the library.zip. Instead it is byte-compiled (see OptimizedBytecode for some details on optimization) and inserted into a named resource in the executable shell. This technique also allows you to insert binary string in the final executable (very nice if you want to add a custom version tag) through the usage of the "other_resources" options for the target (see CustomDataInExe).
Learned things with py2exe 0.5
[http://prdownloads.sourceforge.net/py2exe/py2exe-0.5.0.win32-py2.3.exe py2exe0.5.0] is the release of py2exe 0.5 [http://groups.google.de/groups?dq=&hl=de&lr=&ie=UTF-8&oe=UTF-8&threadm=1ebr001fkuq85al2i8c26ejceu8qvedmdb%404ax.com&prev=/groups%3Fhl%3Dde%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26group%3Dcomp.lang.python announced] by Thomas Heller in January 2004
As nearly usual in Open Source space, prerelases and beta are of the same quality as .02 releases from some commercial software developing companies - rather full functional, with small obstacles.
I had to "upgrade" also my knowledge about workarounds from py2exe 0.4
["py2exe and windows services"] - some gained knowledge
Tips and Tricks
General
ListOfOptions How to see the list of available options for your setup.py script
RunningSetup How to run the setup script once you've written it
EncodingsAgain Problem with encodings and when they are not found in a standalone executable
EvenMoreEncodings They really keep bugging. Solution to problem with different site.py
AddingConfigFiles How can you add arbitrary files to your Py2Exe-Setup?
PathModul Using Jason Orendorffs python PathModul together with Py2Exe 0.5
PassingOptionsToPy2Exe Avoid using sys.argv to pass options
SubclassingPy2Exe Customizing the build process
CustomIcons How to get your own icons with Py2Exe 0.5
TkInter I do not need any tkinter / tcl-Libs in my Setup
FilenameCaseMatters Some windows filing systems mangle case, break py2exe programs
WinBatch A short Windows Batch File to fast provide the EXE File
ExcludingDlls Stopping py2exe from picking up unwanted DLLs
ShippingEmbedded How to use py2exe to ship embedded Python modules
SingleFileExecutable with NSIS
OptimizedBytecode How to get optimized bytecode for all modules
CustomDataInExe Add custom data in the executable?
HowToDetermineIfRunningFromExe - Simple functions to determine if you're in an .exe or .py
py2exe and PyQt
Py2exeAndPyQt If you're getting File "qt.pyc", line 7, in __load Import Error: No module named sip, read this
py2exe and wxPython
Py2exeAndwxPython If you're getting wxObjectPtr not found, read this
py2exe and PyGTK
- ["Py2exeAndPyGTK"] A recipe for py2exe and PyGTK
py2exe and PIL
["PIL and py2exe"] If you're getting cannot identify image file, read this
py2exe and reportlab
["PIL and reportlab"] If you've read ["PIL and py2exe"] and still get cannot identify image file, read this
py2exe and Python ADODB modules
- ADODB package Modules named adodb_xxx (like adodb_mysql) are not added automatically, must be added explicitly
py2exe and PyXML
["Py2exeAndPyXML"] If you're getting File "xml\sax\saxexts.pyc", line 77, in make_parser; xml.sax._exceptions.SAXReaderNotAvailable: No parsers found, read this.
py2exe and win32com
WinShell using win32com.shell with py2exe 0.5
IncludingTypelibs allowing use of makepy generated typelibs
py2exe and Innosetup
BetterCompression Getting complete wxPython Programms down to around 4 Megabytes
SetupLanguage How to localize the language with [http://starship.python.net/crew/theller/py2exe/ py2exe] and [http://www.jrsoftware.org/isinfo.php InnoSetup]
QuickStartIcons How to add Startup-Links to the Quickstart-Bar & the Desktop using [http://www.jrsoftware.org/isinfo.php InnoSetup] together with Py2Exe
py2exe and Biopython
ConfigImportProblems Fixing problems with importing Bio.Config files from library.zip
py2exe and SciPy
ScipyImportProblems Using py2exe with scipy ends up with missing cephes and __cvs_version__ messages. Here is a fix.
py2exe and PythonCard
PythonCardSetup Getting pythoncard to work by editing setup.py
py2exe and Quixote
Quixote is a pythonivc toolkit for webpages which allows one to execute ptl files using ihooks. You can distribute your web application with medusa or twisted and hence you can create a web application without IIS or Apache.
I like to distribute my application with py2exe but I can not make py2exe setup script to recognize that x.ptl is a valid python files. Any idea how to do this? - impossible: ["Quixote & py2exe"] HAM20040602
py2exe and MatPlotLib
MatPlotLib - Fixing and including configuration information for this plotting package.
py2exe and Tix
TixSetup - Including the Tix DLL and Tcl files to make Tix apps work.
the runtime enviroment
Py2exeEnvironment - information about the environment for the executable
py2exe and subprocess
Py2ExeSubprocessInteractions - getting subprocess module to work with py2exe.
py2exe and logging module
LoggingModule - Getting the %(filename)s format string working in the python logging module.
py2exe and win32pipe
IssuesWithWin32pipe (from pywin32) in a bundle.
p2exe and Python Eggs
ExeWithEggs - A recipe for creating an .exe out of eggs
Fixes
ExtendingExample a "-.zip" is missing
GuiApps with options 'windows' still open a console window for errors
Thoughts
SpeedUp using psyco to speed up code compilation
- Generation of .com and .exe files in one run