如何更改 cx_Freeze 创建“build”和“dist”文件夹的目录?

dea*_*ine 6 cx-freeze python-3.x

python setup.py bdist_msi

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

Gal*_*hup 6

有一个选择;当您执行 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)]
Run Code Online (Sandbox Code Playgroud)

在您的设置脚本中

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

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