gpt4 book ai didi

python - `python setup.py check` 实际上是做什么的?

转载 作者:太空狗 更新时间:2023-10-29 18:02:18 26 4
gpt4 key购买 nike

python setup.py check 到底做了什么?

最佳答案

第一站,distutils package documentation :

The check command performs some tests on the meta-data of a package. For example, it verifies that all required meta-data are provided as the arguments passed to the setup() function.

因此它会测试您是否正确填写了元数据;在创建 Python 包时将其视为质量控制步骤。

接下来,我们可以检查命令行是否提供任何帮助:

$ python setup.py --help-commands | grep check
check perform some checks on the package
$ python setup.py check --help
# ...
Options for 'check' command:
--metadata (-m) Verify meta-data
--restructuredtext (-r) Checks if long string meta-data syntax are
reStructuredText-compliant
--strict (-s) Will exit with an error if a check fails

因此我们可以检查元数据并将长描述验证为 reStructuredText。后者要求您安装了 docutils:

$ python setup.py check -rs
running check
error: The docutils package is needed.

如果您确实安装了它并且没有任何问题,则脚本会运行并退出,不会出现任何消​​息:

$ python setup.py check -r
running check

但如果缺少所需的元数据,您会收到警告消息:

$ python setup.py check -r
running check
warning: check: missing required meta-data: url

warning: check: missing meta-data: either (author and author_email) or (maintainer and maintainer_email) must be supplied

如果您给定了 -s 标志,这将成为一个错误:

$ python setup.py check -rs
running check
warning: check: missing required meta-data: url

warning: check: missing meta-data: either (author and author_email) or (maintainer and maintainer_email) must be supplied

error: Please correct your package.

默认情况下,-m 被启用,-r-s 被禁用。

另见 command source code .

关于python - `python setup.py check` 实际上是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30328259/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com