有没有办法为py2exe指定构建目录 [英] Is there a way to specify the build directory for py2exe

查看:46
本文介绍了有没有办法为py2exe指定构建目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用命令行设置py2exe的最终dist目录:

I can set the final dist directory of py2exe using the command line:

python setup.py py2exe -d "my/dist/dir"

但我似乎无法将文件设置为用于临时 build 目录.我已经简要地查看了来源,但除非我遗漏了一些东西,否则似乎没有任何方法可以做到这一点.

but I can't seem to set the file to use for the interim build directory. I've taken a brief look at the source, but unless I am missing something there doesn't appear to be any way to do it.

推荐答案

您可以在命令行上设置的任何选项都可以通过 setup.cfg 文件或在您的 setup.py 文件中.

Any option that you can set on the command line you can set either through a setup.cfg file or in your setup.py file.

-d--dist-dir 的快捷方式,您可以将其添加到字典中的 py2xe dict 传递给 setup 的 options 关键字参数作为 'dist_dir':

-d is a shortcut for --dist-dir which you can add to the py2xe dict in the dictionary passed to the options keyword param of setup as 'dist_dir':

from distutils.core import setup
import py2exe

# equivalent command line with options is:
# python setup.py py2exe --compressed --bundle-files=2 --dist-dir="my/dist/dir" --dll-excludes="w9xpopen.exe"
options = {'py2exe': {
           'compressed':1,  
           'bundle_files': 2, 
           'dist_dir': "my/dist/dir"
           'dll_excludes': ['w9xpopen.exe']
           }}
setup(console=['myscript.py'], options=options)

您还可以将 setup.cfg 放在 setup.py 文件旁边:

You could also put setup.cfg next to your setup.py file:

[py2exe]
compressed=1
bundle_files=2 
dist_dir=my/dist/dir
dll_excludes=w9xpopen.exe

构建目录 (--build-base) 是构建命令的一个选项,因此您可以将其添加到配置文件之一(或 setup.py)中:

The build directory (--build-base) is an option of the build command so you can add it to one of the config files (or the setup.py) as:

[build]
build_base=my/build/dir

这篇关于有没有办法为py2exe指定构建目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