将cx_Freeze msi添加到路径

问题描述 投票:0回答:1

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

我发现了这个:

add_to_path将目标目录添加到PATH环境变量中;如果存在任何基于控制台的可执行文件,则默认值为True,否则为False

来自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)])

返回:

UserWarning:未知的分发选项:'add_to_path'

我也尝试从命令行:

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

如何添加此选项?

python python-3.x path cx-freeze
1个回答
1
投票

在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

© www.soinside.com 2019 - 2024. All rights reserved.