Invalid command 'bdist_msi' when trying to create MSI installer with 'cx_Freeze'

Question:

I am trying to create MSI installer for Windows with cx_Freeze package. Anyway, when running command python setup.py bdist_msi I get an error that it is invalid. Is there any options I am missing or maybe I cannot use it on Linux (I am using Debian 11)?

import sys
from pathlib import Path
from cx_Freeze import setup, Executable

company_name = '...'
product_version = '...'
product_name = '...'
product_description = '...'

base = None
build_exe_options = {}
bdist_msi_options = {
    'initial_target_dir': r'[ProgramFilesFolder]%s%s' % (company_name, product_name),
}

if sys.platform == 'win32':
    base = 'Win32GUI'

setup(
    name=product_name,
    version=product_version,
    description=product_description,
    options={
        'build_exe': build_exe_options,
        'bdist_msi': bdist_msi_options
    },
    executables=[Executable(
        'app.py',
        base=base,
        shortcut_name=product_name,
        shortcut_dir='DesktopFolder',
        icon=str(Path(__file__).parent / 'icon.jpg')
    )],
)
Asked By: Karolis

||

Answers:

According to this section of cx_Freeze documentation cross compilation is indeed not possible. At least in the usual way.

cx_Freeze works on Windows, Mac and Linux, but on each platform it
only makes an executable that runs on that platform. So if you want to
freeze your programs for Windows, freeze it on Windows; if you want to
run it on Macs, freeze it on a Mac.

At a pinch, you can try to make a Windows executable using Wine. Our
experience is that you need to copy some files in manually after
cx_Freeze has run to make the executable work. We don’t recommend this
option.

Answered By: Karolis
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.