[cx_Freeze 问]:如何从非标准构建目录构建 MSI?

[cx_Freeze Q]: How to build MSI from non-standard build directory?

我正在尝试让我的构建过程从非标准构建目录构建。 项目存储在 c:\users\user\onedrive\dev\project 中。这些是我在 setup.py:

中的构建选项
build_options = {
    'packages': ["pyfiglet"],
    'excludes': ["scipy", "PIL", "tkinter", "test"],
    # use this temp dir, so onedrive does not go crazy and lock files!
    'build_exe': f"c:/Temp/{DESCRIPTION.replace(' ','_')}-build", 
}

但现在我很难定义 bdist_msi_options 块:

bdist_msi_options = {
    'upgrade_code': '{1}',
    'add_to_path': False,
    'install_icon': 'icon.ico',
    'skip_build': True, # so I can sign the exe before MSI'ing
    'initial_target_dir': r'[ProgramFilesFolder]\{0}\{1}'.format(
        COMPANY, DESCRIPTION),
}

我没有看到任何选项来定义 MSI 构建将从 c:\temp\ 中获取预构建的 .exe。

最后是 main():

executables = [
    Executable(
        SCRIPT_FILE, # something.py
        base='Console',
        target_name=OUT_FILENAME,
        copyright=COPYRIGHT,
        icon="icon.ico",
        shortcut_name=DESCRIPTION,
        shortcut_dir="DesktopFolder",
    )
]

setup(name='HeightStorage',
      version=cfg.version,
      description=LONG_DESCRIPTION,
      options={
          'build_exe': build_options,
          'bdist_msi': bdist_msi_options,
      },
      executables=executables)

如有任何提示,我们将不胜感激。

尝试在 build 选项中设置构建目录,并使用 bdist_msi 选项的 bdist_dir 选项:

build_dir = f"c:/Temp/{DESCRIPTION.replace(' ','_')}-build"  # or whatever you like
bdist_dir = build_dir  # define here a new directory if you want to keep build_dir
build_options = {
    ...
    'build_exe': build_dir,
}
bdist_msi_options = {
    ...
    'bdist_dir': bdist_dir,    
}
setup(
    ...
    options={
        'build': {'build_exe': build_dir},
        'build_exe': build_options,
        'bdist_msi': bdist_msi_options,
    },
    ...
}