因为要在桃园学校的电脑上安装rur-ple,Pockey和Fred翻译了主程序和前三节课程,rur-ple网站的win32安装包没法merge到一起。所以我重新打一个临时的包。
在编译和打包之前需要安装下面的包:
Python2.5
http://www.python.org/download/releases/wxPython 2.6
http://www.wxpython.org/download.php#binaries
http://sourceforge.net/projects/wxpython/files/wxPython/2.6.4.0/wxPython2.6-win32-unicode-2.6.4.0-py25.exe/downloadpy2exe 0.6.5 – 第一个支持Python2.5的版本
http://www.py2exe.org/
编译程序
参照:http://effbot.org/zone/python-compile.htm
进入要编译的python文件所在目录如下。
D:\sunlw\projects\ygclub\teaching\rurple1.0rc3>python
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on
win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import compileall
>>> compileall.compile_dir(“./”, force=1)
编译完成后运行一下,确认正常。
D:\sunlw\projects\ygclub\teaching\rurple1.0rc3>rur_start.py
貌似运行起来快了一点。
将程序打包成exe
参照:http://www.py2exe.org/index.cgi/Tutorial
添加setup.py文件如下 (http://www.py2exe.org/index.cgi/Tutorial?action=AttachFile&do=view&target=setup.py)
from distutils.core import setup
import py2exe
setup(console=['rur_start.py'])
然后执行
D:\sunlw\projects\ygclub\teaching\rurple1.0rc3>python setup.py py2exe
运行exe程序试试
D:\sunlw\projects\ygclub\teaching\rurple1.0rc3>.\dist\rur_start.exe
成功。
安装包
另外我简单的将编译好的文件用7zip打成自解压程序。
注:
尽量保证依赖的库版本低一些,方便一些安装Windows 2000的电脑使用。