What exactly does python setup.py check
actually do?
setup.py is a python file, the presence of which is an indication that the module/package you are about to install has likely been packaged and distributed with Distutils, which is the standard for distributing Python Modules. This allows you to easily install Python packages.
Use of Setup.py It primarily serves two purposes: It includes choices and metadata about the program, such as the package name, version, author, license, minimal dependencies, entry points, data files, and so on. Secondly, it serves as the command line interface via which packaging commands may be executed.
To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.
If you use setup.py , you have to visit the library's website, figure out where to download it, extract the file, run setup.py ... In contrast, pip will automatically search the Python Package Index (PyPi) to see if the package exists there, and will automatically download, extract, and install the package for you.
First stop, the 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.
So it tests if you have filled in your metadata correctly; see it as a quality control step when creating a Python package.
Next, we can check if the command line offers any help:
$ 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
So we can check for metadata and validate the long description as reStructuredText. The latter requires that you have docutils
installed:
$ python setup.py check -rs
running check
error: The docutils package is needed.
If you do have it installed and there are no problems, the script just runs and exits with no messages:
$ python setup.py check -r
running check
but if required metadata is missing you get warning messages:
$ 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
which becomes an error if you have the -s
flag given:
$ 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.
By default, -m
is enabled, -r
and -s
are disabled.
Also see the command source code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With