# -*- coding: utf-8 -*-

#import distutils

#import py2exe

#from distutils.core import setup

#distutils.core.setup(windows=['first_app.py'])

#setup(console=[r’C:\Users\liumingjie\Desktop\first_app.py’])

from distutils.core import setup

import sys

import py2exe

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

sys.argv.append("py2exe")

options = {"py2exe":{"bundle_files":1}}

options = {"py2exe": {"compressed": 1, #压缩 "optimize": 2, "ascii": 1, "includes":includes, "bundle_files": 3 #所有文件打包成一个exe文件 } }

setup(

options = options,

zipfile = None,

description = "this is a py2exe test",

version = "0.1.0",

name = "search panda",

windows = [

{ "script": "first_app.py", "icon_resources": [(1, "hw.ico")] } ], )

 

 

 

用py2exe setup.py与主程序入口文件放同级目录下,options = {"py2exe": {"compressed": 1,
"optimize": 0,
"packages":[
这里放你的包 ],
"includes":[], "dist_dir":xxx}},。。。。。。。。。。。。

py2exe.
给你个例子

  Python code

  from distutils.core import setup import os import py2exe import pymssql data_files = [] data_files.append(os.path.join(os.path.split(pymssql.__file__)[0], 'ntwdblib.dll')) py2exe_options = {"includes": ['decimal','sqlalchemy.dialects.mssql','pyodbc']} setup(console=["com/engine/crawl.py"], options={"py2exe": py2exe_options}, data_files=data_files)

 

 

py2exe不仅可以包含py文件,还可以包含其他文件,比如

 setup(console=["hello.py", "hello1.py"], windows=["hello2.py"],

     data_files=[("img",

                  [r"d:\documents\matrix.jpg",

                   r"d:\documents\Batman.jpg"]),

                 ("xml",

                  [r"D:\tmp\mypaint.xml",

                   r"D:\tmp\mypuzzle.xml",

                   r"D:\tmp\mypuzzle1.xml"])])

相关文章:

  • 2021-06-03
  • 2021-07-07
  • 2022-01-10
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
猜你喜欢
  • 2022-12-23
  • 2021-05-23
  • 2022-03-05
  • 2021-11-08
  • 2022-12-23
  • 2021-10-23
  • 2021-06-13
相关资源
相似解决方案