Global options:
--verbose (-v) run verbosely (default)
--quiet (-q) run quietly (turns verbosity off)
--dry-run (-n) don't actually do anything
--help (-h) show detailed help message
--no-user-cfg ignore pydistutils.cfg in your home directory
Options for 'py2exe' command:
--optimize (-O) optimization level: -O1 for "python -O", -O2 for
"python -OO", and -O0 to disable [default: -O0]
--dist-dir (-d) directory to put final built distributions in (default
is dist)
--excludes (-e) comma-separated list of modules to exclude
--dll-excludes comma-separated list of DLLs to exclude
--ignores comma-separated list of modules to ignore if they are
not found
--includes (-i) comma-separated list of modules to include
--packages (-p) comma-separated list of packages to include
--compressed (-c) create a compressed zipfile
--xref (-x) create and show a module cross reference
--bundle-files (-b) bundle dlls in the zipfile or the exe. Valid levels
are 1, 2, or 3 (default)
--skip-archive do not place Python bytecode files in an archive, put
them directly in the file system
--ascii (-a) do not automatically include encodings and codecs
--custom-boot-script Python file that will be run when setting up the
runtime environment
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
2: 一个详细的编译脚本
代码如下:
# -*- coding: cp936 -*-
from distutils.core import setup
import py2exe
includes = ["encodings", "encodings.*"]
options = {"py2exe":
{"compressed": 1, # 压缩
"optimize": 2, # 优化级别
"ascii": 1, #
"includes":includes, # 编码方式
"bundle_files": 1 # 所有文件打包成一个zipfile或exe文件,有效级别1,2,3
}}
setup(
options=options, # 是否需要可选项,默认为None
zipfile=None, # 是否需要压缩像,默认为None
console=[{"script": "HelloCmd.py", "icon_resources": [(1, "pc.ico")]}], # 针对CMD控制端口
windows=[{"script": "HelloWin.py", "icon_resources": [(1, "pc.ico")]}], # 针对GUI图形窗口
data_files=[("magic",["App_x86.exe",]),],
version = "v1.01", # 版本信息
description = "py2exe testing",# 描述信息
name = "Hello, Py2exe", # 名字信息
)