13215
Comment:
|
8559
|
Deletions are marked like this. | Additions are marked like this. |
Line 5: | Line 5: |
== 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 14: | Line 37: |
["py2exe and windows services"] - some gained knowledge |
|
Line 31: | Line 57: |
* 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 |
|
Line 39: | Line 70: |
=== 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 48: | Line 81: |
=== 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 |
|
Line 58: | Line 94: |
=== 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. |
|
Line 69: | Line 109: |
[http://www.zhaoguan.com 二氧化氯] [http://www.108888.com 温湿度] [http://www.208888.com 管道] [http://www.308888.com 催化剂] [http://www.408888.com 电子秤] [http://www.508888.com 电加热器] [http://www.708888.com 开关柜] [http://www.300888.com 建材机械] [http://www.500888.com 保险柜] [http://www.700888.com 电路板] [http://www.900888.com 乳胶漆] [http://www.106666.com 工程塑料] [http://www.206666.com 特许经营] [http://www.1006666.com 楼宇自控] [http://www.2006666.com 喷码机] [http://www.306666.com 液位计] [http://www.3006666.com 聚丙烯酰胺] [http://www.506666.com 电磁铁] [http://www.606666.com 超市设备] [http://www.5006666.com 薄膜开关] [http://www.6006666.com 指纹考勤] [http://www.706666.com 渔具] [http://www.7006666.com 跑步机] [http://www.806666.com 防腐设备] [http://www.8006666.com 锁具] [http://www.906666.com 弹簧] [http://www.9006666.com 纸箱] [http://www.0001111.com 煤炭] [http://www.00001111.com 保龄球] [http://www.0003333.com 木地板] [http://www.00005555.com 家用电器] [http://www.0005555.com 植绒] [http://www.0006666.com 钻头] [http://www.00007777.com 冲压件] [http://www.0008888.com 建筑机械] [http://www.1236666.com 实木地板] [http://www.3456666.com 捏合机] [http://www.13088888888.com 整流器] [http://www.13288888888.com 酒店用品] [http://www.13588888888.com 升降台] [http://www.13688888888.com 转换器] [http://www.13788888888.com 软件下载] [http://www.13888888888.com 喷砂机] [http://www.02088888888.com 制罐] [http://www.02288888888.com 工业炉] [http://www.02188888888.com 生产线] [http://www.02388888888.com 瓷器] [http://www.02588888888.com 搅拌机] [http://www.02788888888.com 印刷机械] [http://www.3698888.com 综合布线] [http://www.1478888.com 避雷器] [http://www.888777888.com 减震器] [http://www.8899888888.com 色织] [http://www.8877888888.com 燃烧器] [http://www.8866888888.com 机电设备] [http://www.8855888888.com 防雷器] [http://www.8833888888.com 地坪] [http://www.8822888888.com 纸品] [http://www.8811888888.com 冷弯型钢] [http://www.7799888888.com 木工机械] [http://www.7788888888.com 物流设备] [http://www.7766888888.com 铁塔] [http://www.7755888888.com 非开挖] [http://www.7733888888.com 热电偶] [http://www.7722888888.com 保险箱] [http://www.6666888888.com 吸塑机] [http://www.6655888888.com 喷漆] [http://www.6633888888.com 过滤材料] [http://www.6622888888.com 电刷] [http://www.6611888888.com冷水机] [http://www.5599888888.com 采暖] [http://www.5588888888.com 机械加工] [http://www.5577888888.com 照相器材] [http://www.5566888888.com 电镀原料] [http://www.5555888888.com 毛毡] [http://www.5533888888.com 交通设施] [http://www.5522888888.com 消毒机] [http://www.5511888888.com 压滤机] [http://www.3399888888.com 刻字机] [http://www.3377888888.com 接口转换器] [http://www.3366888888.com 电视电话会议] [http://www.3311888888.com 贴纸相机] [http://www.2299888888.com 橡胶机械] [http://www.2277888888.com 喷泉设备] [http://www.2266888888.com 丝印] [http://www.2255888888.com 精细化工] [http://www.2233888888.com 塑胶玩具] [http://www.3355888888.com 五金模具] [http://www.3333888888.com 电子设备] [http://www.3322888888.com 企业形象设计] [http://www.2211888888.com 指纹识别] [http://www.1199888888.com 搬运车] [http://www.1188888888.com 牛仔布] [http://www.1177888888.com 电动车配件] [http://www.1166888888.com 会议系统] [http://www.1155888888.com 终端服务器] [http://www.1133888888.com 录音笔] [http://www.1122888888.com 球磨机] [http://www.999999888.com 园林设计] [http://www.999777888.com 路由器] [http://www.999666999.com 手套箱] [http://www.999555888.com 实验室设备] [http://www.999333888.com 童装] [http://www.999222888.com 手机美容] [http://www.999111888.com 户外用品] [http://www.888888999.com 证卡] [http://www.888999888.com 机床附件] [http://www.888555888.com 彩电] [http://www.888333888.com 酒店管理] [http://www.888222888.com 电话录音] [http://www.888111888.com 油墨] [http://www.777777888.com 布线] [http://www.777999888.com 蜡烛] [http://www.777666888.com 印刷包装] [http://www.777555888.com 表面活性剂] [http://www.777333888.com 节能灯] [http://www.777222888.com 调味品] [http://www.777111888.com 齿轮] [http://www.666999888.com 高压泵] [http://www.666666888.com 红外热像仪] [http://www.666333888.com 塑料托盘] [http://www.666222888.com 吊带] [http://www.666111888.com 工业锅炉] [http://www.555999888.com 休闲服] [http://www.555777888.com 反光材料] [http://www.555555888.com 印刷设备] [http://www.555333888.com 足球推介] [http://www.555222888.com 热处理] [http://www.555111888.com 压铸] [http://www.1111166666.com 商标注册] [http://www.1111199999.com 喷灌] [http://www.1111188888.com 逆变器] [http://www.2222228888.com 输送带] [http://www.2221118888.com 锻造] [http://www.1119998888.com 车库门] [http://www.1118888888.com 体育器材] [http://www.1117778888.com 太阳能热水器] [http://www.1116668888.com 绝缘材料] [http://www.1115558888.com 焊管] [http://www.1113338888.com 鼓风机] [http://www.1112228888.com 试验] [http://www.111166666.com 插座] [http://www.111155555.com 艺术品] [http://www.111133333.com 矿山机械] [http://www.111122222.com 图像监控] [http://www.333888888.com 无缝钢管] [http://www.333777888.com 激光切割] [http://www.333555888.com 标签打印机] [http://www.333333888.com 燃气表] [http://www.333111888.com 手机配件] [http://www.3331118888.com 卫星定位] [http://www.2229998888.com 印染] [http://www.2228888888.com 玻璃机械] [http://www.2226668888.com 铝型材] [http://www.2225558888.com 注塑] [http://www.1111133333.com 液压升降机] [http://www.999998888.com 打标机] [http://www.777778888.com 工具柜] [http://www.666668888.com 焚烧炉] [http://www.555558888.com 电力设备] [http://www.333338888.com 干燥剂] [http://www.222228888.com 计量泵] [http://www.111118888.com 程控交换机] |
py2exe
Py2Exe is an additional command to DistUtils, that creates standalone distributions for Win32.
Its home is here [http://starship.python.net/crew/theller/py2exe/] 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
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 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.
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.
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