CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-cx-freeze

Create standalone executables from Python scripts

Pending
Overview
Eval results
Files

distribution-commands.mddocs/

Distribution Commands

Platform-specific distribution commands create native installers and packages from frozen executables. These commands build upon the core build_exe functionality to produce distributable formats appropriate for each operating system.

Capabilities

Windows Distribution Commands

MSI Installer Creation

Creates Microsoft Installer (.msi) packages with complete Windows integration including shortcuts, registry entries, and uninstall support.

class bdist_msi(Command):
    """Create Microsoft Installer binary distributions."""
    
    def initialize_options(self) -> None:
        """Initialize MSI-specific options."""
    
    def finalize_options(self) -> None:
        """Validate MSI configuration and platform compatibility."""
    
    def run(self) -> None:
        """Create MSI installer package."""
    
    def add_config(self) -> None:
        """Add MSI database configuration."""
    
    def add_properties(self) -> None:
        """Add MSI properties from package metadata."""
    
    def add_files(self) -> None:
        """Add files to MSI database."""
    
    def add_ui(self) -> None:
        """Create complete MSI user interface."""
    
    # Dialog creation methods
    def add_cancel_dialog(self) -> None: ...
    def add_exit_dialog(self) -> None: ...
    def add_progress_dialog(self) -> None: ...
    def add_welcome_dialog(self) -> None: ...

MSI Configuration Options

# MSI package options
target_name: str              # MSI filename
target_version: str           # Product version
product_code: str             # MSI product GUID
upgrade_code: str             # MSI upgrade GUID
initial_target_dir: str       # Default installation directory
add_to_path: bool             # Add to system PATH
all_users: bool              # Install for all users vs current user
install_icon: str             # Shortcut icon file
license_file: str             # License text file
launch_on_finish: bool        # Launch application after install
summary_data: dict            # MSI summary information
directories: dict             # Custom directory structure
environment_variables: dict    # Environment variables to set
extensions: list             # File association extensions

macOS Distribution Commands

DMG Disk Image Creation

Creates Mac disk images (.dmg) containing application bundles with customizable appearance and licensing.

class bdist_dmg(Command):
    """Create Mac DMG disk image distributions."""
    
    def initialize_options(self) -> None:
        """Initialize DMG-specific options."""
    
    def finalize_options(self) -> None:
        """Validate DMG configuration."""
    
    def finalize_dmgbuild_options(self) -> None:
        """Set dmgbuild-specific defaults."""
    
    def run(self) -> None:
        """Create DMG disk image."""
    
    def build_dmg(self) -> None:
        """Execute DMG creation process."""

DMG Configuration Options

# DMG volume settings
volume_label: str             # Volume name
applications_shortcut: bool   # Create Applications folder shortcut
format: str                   # Image format (UDZO, UDBZ, etc.)
filesystem: str               # Filesystem type (HFS+, APFS)
size: str                     # Volume size

# Visual customization
background: str               # Background image path
icon_locations: dict          # Icon positions {filename: (x, y)}
window_rect: tuple           # Finder window dimensions (x, y, width, height)
default_view: str            # Default Finder view mode
show_status_bar: bool        # Show Finder status bar
show_sidebar: bool           # Show Finder sidebar
sidebar_width: int           # Sidebar width in pixels

# License agreement
license: dict                # License with language support
                            # {"default-language": "en", "licenses": {"en": "text"}}

App Bundle Creation

Creates Mac application bundles (.app) with proper structure, metadata, and code signing support.

class bdist_mac(Command):
    """Create Mac application bundle distributions."""
    
    def initialize_options(self) -> None:
        """Initialize Mac app bundle options."""
    
    def finalize_options(self) -> None:
        """Validate and set bundle paths."""
    
    def run(self) -> None:
        """Create complete app bundle."""
    
    def create_plist(self) -> None:
        """Generate Contents/Info.plist file."""
    
    def set_absolute_reference_paths(self, path: str | None = None) -> None:
        """Set absolute library paths using install_name_tool."""
    
    def find_qt_menu_nib(self) -> None:
        """Locate Qt menu resources."""
    
    def prepare_qt_app(self) -> None:
        """Configure Qt application resources."""
    
    # Code signing methods
    def _codesign(self) -> None:
        """Sign the complete application bundle."""
    
    def _codesign_file(self, filename: str) -> None:
        """Sign individual files within bundle."""
    
    def _verify_signature(self) -> None:
        """Verify code signature validity."""

App Bundle Configuration Options

# Bundle structure
bundle_name: str              # Application bundle name (.app)
iconfile: str                 # Application icon (.icns)
custom_info_plist: str        # Custom Info.plist template
plist_items: dict            # Additional Info.plist entries

# Framework and resource inclusion
include_frameworks: list      # Frameworks to bundle
include_resources: list       # Additional resources to include

# Code signing
codesign_identity: str        # Code signing identity
codesign_entitlements: str    # Entitlements file path
codesign_deep: bool          # Deep code signing
codesign_timestamp: bool     # Include secure timestamp

# Qt support
qt_menu_nib: str             # Path to Qt menu.nib

Linux Distribution Commands

AppImage Creation

