Monday, February 3, 2014

How to avoid cx_Freeze generating Library.zip when packing Python files?

The cx_Freeze is a tool that packs Python files to generate a EXE file. How do we avoid it generating Library.zip? The following source tree is an example.

[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

The content of the Setup.py is:

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.
}
}
)
view raw Setup.py hosted with ❤ by GitHub
We perform the following command to pack MyApp.py in MyApp.exe.

Workspace> python MyApp\Setup.py build

You cannot find Library.zip in the build directory because create_shared_zip is assigned to False.

-Count

No comments:

Post a Comment