### Generating Windows Installer with cx_Freeze Source: https://cx-freeze.readthedocs.io/en/stable/setup_script This command shows how to build a Windows MSI installer for your cx_Freeze application. It leverages setuptools' bdist_msi command to package all necessary files. ```python python setup.py bdist_msi ``` -------------------------------- ### Building AppImage with cx_Freeze Source: https://cx-freeze.readthedocs.io/en/stable/bdist_appimage This command initiates the process of building an AppImage distribution using cx_Freeze. It is typically executed via the command line or through a setup script. Ensure cx_Freeze is installed in your environment. ```bash cxfreeze bdist_appimage ``` ```python python setup.py bdist_appimage ``` -------------------------------- ### cx_Freeze Setup with setup.py Source: https://cx-freeze.readthedocs.io/en/stable/setup_script This Python script demonstrates how to configure cx_Freeze build options within a setup.py file. It allows for specifying executables, build options like exclusions and included packages, and integrates with setuptools. Dependencies are often auto-detected but may require manual tuning. ```python from cx_Freeze import setup # Dependencies are automatically detected, but they might need fine-tuning. build_exe_options = { "excludes": ["tkinter", "unittest"], "zip_include_packages": ["encodings", "PySide6", "shiboken6"], } setup( name="guifoo", version="0.1", description="My GUI application!", options={"build_exe": build_exe_options}, executables=[{"script": "guifoo.py", "base": "gui"}], ) ``` ```python from cx_Freeze import setup build_exe_options = { "zip_include_packages": ["encodings", "PySide6", "shiboken6"], } setup( name="guifoo", version="0.1", description="My GUI application!", options={"build_exe": build_exe_options}, executables=[{"script": "guifoo.py", "base": "gui"}], ) ``` -------------------------------- ### cx_Freeze Executable and Setup Configuration Source: https://cx-freeze.readthedocs.io/en/stable/bdist_msi Sets up the main cx_Freeze build process, defining executable files, build options (like excluding Tkinter and including MSVC runtime), and MSI specific options. This script orchestrates the creation of standalone executables and MSI installers. ```python build_exe_options = {"excludes": ["tkinter"], "include_msvcr": True} executables = [ Executable( "hello.py", base="gui", copyright="Copyright (C) 2025 cx_Freeze", icon="icon.ico", shortcut_name="My Program Name", shortcut_dir="MyProgramMenu", ) ] setup( name="hello", version="0.1", description="Sample cx_Freeze script to test MSI arbitrary data stream", executables=executables, options={ "build_exe": build_exe_options, "bdist_msi": bdist_msi_options, }, ) ``` -------------------------------- ### cx_Freeze Command Line Build Execution Source: https://cx-freeze.readthedocs.io/en/stable/setup_script These commands demonstrate how to initiate the cx_Freeze build process using different configuration methods. They show invocation via pyproject.toml, setup.py, setup.cfg, and direct command-line options. ```bash cxfreeze build ``` ```bash python setup.py build ``` ```bash cxfreeze --script=guifoo.py --base=gui ``` ```bash python setup.py build_exe --excludes=tkinter,unittest ``` -------------------------------- ### cx_Freeze Option Naming Convention Source: https://cx-freeze.readthedocs.io/en/stable/setup_script This section highlights the difference in naming conventions for cx_Freeze options between script configuration (underscores) and command-line arguments (dashes). For example, `zip_include_packages` in scripts becomes `--zip-include-packages` on the command line. ```python # ... zip_include_packages = ["encodings", "PySide6", "shiboken6"] ``` ```bash python setup.py build_exe --zip-include-packages=encodings,PySide6,shiboken6 ``` -------------------------------- ### cx_Freeze Build Command Help Source: https://cx-freeze.readthedocs.io/en/stable/setup_script This command displays the help options available for the 'build' command in cx_Freeze, which is used to build executables. It lists available arguments for customization, such as specifying the build base directory and compiler type. ```bash python setup.py build --help ``` -------------------------------- ### cx_Freeze Configuration using pyproject.toml Source: https://cx-freeze.readthedocs.io/en/stable/setup_script This snippet shows how to configure cx_Freeze build options, such as executables, excluded modules, and packages to include in the zip, using the pyproject.toml file. It relies on the TOML format for configuration. ```toml [project] name = "guifoo" version = "0.1" description = "My GUI application!" [tool.cxfreeze] executables = [ {script = "guifoo.py", base = "gui"} ] [tool.cxfreeze.build_exe] excludes = ["tkinter", "unittest"] zip_include_packages = ["encodings", "PySide6", "shiboken6"] ``` -------------------------------- ### Execute cx_Freeze bdist_msi Command Source: https://cx-freeze.readthedocs.io/en/stable/bdist_msi This command initiates the process of building a Windows installer package using cx_Freeze. It requires no specific input arguments but relies on configuration defined elsewhere (e.g., in `setup.py` or `pyproject.toml`). ```bash cxfreeze bdist_msi ``` -------------------------------- ### Install cx_Freeze using pip Source: https://cx-freeze.readthedocs.io/en/stable/installation Installs or upgrades cx_Freeze to the latest version using pip. It's recommended to use this within a virtual environment. This command fetches the package from PyPI. ```bash pip install --upgrade cx_Freeze ``` ```bash uv pip install --upgrade cx_Freeze ``` -------------------------------- ### Install Patchelf on Debian-based Systems Source: https://cx-freeze.readthedocs.io/en/stable/faq This command installs the Patchelf utility on Debian-based Linux distributions using the apt-get package manager. Patchelf is required for cx_Freeze on Linux and Unix-like systems. ```bash sudo apt-get install patchelf ``` -------------------------------- ### cx_Freeze Configuration using setup.cfg Source: https://cx-freeze.readthedocs.io/en/stable/setup_script This INI-style configuration file defines cx_Freeze build options, including metadata and build-specific settings like excluded modules and packages to include in the zip. It's parsed by setuptools and cx_Freeze. ```ini [metadata] name = guifoo version = 0.1 description = My GUI application! [build_exe] excludes = tkinter,unittest zip_include_packages = encodings,PySide6,shiboken6 ``` -------------------------------- ### cx_Freeze Python Requirements Source: https://cx-freeze.readthedocs.io/en/stable/installation Lists the core Python packages required by cx_Freeze, along with specific version constraints. These requirements are automatically handled by pip or conda during installation. ```text > freeze-core >= 0.4.0 packaging >= 24 setuptools >= 78.1.1,<81 tomli >= 2.0.1 # Python 3.10, Python 3.11+ has tomllib filelock >= 3.15.3 # Linux patchelf >= 0.14,<0.18 # Linux dmgbuild >= 1.6.1 # macOS lief >= 0.15.1 # Windows python-msilib >= 0.4.1 # Python 3.13+ on Windows ``` -------------------------------- ### Generating macOS Bundles/Disk Images with cx_Freeze Source: https://cx-freeze.readthedocs.io/en/stable/setup_script These commands illustrate how to create Mac application bundles or disk images using cx_Freeze on macOS. `bdist_mac` creates an application bundle, while `bdist_dmg` creates a disk image. ```python python setup.py bdist_mac ``` ```python python setup.py bdist_dmg ``` -------------------------------- ### Install cx_Freeze using conda Source: https://cx-freeze.readthedocs.io/en/stable/installation Installs cx_Freeze from the conda-forge channel using the conda package manager. This command ensures that cx_Freeze and its dependencies are managed by conda. ```bash conda install conda-forge:cx_freeze ``` -------------------------------- ### Install Patchelf on Fedora Systems Source: https://cx-freeze.readthedocs.io/en/stable/faq This command installs the Patchelf utility on Fedora Linux systems using the dnf package manager. Patchelf is necessary for cx_Freeze functionality on Linux environments. ```bash dnf install patchelf ``` -------------------------------- ### Install Microsoft Visual C++ Redistributable on Windows Source: https://cx-freeze.readthedocs.io/en/stable/faq These Windows command-line commands use the `winget` package manager to upgrade or install the Microsoft Visual C++ Redistributable packages for x64 and x86 architectures. This is often required for Python applications on Windows, especially with newer versions. ```bash winget upgrade Microsoft.VCRedist.2015+.x64 winget upgrade Microsoft.VCRedist.2015+.x86 ``` -------------------------------- ### cx_Freeze Executable Class Source: https://cx-freeze.readthedocs.io/en/stable/setup_script The Executable class in cx_Freeze allows specification of values specific to a particular executable build. This includes settings for the script, initialization script, base executable, target name, icons, manifests, UAC settings, shortcuts, and version resource information. ```APIDOC ## cx_Freeze Executable Class ### Description This class allows for the specification of options for individual executables created by cx_Freeze. ### Constructor Arguments #### `script` - **type**: string - **description**: The name of the file containing the script to be frozen. #### `init_script` - **type**: string - **description**: The name of the initialization script to be executed before the actual script. If a name is given without an absolute path, it searches in the `initscripts` subdirectory of the `cx_Freeze` package. #### `base` - **type**: string - **description**: The name of the base executable. Pre-defined values are "console", "gui", and "service". A user-defined base is accepted if given with an absolute path. Defaults to "console". #### `target_name` - **type**: string - **description**: The name of the target executable. The default value is the name of the script. It is recommended not to use an extension (automatically added on Windows). Version in the name is supported (e.g., "Hello-0.1"). If a path is specified, it raises an error. Note: This can only be modified after the build if only one Executable is built. #### `icon` - **type**: string - **description**: The name of the icon to be included in the executable itself on Windows (ignored by Python apps from the Microsoft Store) or placed in the target directory for other platforms. It is recommended not to use an extension (automatically added as ".ico" on Windows, ".icns" on macOS, and ".png" or ".svg" on Linux and others). #### `manifest` - **type**: string - **description**: The name of the manifest file to be included in the executable itself (Windows only - ignored by Python apps from the Microsoft Store). Added in version 6.10. #### `uac_admin` - **type**: boolean - **description**: Creates a manifest for an application that will request elevation (Windows only - ignored by Python apps from the Microsoft Store). Added in version 6.10. #### `uac_uiaccess` - **type**: boolean - **description**: Changes the application manifest to bypass user interface control (Windows only - ignored by Python apps from the Microsoft Store). Added in version 7.0. #### `shortcut_name` - **type**: string - **description**: The name to give a shortcut for the executable when included in an MSI package (Windows only). #### `shortcut_dir` - **type**: string - **description**: The directory in which to place the shortcut when being installed by an MSI package. Refer to the MSI Shortcut table documentation for more information on valid values. #### `copyright` - **type**: string - **description**: The copyright value to include in the version resource associated with the executable (Windows only). #### `trademarks` - **type**: string - **description**: The trademarks value to include in the version resource associated with the executable (Windows only). ### Notes - `setup` accepts a list of `Executable` objects. - Arguments are all snake_case (camelCase was removed in version 6.15). ### See Also - [Windows Manifest](https://docs.microsoft.com/en-us/windows/desktop/sbscs/application-manifests) - [Important note for uiaccess](https://docs.microsoft.com/en-us/windows/desktop/uxguide/winenv-uiaccess) ``` -------------------------------- ### cx_Freeze MSI Build Options Source: https://cx-freeze.readthedocs.io/en/stable/bdist_msi Configures options for the `bdist_msi` command in cx_Freeze. It includes settings for adding the installation directory to the system's PATH, providing custom MSI data, defining environment variables, and specifying an upgrade code for managing application updates. ```python bdist_msi_options = { "add_to_path": True, "data": msi_data, "environment_variables": [ ("E_MYAPP_VAR", "=-*MYAPP_VAR", "1", "TARGETDIR") ], "upgrade_code": "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}", } ``` -------------------------------- ### cx_Freeze MSI Build Configuration Example Source: https://cx-freeze.readthedocs.io/en/stable/bdist_msi This TOML snippet demonstrates how to configure the cx_Freeze `bdist_msi` command within a `pyproject.toml` file. It includes settings for executables, build exclusions, MSI-specific options like environment variables, and path additions. ```toml [project] name = "hello" version = "0.1.2.3" description = "Sample cx_Freeze script to test MSI arbitrary data stream" [[tool.cxfreeze.executables]] script = "hello.py" base = "gui" copyright = "Copyright (C) 2025 cx_Freeze" icon = "icon.ico" shortcut_name = "My Program Name" shortcut_dir = "MyProgramMenu" [tool.cxfreeze.build_exe] excludes = ["tkinter", "unittest"] include_msvcr = true [tool.cxfreeze.bdist_msi] add_to_path = true environment_variables = [ ["E_MYAPP_VAR", "=-*MYAPP_VAR", "1", "TARGETDIR"] ] ``` -------------------------------- ### Python Multiprocessing with cx_Freeze Source: https://cx-freeze.readthedocs.io/en/stable/faq Example of using multiprocessing in a cx_Freeze executable. It demonstrates the necessity of calling multiprocessing.freeze_support() immediately after the if __name__ == "__main__" block to ensure proper process management on all platforms. ```python from multiprocessing import Process, freeze_support def f(): print("Hello from cx_Freeze") if __name__ == "__main__": freeze_support() Process(target=f).start() ``` -------------------------------- ### cx_Freeze MSI Data Configuration Source: https://cx-freeze.readthedocs.io/en/stable/bdist_msi Defines custom data for MSI packages, including directory structures, program IDs with descriptions and icons, and icon file associations. This configuration allows for fine-grained control over the installer's behavior and appearance. ```python directory_table = [ ("ProgramMenuFolder", "TARGETDIR", "."), ("MyProgramMenu", "ProgramMenuFolder", "MYPROG~1|My Program"), ] msi_data = { "Directory": directory_table, "ProgId": [ ("Prog.Id", None, None, "This is a description", "IconId", None), ], "Icon": [ ("IconId", "icon.ico"), ], } ``` -------------------------------- ### Execute bdist_msi via setup.py Source: https://cx-freeze.readthedocs.io/en/stable/bdist_msi This command uses the standard Python `setup.py` script to invoke the `bdist_msi` command provided by cx_Freeze. This method is common for managing build processes within Python projects. ```python python setup.py bdist_msi ``` -------------------------------- ### Create RPM Package using Python setup.py Source: https://cx-freeze.readthedocs.io/en/stable/bdist_rpm This command achieves the same goal as the `cxfreeze` command by invoking the `bdist_rpm` command through the `setup.py` script. It's an alternative method for initiating RPM package creation. ```python python setup.py bdist_rpm ``` -------------------------------- ### cx_Freeze Command Line for Ignoring Warnings Source: https://cx-freeze.readthedocs.io/en/stable/faq This command demonstrates how to use cx_Freeze from the command line to build an executable while ignoring the runtime warning message related to multiprocessing.freeze_support. The `--constants` option with `ignore_freeze_support_message=1` is used. ```bash cxfreeze --script test.py build_exe --constants='ignore_freeze_support_message=1' ``` -------------------------------- ### Create RPM Package using cxfreeze Source: https://cx-freeze.readthedocs.io/en/stable/bdist_rpm This command initiates the creation of an RPM package using cx_Freeze. It leverages the `bdist_rpm` command to build the package for RPM-based Linux distributions. ```shell cxfreeze bdist_rpm ``` -------------------------------- ### Specify Packager in RPM Creation via setup.py Source: https://cx-freeze.readthedocs.io/en/stable/bdist_rpm This Python command-line invocation allows specifying the packager's information when creating an RPM package. It's the equivalent of using `cxfreeze` with the `--packager` option. ```python python setup.py bdist_rpm --packager="John Doe " ``` -------------------------------- ### Configuring AppImage Update Information Source: https://cx-freeze.readthedocs.io/en/stable/bdist_appimage This configuration snippet shows how to embed update information into an AppImage using cx_Freeze's pyproject.toml. It specifies the update mechanism (zsync) and the URL for update files. This allows the AppImage to check for and apply updates automatically. ```toml [tool.cxfreeze.bdist_appimage] updateinformation = "zsync|https://example.com/path/simple/simple.AppImage.zsync" ``` -------------------------------- ### Specify Packager in RPM Creation Source: https://cx-freeze.readthedocs.io/en/stable/bdist_rpm This command demonstrates how to specify packager details when creating an RPM package. The `--packager` option allows you to set the packager's name and email, which is included in the RPM metadata. ```shell cxfreeze bdist_rpm --packager="John Doe " ``` -------------------------------- ### Find Data File Path in cx_Freeze Applications Source: https://cx-freeze.readthedocs.io/en/stable/faq This Python function helps locate data files bundled with a cx_Freeze application. It checks if the application is frozen and adjusts the search path accordingly. It requires the `sys` and `os` modules and returns the full path to the specified data file. ```python import sys import os def find_data_file(filename): if getattr(sys, "frozen", False): # The application is frozen datadir = sys.prefix else: # The application is not frozen # Change this bit to match where you store your data files: datadir = os.path.dirname(__file__) return os.path.join(datadir, filename) ``` -------------------------------- ### Generate RPM Spec File Only Source: https://cx-freeze.readthedocs.io/en/stable/bdist_rpm This command instructs `bdist_rpm` to only generate the `.spec` file for the RPM package and then exit. The `.spec` file is written to the distribution directory, typically `dist/`, allowing for manual inspection or modification. ```shell cxfreeze bdist_rpm --spec-only ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.