【问题标题】:How to change the directory where cx_Freeze creates the "build" and "dist" folders?如何更改 cx_Freeze 创建“build”和“dist”文件夹的目录?
【发布时间】:2017-04-17 20:50:13
【问题描述】:

python setup.py bdist_msi

如何更改 cx_Freeze 创建“build”和“dist”文件夹的目录? 当我运行这个命令时,它会在我放置 setup.py 和 myapp.py 文件的 python 目录中创建它们,但我想在其他地方创建它们。

【问题讨论】:

    标签: python-3.x cx-freeze


    【解决方案1】:

    有一个选项;当您执行 distutils 设置脚本时,例如python setup.py build,可以指定目录为python setup.py build -b ..\somewhere\else\

    或者,您可以在选项dict的代码中设置它。例如改变

    options = {
        'includes': ['numpy.core._methods'],
        'excludes': ['tkinter']
    }
    setup(name="Application", options=options, executables=[Executable("run.py", base=None)]
    

    在您的设置脚本中

    options = {
        'includes': ['numpy.core._methods'],
        'excludes': ['tkinter'],
        'build_exe': '..\\somewhere\\else\\'
    }
    setup(name="Application", options=options, executables=[Executable("run.py", base=None)]
    

    请注意,这两种解决方案的行为略有不同;第一个会将所有文件放入一个文件夹inside somewhere\else,而第二个会将所有文件简单地放入somewhere\else

    【讨论】:

    • 如果您在build_exe 中指定更多选项,例如packages,您可以这样做:'build_exe': {'build_exe': '..\\somewhere\\else\\', 'packages': packages}
    猜你喜欢
    • 2019-04-06
    • 2017-11-12
    • 2017-01-09
    • 1970-01-01
    • 2016-07-15
    • 2021-03-14
    • 1970-01-01
    • 2021-12-24
    • 1970-01-01
    相关资源
    最近更新 更多