添加自定义操作以使用 cx_Freeze 将文件重命名为 msi 安装程序
Add custom action to rename file to msi installer with cx_Freeze
cx_Freeze 中存在多处理包的错误,它将 "pool.pyc" 复制为 "Pool.pyc",这会导致运行时错误:"no module named multiprocessing.pool".
为了缓解这种情况,我想在我的安装程序中包含一个 VBScript 以重命名该文件 post-installation 以使我的构建过程保持自动。
我试过这个:
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。
可以通过将 'multiprocessing.Pool' 添加到 setup.py 中的排除项来避免整个问题。
cx_Freeze 中存在多处理包的错误,它将 "pool.pyc" 复制为 "Pool.pyc",这会导致运行时错误:"no module named multiprocessing.pool".
为了缓解这种情况,我想在我的安装程序中包含一个 VBScript 以重命名该文件 post-installation 以使我的构建过程保持自动。
我试过这个:
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。
可以通过将 'multiprocessing.Pool' 添加到 setup.py 中的排除项来避免整个问题。