Creates portable AppImage executables that run on most Linux distributions without installation.

class bdist_appimage(Command):
    """Create Linux AppImage distributions."""
    
    def initialize_options(self) -> None:
        """Initialize AppImage options."""
    
    def finalize_options(self) -> None:
        """Validate Linux platform and get appimagetool."""
    
    def run(self) -> None:
        """Create AppImage package."""
    
    def save_as_file(
        self, 
        data: str, 
        outfile: str, 
        mode: str = "r"
    ) -> None:
        """Save file with proper permissions."""
    
    def warn_delayed(self, msg: str) -> None:
        """Queue warning messages."""
    
    def warnings(self) -> None:
        """Display all queued warnings."""
    
    def _get_appimagekit(self) -> None:
        """Download appimagetool if needed."""

RPM Package Creation

Creates Red Hat Package Manager (.rpm) distributions for Red Hat, SUSE, and other RPM-based Linux distributions.

class bdist_rpm(Command):
    """Create RPM binary distributions."""
    
    def initialize_options(self) -> None:
        """Initialize RPM options."""
    
    def finalize_options(self) -> None:
        """Validate RPM configuration and tools."""
    
    def finalize_package_data(self) -> None:
        """Set RPM metadata defaults."""
    
    def run(self) -> None:
        """Create RPM package."""
    
    def _make_spec_file(self) -> list[str]:
        """Generate RPM spec file."""
    
    def _format_changelog(self, changelog: str) -> list[str]:
        """Format changelog entries correctly."""

RPM Configuration Options

# RPM metadata
group: str                    # RPM group classification
vendor: str                   # Package vendor
packager: str                 # Package maintainer
release: str                  # Release number
serial: int                   # Package serial number

# Dependencies
provides: list[str]           # Capabilities this package provides
requires: list[str]           # Required dependencies
conflicts: list[str]          # Conflicting packages
build_requires: list[str]     # Build-time dependencies
obsoletes: list[str]          # Packages this obsoletes

# Build configuration
rpm_base: str                 # RPM build directory
spec_only: bool              # Generate spec file only
keep_temp: bool              # Keep temporary files
no_autoreq: bool             # Disable automatic requirement generation

# Scripts and documentation
prep_script: str             # %prep script
build_script: str            # %build script  
install_script: str          # %install script
clean_script: str            # %clean script
pre_install: str             # %pre script
post_install: str            # %post script
pre_uninstall: str           # %preun script
post_uninstall: str          # %postun script
doc_files: list[str]         # Documentation files
changelog: str               # Package changelog
icon: str                    # Package icon

DEB Package Creation

Creates Debian (.deb) packages by converting RPM packages using the alien tool.

class bdist_deb(Command):
    """Create DEB distributions by converting RPM."""
    
    def initialize_options(self) -> None:
        """Initialize basic options."""
    
    def finalize_options(self) -> None:
        """Check for required tools (alien, fakeroot)."""
    
    def run(self) -> None:
        """Convert RPM to DEB format."""

Usage Examples

from cx_Freeze import setup, Executable

# Multi-platform setup with distribution commands
setup(
    name="MyApp",
    version="1.0.0",
    description="My Application",
    executables=[
        Executable("main.py", base="gui", icon="app.ico")
    ],
    options={
        "build_exe": {
            "packages": ["tkinter"],
            "include_files": [("data/", "data/")]
        },
        "bdist_msi": {
            "target_name": "MyApp-1.0.0",
            "add_to_path": True,
            "install_icon": "app.ico",
            "license_file": "LICENSE.txt"
        },
        "bdist_dmg": {
            "volume_label": "MyApp Installer",
            "applications_shortcut": True,
            "background": "dmg_background.png"
        },
        "bdist_mac": {
            "bundle_name": "MyApp.app",
            "iconfile": "app.icns",
            "codesign_identity": "Developer ID Application: Your Name"
        }
    }
)

# Command-line usage
# python setup.py bdist_msi
# python setup.py bdist_dmg  
# python setup.py bdist_mac
# python setup.py bdist_rpm
# python setup.py bdist_appimage

Platform-Specific Requirements

Each distribution command has specific system requirements and dependencies.

Windows (bdist_msi):

  • Windows SDK or Visual Studio
  • MSI database tools
  • Optional: Code signing certificate

macOS (bdist_dmg, bdist_mac):

  • Xcode command line tools
  • dmgbuild package (for DMG creation)
  • Optional: Apple Developer certificate for code signing

Linux (bdist_rpm, bdist_deb, bdist_appimage):

  • rpm-build package (for RPM)
  • alien and fakeroot (for DEB)
  • appimagetool (for AppImage, auto-downloaded)
  • Optional: GPG key for package signing

Error Handling

# Platform validation
class PlatformError(Exception):
    """Raised for platform-specific errors."""

# Tool requirements
class ExecError(Exception):
    """Raised when external tools are missing or fail."""

# Configuration validation  
class OptionError(Exception):
    """Raised for invalid distribution options."""

Install with Tessl CLI

npx tessl i tessl/pypi-cx-freeze

docs

advanced-freezing.md

build-commands.md

cli-tools.md

distribution-commands.md

executable-config.md

index.md

tile.json