添加 cx_Freeze msi 到路径

Adding cx_Freeze msi to path

我有一个 msi,我希望它在安装时将 exe 添加到路径中。

我找到了这个:

add_to_path add the target directory to the PATH environment variable; the default value is True if there are any console based executables and False otherwise

来自 the documentation.

我已经尝试将此添加到设置脚本中:

setup(  name = "cabbage",
        version = "0.1",
        description = "just a vegetable",
        add_to_path = True, # <-- Just here
        options = {"build_exe": build_exe_options},
        executables = [Executable("spam.py", base=base)])

这个returns:

UserWarning: Unknown distribution option: 'add_to_path'

我也从命令行尝试过:

C:\Users\Simon\Desktop>python setup.py bdist_msi add_to_path=True
invalid command name 'add_to_path=True'

如何添加这个选项?

在您的 setup.py 脚本中添加以下行以使其工作。

  if 'bdist_msi' in sys.argv:

        sys.argv += ['--add-to-path', 'True']

您的代码应如下所示:

 if 'bdist_msi' in sys.argv:

        sys.argv += ['--add-to-path', 'True']


 setup(  name = "cabbage",
    version = "0.1",
    description = "just a vegetable",
    add_to_path = True, # <-- Just here
    options = {"build_exe": build_exe_options},
    executables = [Executable("spam.py", base=base)])

运行 命令:python setup.py bdist_msi