I am newbie in python.
Could anybody answer what does __requires__
means in the following code?
Why would they put __requires__ = 'flower==0.4.0'
in the beginning of the file?
#!/srv/virtualenvs/zeusenv/bin/python
__requires__ = 'flower==0.4.0'
import sys
from pkg_resources import load_entry_point
sys.exit(
load_entry_point('flower==0.4.0', 'console_scripts', 'flower')()
)
The __requires__
line is part of a generated console script. It has no meaning to Python itself, only the setuptools
library uses this information.
Console scripts are python scripts defined in a python package metadata, and setuptools
installs wrapper script files to let you run them as command line scripts. The flower
file installed in your virtualenv is such a script, defined by the flower
package setup.py
file.
The pkg_resources
module imported in the wrapper script inspects the value of __requires__
in the main script to make sure the correct version of the library is available and loaded before the load_entry_point
function (or any other pkg_resources
function) is run. It'll not install the version specified, it is assumed that that version is already installed on your system. It's purpose is to avoid loading incorrect, incompatible resources when the script runs and loads dependencies.
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