waterye

py2exe

py2exe is a Python distutils extension which converts python scripts into executable windows programs, able to run without requiring a python installation.

install py2exe:  py2exe-0.6.3.win32-py2.4.exe

hello.py
1def sayHello( name ):
2    print "hello, ".upper() + name + "!"
3
4if __name__ == '__main__':
5    sayHello( "Water Ye" )

hello_setup.py
 1from distutils.core import setup
 2import py2exe
 3
 4setup(    
 5    version = "0.0.6",
 6    description = "py2exe sample script",
 7    name = "say hello",
 8
 9    # targets to build
10    # windows = ["test_wx.py"],
11    console = ["hello.py"],
12    )

running
G:\python_src> python hello_setup.py py2exe
note: -b
python hello_setup.py py2exe -b 2: Specifying a level of 2 includes the .pyd and .dll files into the zip-archive or the executable.
python hello_setup.py py2exe -b 1: Using a level of 1 includes the .pyd and .dll files into the zip-archive or the executable itself, and does the same for pythonXY.dll.
 
deploy
复制dist下的所有文件到没有python环境的机器即可运行

posted on 2005-11-18 00:55 waterye 阅读(564) 评论(0)  编辑  收藏 所属分类: python


只有注册用户登录后才能发表评论。


网站导航: