将项目打包到 excutableinstaller 中

cx_Freeze - 一个工具可以将项目打包到 excutable / installer

  • 在通过 pip 安装后,打包 demo.py,我们需要 setup.py 如下。
import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {
    "excludes": ["tkinter"],
    "include_files":[('./platforms','./platforms')] # need qwindows.dll for qt5 application
}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(  name = "demo",
        version = "0.1",
        description = "demo",
        options = {"build_exe": build_exe_options},
        executables = [Executable("demo.py", base=base)])
  • 然后建立
python .\setup.py build
  • 分开
python .\setup.py bdist_msi