如何避免cx_Freeze產生Library.zip

cx_Freeze這個工具,可將Python檔案,包裝成一個EXE檔。此外,它還會產生一個Library.zip。如何叫它不要產生呢?底下是要用cx_Freeze打包的Source Tree:

[Workspace]
  [MyApp]
    Setup.py ---- cx_Freeze setup program
    MyApp.py ---- the python file that will be packed in EXE.
  [build]    ---- The directory is generated by cx_Freeze

底下是Setup.py代碼

import sys
import os
from cx_Freeze import setup, Executable

Exe1 = Executable (
        script=r"MyApp\MyApp.py",
        base=None,
        appendScriptToExe = True,
        appendScriptToLibrary = False,        
        )

includes = []
excludes = []
packages = []
path = sys.path

setup (
    name = "MyApp",
    version = "0.1",
    description = MyApp,
    executables = [Exe1],
    options = {
        "build_exe": {
            "includes": includes,
            "excludes": excludes,
            "packages": packages,
            "path": path,
            "create_shared_zip": False,
                # don't generate Library.zip
            "append_script_to_exe": True,
                # don't generate MyApp.zip file.
            }            
        }
    )

用下面的指令,打包MyApp.py,產生MyApp.exe。

Workspace> python MyApp\Setup.py build

我們可以發現,Library.zip不會被產生了。這是因為我們將create_shared_zip設為False。


-Count


你可能感兴趣的:(如何避免cx_Freeze產生Library.zip)