参考 wxpython 的说明文档
如下:主要看标红的文字, 在所述位置找到相应文件copy到发布的目录并修改相应 .manifest 文件,使版本号一致。
------------------------------------------------------------------------------------------------------------
Using cx_freeze to freeze your application
The following will explain how to freeze a Python/wxPython application using the cx_freeze tool.
What Objects are Involved
You will need a working development environment including
* Python
* wxPython
* cx_freeze
* Gui2Exe - by Andrea Gavana
Process Overview
A small sample wxPython "Hello world" application will be used to demonstrate the process. I created the tiny application using Boa Constructor but you could use any other IDE you use for your wxPython development. I did the initial creation of the setup.py file with Gui2Exe and then keep maintaining it and running it from the IDE (Boa in my case).
Special Concerns
Python 2.5x
- you will need the MS C run time dll 'msvcr71.dll', included with Python
- the dll 'gdiplus.dll' might also be needed depending on what wxPython widgets you use
- the appname.manifest file (needed to get the nice themed widgets on XP+) can be generated by checking the appropriate option in Gui2Exe
Python 2.6x
- you will need the MS C run time dll's (msvcr90.dll, msvcp90.dll, msvcm90.dll), included with Python (additional information provided below)
- you will need a copy of the Microsoft.VC90.CRT.manifest file, additional information provided below
- the dll 'gdiplus.dll' might also be needed depending on what wxPython widgets you use
- do not check the manifest option in Gui2Exe - to be verified
The setup.py
Save the following code in your working folder as a file called 'setup.py'.
I selected the "Compressed" option which created two .zip files to reduce the number of files to distribute, it also automagically copied the required dll's needed by Python and wxPython into the "dist" folder.
To deliver a single file to your end-users check out the InnoSetup page.
To "freeze" the application you run the following command from the command line in your working folder.
\python26\python setup.py build
The MS manifest
Following is the content of the Microsoft manifest file ("Microsoft.VC90.CRT.manifest"), note that the content of "version" and "publicKeyToken" are specific to the version of the dll files.
Installing Python 2.6 on Windows with the option "for this user only" this manifest file is created in the Python26 folder, note the Py26 installer does not offer the "for this user only" option on Vista.
If you install Python 2.6 for all users then these files are found in "C:\Windows\winsxs",
i.e. in "C:\Windows\winsxs\Manifests" you will find guess what the manifest and it would be called "x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest" and then in "C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91" you will find the dll's.
Note that the folder names contain the version number, so with Python 2.6.2 you should use version 9.0.21022.8 manifest and dll's.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- Copyright (c) Microsoft Corporation. All rights reserved. --> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <noInheritable/> <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" /> <file name="msvcr90.dll" /> <file name="msvcp90.dll" /> <file name="msvcm90.dll" /> </assembly>
Sample wxPython application
Save the following code in your working folder as a file called 'simplewx.py'.