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
1
def sayHello( name ):
2
print "hello, ".upper() + name + "!"
3
4
if __name__ == '__main__':
5
sayHello( "Water Ye" )

2

3

4

5

hello_setup.py
1
from distutils.core import setup
2
import py2exe
3
4
setup(
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
)

2

3

4

5

6

7

8

9

10

11

12

running

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 閱讀(595) 評論(0) 編輯 收藏 所屬分類: python