使用 cx_Freeze 创建 MSI 时可用的 bdist_msi 选项 [英] Available bdist_msi options when creating MSI with cx_Freeze
问题描述
在使用 cx_Freeze
安装脚本创建 MSI 时,我无法找到有关 bdist_msi
命令的可用选项的文档.
I am having trouble finding documentation on what are the available options for the bdist_msi
command when creating an MSI with a cx_Freeze
setup script.
我在与此主题相关的其他 SO 帖子中看到了以下选项:
I have seen the following options being used in other SO posts related to this topic:
bdist_msi_options = {'data': '','add_to_path':'','initial_target_dir':'','upgrade_code':'',}
setup(
options = {
"bdist_msi": bdist_msi_options,
},
executables = [
Executable(
"test.py",
)
]
)
windows 安装程序文档 提到一些选项分散在各处.cx_Freeze docs 记录了两个选项(包括 upgrade_code代码>) 提到它们与 标准选项集.在哪里可以找到上述标准选项集列表?
The windows installer docs mentions some of the options scattered throughout.
The cx_Freeze docs documents two options (including upgrade_code
) mentioning that they are available along with the standard set of options.
Where can I find this list of standard set of options as mentioned?
推荐答案
你可以在cx_Freeze/windist.py 查看预期选项的列表:
You can have a look at the source code in cx_Freeze/windist.py to see a list of the expected options:
class bdist_msi(distutils.command.bdist_msi.bdist_msi):
user_options = distutils.command.bdist_msi.bdist_msi.user_options + [
('add-to-path=', None, 'add target dir to PATH environment variable'),
('upgrade-code=', None, 'upgrade code to use'),
('initial-target-dir=', None, 'initial target directory'),
('target-name=', None, 'name of the file to create'),
('directories=', None, 'list of 3-tuples of directories to create'),
('environment-variables=', None, 'list of environment variables'),
('data=', None, 'dictionary of data indexed by table name'),
('product-code=', None, 'product code to use'),
('install-icon=', None, 'icon path to add/remove programs ')
]
如你所见:
- cx_Freeze 添加了比文档中提到的更多的选项
- cx_Freeze 的
bdist_msi
类派生自标准模块distutils
的同名类,它本身需要您在问题中提到的标准选项集",您可以在path_to_python\Lib\distutils\command\bdist_msi.py
中读取:
- cx_Freeze adds more options than mentioned in the documentation
- cx_Freeze's
bdist_msi
class is derived from the homonym class of the standard moduledistutils
, which itself expects the "standard set of options" you mention in your question, which you can read inpath_to_python\Lib\distutils\command\bdist_msi.py
:
class bdist_msi(Command):
description = "create a Microsoft Installer (.msi) binary distribution"
user_options = [('bdist-dir=', None,
"temporary directory for creating the distribution"),
('plat-name=', 'p',
"platform name to embed in generated filenames "
"(default: %s)" % get_platform()),
('keep-temp', 'k',
"keep the pseudo-installation tree around after " +
"creating the distribution archive"),
('target-version=', None,
"require a specific python version" +
" on the target system"),
('no-target-compile', 'c',
"do not compile .py to .pyc on the target system"),
('no-target-optimize', 'o',
"do not compile .py to .pyo (optimized)"
"on the target system"),
('dist-dir=', 'd',
"directory to put final built distributions in"),
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
('install-script=', None,
"basename of installation script to be run after"
"installation or before deinstallation"),
('pre-install-script=', None,
"Fully qualified filename of a script to be run before "
"any files are installed. This script need not be in the "
"distribution"),
]
您必须查看源代码中这些选项的实现,以了解如何使用它们.您会注意到其中一些未实施或仅部分实施.
You'll have to look at the implementation of these options in the source code to understand how they can be used. You'll notice that some of them are not implemented or only partially.
data
选项可用于让安装程序在桌面或程序菜单中添加快捷方式,如 使用 cx-freeze 创建一个向桌面添加快捷方式的 msi 和 此处.
The data
option can be used for example to let the installer add a shortcut on the desktop or in the program menu as described in Use cx-freeze to create an msi that adds a shortcut to the desktop and here.
这篇关于使用 cx_Freeze 创建 MSI 时可用的 bdist_msi 选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!