Tool:cx_Freeze
| Developer | Marcelo Duarte, Anthony Tuininga and contributors |
|---|---|
| License | PSF-derived license (see LICENSE.md in the repository) |
| Website | https://cx-freeze.readthedocs.io |
| On this wiki | Facts · Code · Notes · Topics |
Python freezer for Windows, Linux and macOS: the program is a small prebuilt C executable next to a lib/ folder whose library.zip holds every module as a .pyc file; the build also injects a BUILD_CONSTANTS module and per-executable __init__ and __main__ modules.
Identification
- A cx_Freeze build is a folder: the executable (a prebuilt C stub renamed after the script), the Python runtime DLL or shared library, and
lib/withlibrary.zip, extension modules and data. In the default setup every Python module is a.pycinsidelib/library.zip; packages listed inzip_exclude_packages(the default is all of them,["*"]) are written as plain.pycfiles belowlib/instead of into the zip. A one-line filelib/library.datholds the zip file name (Fact:cx_Freeze/behavior/library.zip layout and library.dat). - Frozen-module names: each executable gets an init module
__init__<name>and a main module__main__<name>(the script), both stored in the zip like normal modules;BUILD_CONSTANTSis a generated module withBUILD_RELEASE_STRINGandBUILD_COPYRIGHT, and__startup__is the common start-up script. Use these names to find the entry point after unzipping (Fact:cx_Freeze/behavior/Frozen module names). - At commit 9f258f9d7340c40df48b11dd4f83af65f87c5a38 the repository no longer contains the C stub source or the
initscripts/directory:pyproject.tomllines 31-32 depend on the separate PyPI packagefreeze-core(>=0.6.1; >=0.8.0 for Python 3.15),cx_Freeze/freezer.pyimportsfreeze_core.utilandfreeze_core.winmsvcr(lines 48-54) and loadsinitscripts/__startup__.pythroughresource_path(lines 460-461).freezer.pylines 821-830 writelib/library.datcontaining the zip file name when the zip name differs from the default, or extract the zip intolib/when no zip is used. Unverified: how the prebuilt stub reads library.dat and puts the zip on sys.path at run time; that code is in freeze-core, which was not read.
.pyc files
The writer prepends the interpreter's MAGIC_NUMBER, then struct.pack("<iLL", 0, mtime, size) (flags 0, source mtime, source size; with no source file the mtime is the build time and size 0) and then marshal.dumps(code) (Fact:cx_Freeze/struct/pyc header written by cx_Freeze). Unlike py2exe the timestamp and size are normally real values. Zip entry timestamps below 1980 are clamped to 1980-01-01.
Extraction
Unzip library.zip with any ZIP tool; the .pyc files decompile with a decompiler that supports the Python version of the magic number (Format:PYC (Python compiled bytecode), Technique:Bundled-runtime applications). Compare Format:PyInstaller archive (CArchive and PYZ) and Tool:Py2exe.
Code & repositories
See the repository list below.
- https://github.com/marcelotduarte/cx_Freeze @
9f258f9d7340c40df48b11dd4f83af65f87c5a38· license: LicenseRef-PSF-derived (declared by the contributor; GitHub's detector did not recognize LICENSE.md)
cx_Freeze: cx_Freeze/freezer.py writes lib/library.zip (_write_modules), executable.py names the __init__ and __main__ modules, module.py generates BUILD_CONSTANTS.
Tested on: source read, not run · checked 2026-10-18; last activity 2026-10-16