Skip to content

How To: Protect a cx_Freeze Application

cx_Freeze is a popular Python packaging tool that produces a directory of files. PyLocket supports cx_Freeze output on all platforms.


Prerequisites

  • PyLocket CLI installed and authenticated
  • An app registered with PyLocket
  • cx_Freeze installed (pip install cx_Freeze)

Build with cx_Freeze

Using a setup.py

# setup.py
from cx_Freeze import setup, Executable

setup(
    name="MyApp",
    version="1.0",
    executables=[Executable("myapp.py")],
)
python setup.py build

This creates build/exe.<platform>/ containing your executable and dependencies.

Using cxfreeze CLI

cxfreeze myapp.py --target-dir dist/myapp

Package for Upload

Compress the cx_Freeze output directory:

cd build
zip -r myapp-cxfreeze.zip exe.linux-x86_64-3.12/

Protect

pylocket protect \
  --app <APP_ID> \
  --artifact build/myapp-cxfreeze.zip \
  --platform linux-x64 \
  --python 3.12

Download

pylocket fetch --build <BUILD_ID> --out dist/protected/

Notes

  • cx_Freeze always produces a directory (no onefile mode). Compress the directory into a ZIP before uploading.
  • The --python version must match the Python used to build with cx_Freeze.
  • Non-Python files (data, images) are passed through without encryption.

See Also