加入收藏 | 设为首页 | 会员中心 | 我要投稿 商洛站长网 (https://www.0914zz.com/)- AI应用、CDN、边缘计算、云计算、物联网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 有没有办法指定py2exe的build目录

发布时间:2020-09-06 05:04:23 所属栏目:Python 来源:互联网
导读:我可以使用命令行设置py2exe的最终dist目录: python setup.py py2exe -d my/dist/dir 但我似乎无法将该文件设置为临时构建目录.我简要地看了一下这个来源,但是除非我错过了一些事情,似乎没有任何办法. 您可以在命令行中设置的任何选项可以通过 setup.cfg文件

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

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

但我似乎无法将该文件设置为临时构建目录.我简要地看了一下这个来源,但是除非我错过了一些事情,似乎没有任何办法.

解决方法

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

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

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文件旁边:

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

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

[build]
build_base=my/build/dir

(编辑:商洛站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读