`python setup.py check` 到底做了什么?
What does `python setup.py check` actually do?
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
禁用。
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
禁用。