使用 cx_Freeze 创建 MSI 时可用的 bdist_msi 选项
Available bdist_msi options when creating MSI with cx_Freeze
在使用 cx_Freeze
安装脚本创建 MSI 时,我无法找到有关 bdist_msi
命令可用选项的文档。
我在与此主题相关的其他 SO 帖子中看到了以下选项:
bdist_msi_options = {'data': '','add_to_path':'','initial_target_dir':'','upgrade_code':'',}
setup(
options = {
"bdist_msi": bdist_msi_options,
},
executables = [
Executable(
"test.py",
)
]
)
windows installer docs 提到了一些分散在各处的选项。
cx_Freeze docs documents two options (including upgrade_code
) mentioning that they are available along with the standard set of options。
我在哪里可以找到提到的标准选项集列表?
您可以查看 cx_Freeze/windist.py 中的源代码以查看预期选项的列表:
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
class来源于标准模块distutils
的谐音class,它本身期望"standard set of options" 你在问题中提到,你可以在 path_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"),
]
您必须查看源代码中这些选项的实现,以了解如何使用它们。您会注意到其中一些未实现或仅部分实现。
data
选项可用于让安装程序在桌面或程序菜单中添加快捷方式,如 Use cx-freeze to create an msi that adds a shortcut to the desktop and here 中所述。
在使用 cx_Freeze
安装脚本创建 MSI 时,我无法找到有关 bdist_msi
命令可用选项的文档。
我在与此主题相关的其他 SO 帖子中看到了以下选项:
bdist_msi_options = {'data': '','add_to_path':'','initial_target_dir':'','upgrade_code':'',}
setup(
options = {
"bdist_msi": bdist_msi_options,
},
executables = [
Executable(
"test.py",
)
]
)
windows installer docs 提到了一些分散在各处的选项。
cx_Freeze docs documents two options (including upgrade_code
) mentioning that they are available along with the standard set of options。
我在哪里可以找到提到的标准选项集列表?
您可以查看 cx_Freeze/windist.py 中的源代码以查看预期选项的列表:
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
class来源于标准模块distutils
的谐音class,它本身期望"standard set of options" 你在问题中提到,你可以在path_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"),
]
您必须查看源代码中这些选项的实现,以了解如何使用它们。您会注意到其中一些未实现或仅部分实现。
data
选项可用于让安装程序在桌面或程序菜单中添加快捷方式,如 Use cx-freeze to create an msi that adds a shortcut to the desktop and here 中所述。