简体   繁体   English

在使用setuptools构建软件包时,如何避免无效警告?

[英]How can I avoid getting useless warnings while building my package using setuptools?

It seems that setuptools triggers various warnings that are really of zero value and I want to get rid of them as they are spamming the continuous integration progress, making just harder to spot real warnings. 似乎setuptools触发了真正零价值的各种警告,我想摆脱它们,因为它们正在发送持续集成进程的垃圾邮件,使得更难发现真正的警告。

Here are those that I do want to get rid of: 这些是我想要摆脱的:

python setup.py -q bdist_wheel
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.pyc' found under directory '*'
warning: no previously-included files matching '*.pyo' found under directory '*'
warning: no previously-included files matching '*.orig' found under directory '*'
warning: no files found matching '*.md' under directory 'releases'
warning: no files found matching '*.rst' under directory 'releases'
warning: no files found matching '*.json' under directory 'releases'
warning: no previously-included files matching '*' found under directory 'examples/node_modules'
no previously-included directories found matching 'examples/node_modules'
warning: build_py: byte-compiling is disabled, skipping.

warning: install_lib: byte-compiling is disabled, skipping.

It seems that all these are caused by the MANIFEST.in file but the conditions there do have a reason for being there, and that's clearly not the one of generating warnings when exclude patters do find no files to match?! 似乎所有这些都是由MANIFEST.in文件引起的,但那里的条件确实存在,并且当排除模式确实找不到匹配的文件时,这显然不是产生警告的那个?!

目前我发现这个问题只有一个解决方法: export PYTHONDONTWRITEBYTECODE=这样可以避免在构建期间收到这些恼人的警告。

I use a makefile to build my project and I had to add the following line to the top: 我使用makefile来构建我的项目,我不得不将以下行添加到顶部:

unexport PYTHONDONTWRITEBYTECODE

In shell, you must unset PYTHONDONTWRITEBYTECODE , too. 在shell中,你也必须unset PYTHONDONTWRITEBYTECODE Setting it from 1 to 0 won't work. 将其从1设置为0将不起作用。 I am using zsh though, so maybe the answer above will work elsewhere. 我虽然使用zsh ,所以上面的答案可能会在其他地方使用。

Also, you can pass -B to python directly to disable byte-compiling, but the environment variable takes precedence over it (at least in the Python 3 version I am using - 3.6.8 ). 此外,您可以直接将-B传递给python以禁用字节编译,但环境变量优先于它(至少在我使用的Python 3版本中是3.6.8 )。 I do not see an option to force turning on byte-compiling, though. 但是,我没有看到强制打开字节编译的选项。

Lastly, you can pass --help to most setup.py commands to get info on flags they support. 最后,您可以将--help传递给大多数setup.py命令,以获取有关它们支持的标志的信息。 For example, build_py and install_lib support --compile/-c , --no-compile flags which should help you with fine-grain control, although the environment variable again takes precedence from my experience. 例如, build_pyinstall_lib支持--compile/-c--no-compile --compile/-c --no-compile标志,它们可以帮助您进行细粒度控制,尽管环境变量再次优先于我的经验。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让pip / setuptools了解我的包在./src中? - how can I make pip/setuptools understand that my package is in ./src? 如何在我的 package 中获取 setup.py (setuptools) 中定义的版本? - How can I get the version defined in setup.py (setuptools) in my package? 使用setuptools构建鸡蛋时,如何以编程方式检测错误? - How can I detect errors programatically when building an egg with setuptools? 使用 setuptools 构建 sphinx 文档时如何将警告转化为错误? - How to turn warnings into errors when building sphinx documentation with setuptools? 如何让setuptools安装一个不在PyPI上的软件包? - How can I make setuptools install a package that's not on PyPI? python setuptools:如何用cython子模块安装包? - python setuptools: how can I install package with cython submodules? 使用 setuptools 构建包时是否应该包含测试和 .pyc 文件? - Should I include tests and .pyc files when building package with setuptools? 如何避免使用我的python包构建C库? - How to avoid building C library with my python package? 使用setuptools(pip)时如何打印警告和错误 - How to print warnings and errors when using setuptools (pip) 如何使用 setuptools *安装*额外的 package 数据? - How to *install* extra package data using setuptools?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM