or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

advanced-freezing.mdbuild-commands.mdcli-tools.mddistribution-commands.mdexecutable-config.mdindex.md
tile.json

tessl/pypi-cx-freeze

Create standalone executables from Python scripts

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/cx-freeze@8.4.x

To install, run

npx @tessl/cli install tessl/pypi-cx-freeze@8.4.0

index.mddocs/

cx_Freeze

A cross-platform Python package that creates standalone executables from Python scripts, maintaining the same performance as the original script. cx_Freeze provides a comprehensive build system for packaging Python applications into distributable executables for Windows, macOS, and Linux platforms.

Package Information

  • Package Name: cx_Freeze
  • Language: Python
  • Installation: pip install cx_Freeze

Core Imports

import cx_Freeze
from cx_Freeze import setup, Executable

For specific functionality:

from cx_Freeze import (
    setup, Executable, Freezer, ConstantsModule,
    build_exe, ModuleFinder, Module, __version__
)

Basic Usage

from cx_Freeze import setup, Executable

# Define executable to create
executables = [
    Executable("main.py", base="console")
]

# Setup configuration
setup(
    name="MyApp",
    version="1.0",
    description="My Application",
    executables=executables,
    options={
        "build_exe": {
            "packages": ["tkinter"],
            "excludes": ["unittest"],
            "include_files": ["data/"]
        }
    }
)

Command-line usage:

# Basic freezing
cxfreeze --script main.py --target-dir dist

# With options
cxfreeze --script main.py --base gui --icon app.ico --target-dir dist

# Using setup.py
python setup.py build_exe

# Create MSI installer (Windows)
python setup.py bdist_msi

Architecture

cx_Freeze operates through several key components:

  • Freezer: Core freezing engine that analyzes dependencies and creates executables
  • ModuleFinder: Discovers required modules through import analysis
  • Executable: Represents an executable configuration with scripts, icons, and metadata
  • Commands: Build and distribution commands for different platforms
  • Hooks: Package-specific customizations for popular libraries
  • Base Executables: Platform-specific executable templates (console, gui, service)

The freezing process works by:

  1. Analyzing the main script and discovering all imported modules
  2. Collecting Python modules, shared libraries, and data files
  3. Creating a base executable that embeds the Python interpreter
  4. Packaging everything into a distributable directory or installer

Capabilities

Core Executable Creation

The fundamental capability for defining and creating executable files from Python scripts, with support for different base types, icons, and metadata configuration.

class Executable:
    def __init__(
        self,
        script: str | Path,
        init_script: str | Path | None = None,
        base: str | Path | None = None,
        target_name: str | None = None,
        icon: str | Path | None = None,
        shortcut_name: str | None = None,
        shortcut_dir: str | Path | None = None,
        copyright: str | None = None,
        trademarks: str | None = None,
        manifest: str | Path | None = None,
        uac_admin: bool = False,
        uac_uiaccess: bool = False,
    )

def setup(**attrs) -> setuptools.Distribution

Executable Configuration

Build System Integration

Setuptools-compatible build commands for creating executables and managing the freezing process with extensive configuration options.

class build_exe(Command):
    def initialize_options(self) -> None
    def finalize_options(self) -> None
    def run(self) -> None

Build Commands

Installation Commands

Installation commands for deploying built executables and managing the installation process with customizable directory options.

class install(Command):
    """Install everything from build directory."""

class install_exe(Command):
    """Install executables built from Python scripts."""

Platform-Specific Distribution

Creation of platform-native installers and packages including MSI files for Windows, DMG and app bundles for macOS, and AppImages, DEBs, and RPMs for Linux.

# Windows
class bdist_msi(Command): ...

# macOS  
class bdist_dmg(Command): ...
class bdist_mac(Command): ...

# Linux
class bdist_appimage(Command): ...
class bdist_deb(Command): ...
class bdist_rpm(Command): ...

Distribution Commands

Command-Line Interface

Complete command-line tools for freezing scripts and generating setup configurations without requiring Python programming.

def main() -> None  # cxfreeze command
def main() -> None  # cxfreeze-quickstart command

Command-Line Tools

Advanced Freezing Control

Direct access to the freezing engine for programmatic control over module discovery, dependency analysis, and executable creation.

class Freezer:
    def __init__(
        self,
        executables: Sequence[Executable, Mapping[str, str], str],
        constants_module: ConstantsModule | None = None,
        includes: list[str] | None = None,
        excludes: list[str] | None = None,
        packages: list[str] | None = None,
        # ... additional configuration
    )

class ModuleFinder:
    # Module discovery and analysis methods

class Module:
    # Module representation and manipulation

Advanced Freezing

Types

# Core exception types
class OptionError(Exception):
    """Raised when an error is detected in configuration."""

class SetupError(Exception):
    """Raised for setup script errors."""

class ModuleError(Exception):
    """Raised when there are problems loading modules."""

class FileError(Exception):
    """Raised for file/resource not found errors."""

class BindError(Exception):
    """Raised for Windows resource binding errors (Windows only)."""

# Platform-specific types (Windows only)
HANDLE = int | None  # Windows resource handle type