### Full cx_Freeze Setup for MSI Build Source: https://cx-freeze.readthedocs.io/en/stable/bdist_msi.html A complete setup.py script demonstrating how to configure cx_Freeze for building an MSI installer, including executable definitions, build options, and MSI-specific configurations. ```python from cx_Freeze import Executable, setup 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"), ], } 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}", } build_exe_options = {"excludes": ["tkinter"], "include_msvcr": True} executables = [ Executable( "hello.py", base="gui", copyright="Copyright (C) 2026 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, }, ) ``` -------------------------------- ### Conda-forge Requirements Example (Linux) Source: https://cx-freeze.readthedocs.io/en/stable/development/index.html Example of setting up a conda environment for cx_Freeze development on Linux, including installing specific packages and dependencies. ```bash git clone https://github.com/marcelotduarte/cx_Freeze cd cx_Freeze conda create -n cx313conda -c conda-forge python=3.13 -y conda activate cx313conda conda install -c conda-forge patchelf -y conda install -c conda-forge --file=requirements-dev.txt prek install --install-hooks --overwrite -t pre-commit pip install -e. --no-deps --no-build-isolation ``` -------------------------------- ### Specify zip_include_packages in setup.py Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html Example of how to specify packages to be included in the zip archive within a setup.py script. ```python # ... zip_include_packages = ["encodings", "PySide6", "shiboken6"] ``` -------------------------------- ### Run bdist_msi with setup.py Source: https://cx-freeze.readthedocs.io/en/stable/bdist_msi.html Use this command to build a Windows MSI installer when your project is configured using setup.py. ```python python setup.py bdist_msi ``` -------------------------------- ### Display install_exe Command Options Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html Use this command to view the available options for the install_exe command when customizing executable installations. ```bash python setup.py install_exe --help ``` -------------------------------- ### Install Patchelf on Fedora Source: https://cx-freeze.readthedocs.io/en/stable/faq.html Use this command to install the Patchelf utility on Fedora Linux. ```bash dnf install patchelf ``` -------------------------------- ### Setup cx_Freeze Executable with setup.py Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html Configure build options and executables directly within a Python setup.py script for cx_Freeze projects. ```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"}], ) ``` -------------------------------- ### Install Patchelf on Debian-based systems Source: https://cx-freeze.readthedocs.io/en/stable/faq.html Use this command to install the Patchelf utility on Debian-based Linux distributions. ```bash sudo apt-get install patchelf ``` -------------------------------- ### Install cx_Freeze using uv Source: https://cx-freeze.readthedocs.io/en/stable/installation.html Install or upgrade cx_Freeze using the uv package manager. It is recommended to use this within a virtual environment. ```bash uv pip install --upgrade cx_Freeze ``` -------------------------------- ### Build MSI Installer on Windows Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html Command to generate a Windows Installer (MSI) package for your cx_Freeze application. ```bash python setup.py bdist_msi ``` -------------------------------- ### Install cx_Freeze without Make Source: https://cx-freeze.readthedocs.io/en/stable/development/index.html If make is not installed, upgrade pip and install cx_Freeze in editable mode with development and documentation dependencies. ```bash python -m pip install --upgrade pip pip install -e .[dev,doc] prek install --install-hooks --overwrite -t pre-commit ``` -------------------------------- ### Configure bdist_msi in pyproject.toml Source: https://cx-freeze.readthedocs.io/en/stable/bdist_msi.html Example configuration for the bdist_msi command within a pyproject.toml file, demonstrating options like adding to PATH, environment variables, and product naming. ```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) 2026 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"] ] product_name = "Hello cx_Freeze" ``` -------------------------------- ### Install cx_Freeze using pip Source: https://cx-freeze.readthedocs.io/en/stable/installation.html Use this command to install or upgrade to the latest version of cx_Freeze with pip. It is recommended to use this within a virtual environment. ```bash pip install --upgrade cx_Freeze ``` -------------------------------- ### Run bdist_msi with pyproject.toml Source: https://cx-freeze.readthedocs.io/en/stable/bdist_msi.html Use this command to build a Windows MSI installer when your project is configured using pyproject.toml. ```bash cxfreeze bdist_msi ``` -------------------------------- ### Clone cx_Freeze Repository Source: https://cx-freeze.readthedocs.io/en/stable/development/index.html Clone the cx_Freeze repository using git and navigate into the directory. Then, install the project using make. ```bash git clone https://github.com/marcelotduarte/cx_Freeze cd cx_Freeze make install ``` -------------------------------- ### Minimal setup.py for Command Line Options Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html A basic setup.py script is required when using command-line options to override or supplement build settings. ```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"}], ) ``` -------------------------------- ### Create macOS App Bundle with setup.py Source: https://cx-freeze.readthedocs.io/en/stable/bdist_mac.html Use this command with setup.py to create a macOS application bundle. ```python python setup.py bdist_mac ``` -------------------------------- ### Build AppImage using setup.py Source: https://cx-freeze.readthedocs.io/en/stable/bdist_appimage.html Use this command to build an AppImage when your project is configured with setup.py. ```python python setup.py bdist_appimage ``` -------------------------------- ### Display bdist_deb Help via setup.py Source: https://cx-freeze.readthedocs.io/en/stable/bdist_deb.html Use this command to view the available options and usage for the bdist_deb command when managing your project with setup.py. ```python python setup.py bdist_deb --help ``` -------------------------------- ### Invoke cx_Freeze build with setup.py Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html Execute the setup.py script to build cx_Freeze executables. ```bash python setup.py build ``` -------------------------------- ### Configure cx_Freeze with setup.cfg Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html Define project metadata and cx_Freeze build options in a setup.cfg file for simpler configurations. ```ini [metadata] name = guifoo version = 0.1 description = My GUI application! [build_exe] excludes = tkinter,unittest zip_include_packages = encodings,PySide6,shiboken6 ``` -------------------------------- ### Install cx_Freeze using conda Source: https://cx-freeze.readthedocs.io/en/stable/installation.html Install cx_Freeze from the conda-forge channel using the conda package manager. This is a convenient way to manage dependencies in a conda environment. ```bash conda install conda-forge:cx_Freeze ``` -------------------------------- ### Create RPM Package with setup.py Source: https://cx-freeze.readthedocs.io/en/stable/bdist_rpm.html Alternatively, use the bdist_rpm command with setup.py for RPM package creation. ```python python setup.py bdist_rpm ``` -------------------------------- ### cx_Freeze build command help Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html Display help information for the cx_Freeze 'build' command, including available options. ```bash python setup.py build --help ``` -------------------------------- ### Create RPM Package with Packager Option (setup.py) Source: https://cx-freeze.readthedocs.io/en/stable/bdist_rpm.html Specify the packager information when creating an RPM package using setup.py. ```python python setup.py bdist_rpm --packager="John Doe " ``` -------------------------------- ### Build Documentation Locally Source: https://cx-freeze.readthedocs.io/en/stable/development/index.html Build the HTML documentation for cx_Freeze locally using Sphinx. The output will be in the build/doc/html folder. ```bash make html ``` -------------------------------- ### cx_Freeze Python Package Requirements Source: https://cx-freeze.readthedocs.io/en/stable/installation.html These are the Python package requirements for cx_Freeze. They are automatically installed by pip or conda. Note the OS-specific requirements for filelock, patchelf, dmgbuild, lief, and python-msilib. ```text freeze-core >=0.6.1 packaging >=25.0 setuptools >=78.1.1,<83.0 tomli >=2.0.1 # Python 3.10, Python 3.11+ has tomllib filelock >=3.20.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 ``` -------------------------------- ### Ignore Multiprocessing Warning in cx_Freeze (Command Line) Source: https://cx-freeze.readthedocs.io/en/stable/faq.html This command-line example shows how to configure cx_Freeze to ignore the runtime warning message related to `freeze_support()` on Linux and macOS. This is achieved by setting the `constants` option. ```bash cxfreeze --script test.py build_exe --constants='ignore_freeze_support_message=1' ``` -------------------------------- ### Invoke cx_Freeze build_exe with command line options Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html Build cx_Freeze executables using setup.py and specifying build options directly on the command line. ```bash python setup.py build_exe --excludes=tkinter,unittest ``` -------------------------------- ### Enable Multiprocessing Support in cx_Freeze Source: https://cx-freeze.readthedocs.io/en/stable/faq.html This Python snippet demonstrates the necessary setup for multiprocessing support in cx_Freeze applications. Ensure `freeze_support()` is called immediately after the `if __name__ == "__main__":` block to avoid runtime errors on Windows and ensure proper behavior on other systems. ```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 build command options Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html Lists common options for the cx_Freeze 'build' command, such as --build-base and --compiler. ```text Options for 'build' command: --build-base (-b) base directory for build library (...) --compiler (-c) specify the compiler type --help-compiler list available compilers ``` -------------------------------- ### Build Wheel Locally Source: https://cx-freeze.readthedocs.io/en/stable/development/index.html Use the make command to build a wheel package locally for cx_Freeze. ```bash make wheel ``` -------------------------------- ### Invoke cxfreeze build with setup.cfg Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html Command to build executables using cx_Freeze when configuration is primarily in setup.cfg. ```bash cxfreeze --script=guifoo.py --base=gui ``` -------------------------------- ### Build Mac Application Bundle Source: https://cx-freeze.readthedocs.io/en/stable/setup_script.html Use the bdist_mac command to create a Mac application bundle with cx_Freeze. ```bash python setup.py bdist_mac ``` -------------------------------- ### Test Documentation Locally Source: https://cx-freeze.readthedocs.io/en/stable/development/index.html Run the tests for the documentation locally using the make htmltest command. ```bash make htmltest ```