python 中关于py2exe打包

目录:
2014/07/02  15:53    <DIR>          dist
2014/07/02  14:57    <DIR>          lib
2014/07/02  14:57               167 runtime.py
2014/07/02  15:37                 3 start.bat
2014/07/02  15:29               307 test.py

lib:
2014/07/02  14:57               167 runtime.py
2014/07/02  14:57               362 runtime.pyc
2014/06/16  11:14                 0 __init__.py
2014/07/02  14:57               119 __init__.pyc

安装py2exe:

建立setup.py

from distutils.core import setup
import py2exe

includes = ["encodings", "encodings.*"]
options = {"py2exe":
           {
               "compressed":1,        ##压缩
               "optimize":2,
               "includes": includes,
               "bundle_files":1       ##全部文件打包成一个exe文件
               }
           }
data_files = [('cfg',['cfg\config.txt']),('log',glob.glob('log\\*'))]
setup(
    version = '1.0.0',
    description = "mock",
    name = "mock",
    options = options,
    zipfile = None,
    console=[{"script":"test.py"}],
    data_files = data_files
    ) 

执行:
cmd 进入当前目录
python setup.py py2exe

在目录的dist下生成了exe文件


若是包含第三方库的pyodbc的话python

在includes中添加一项,以下sql

includes = ["encodings", "encodings.*","decimal"]


若是包含第三方库的pymssql的话app

data_files.append(os.path.join(os.path.split(pymssql.__file__)[0], 'ntwdblib.dll'))
相关文章
相关标签/搜索