【问题标题】:Add custom action to rename file to msi installer with cx_Freeze添加自定义操作以使用 cx_Freeze 将文件重命名为 msi 安装程序
【发布时间】:2020-02-11 13:51:45
【问题描述】:

在 cx_Freeze 中存在多处理包的错误,它将“pool.pyc”复制为“Pool.pyc”,导致运行时错误:“没有名为 multiprocessing.pool 的模块”。

为了缓解这种情况,我想在我的安装程序中包含一个 VBScript,以便在安装后重命名该文件,以保持我的构建过程自动化。

我试过了:

msi_custom_action = [
    (
        'rename_pool',              # identifier
        22,                         # custom action type, https://docs.microsoft.com/en-us/windows/win32/msi/custom-action-type-22
        'installer_helper.vb',      # source
        None,                       # target
        None,                       # extendedtype
    )
]

msi_sequence = [
    (
        'rename_pool',              # name of action
        None,                       # condition
        6601,                       # sequence (6600< after files are copied)
    )
]

msi_data = {
    "Shortcut": msi_shortcut_table,
    "CustomAction": msi_custom_action,
    "InstallExecuteSequence": msi_sequence,
}

options = {
    'build_exe': {
        'optimize': 1,
        'includes': ['atexit'],
        'include_files': [('./qt/', 'qt/'), './TableManipulationsDialogOperations.json', './single.rc', './matplotlibrc', './installer_helper.vb'],
        'packages': packages,
        'excludes': ['scipy.spatial.cKDTree', 'tkinter', 'Tkinter'], # cKDTree excluded bc of a bug, ckdtree still available
    },
    'bdist_msi': { # first three options remove need of admin rights for installer
        'initial_target_dir': r'[LocalAppDataFolder]\spleng',
        'add_to_path': False,
        'all_users': False,
        'data': msi_data,
        'target_name': 'Spleng_Installer',
    }
}

# execute build
setup(
    name="SplENG",
    options=options,
    version='0.1.1',
    description='SplitExplorerNextGeneration',
    executables=executables
)

但在创建安装程序时,我收到此错误:

creating dist
Traceback (most recent call last):
  File "build.py", line 146, in <module>
    executables=executables
  File "C:\Users\-\Documents\git_repos\spleng\.venv\lib\site-packages\cx_Freeze\dist.py", line 340, in setup
    distutils.core.setup(**attrs)
  File "C:\Users\-\AppData\Local\Programs\Python\Python37\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\-\AppData\Local\Programs\Python\Python37\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Users\-\AppData\Local\Programs\Python\Python37\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\-\Documents\git_repos\spleng\.venv\lib\site-packages\cx_Freeze\windist.py", line 420, in run
    self.add_config(fullname)
  File "C:\Users\-\Documents\git_repos\spleng\.venv\lib\site-packages\cx_Freeze\windist.py", line 74, in add_config
    msilib.add_data(self.db, tableName, data)
  File "C:\Users\-\AppData\Local\Programs\Python\Python37\lib\msilib\__init__.py", line 104, in add_data
    assert len(value) == count, value
AssertionError: ('rename_pool', 22, 'installer_helper.vb', None, None)

有人能告诉我如何正确添加脚本吗,我真的无法对文档做出正面或反面。 我使用的是 cx_freeze 6.1 版。

【问题讨论】:

    标签: python windows-installer python-multiprocessing cx-freeze


    【解决方案1】:

    可以通过将“multiprocessing.Pool”添加到 setup.py 中的排除项来避免整个问题。

    https://github.com/anthony-tuininga/cx_Freeze/issues/353

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多