In requires_dist
section of a package's json response from pypi, it is given:
requires_dist : [
"bcrypt; extra == 'bcrypt'",
"argon2-cffi (>=16.1.0); extra == 'argon2'"
]
can anyone make it clear the second statement of each dependency, extra == 'bcrypt'
and extra == 'argon2'
?
Python extras are a way for Python projects to declare that extra dependencies are required for additional functionality. For example, requests has several standard dependencies (e.g. urllib3 ). But it also declares an extra named requests[security] , which lists additional dependencies (e.g. cryptography ).
PyPI primarily hosts Python packages in the form of archives called sdists (source distributions) or precompiled "wheels." PyPI as an index allows users to search for packages by keywords or by filters against their metadata, such as free software license or compatibility with POSIX.
Unfortunately, pip makes no attempt to resolve dependency conflicts. For example, if you install two packages, package A may require a different version of a dependency than package B requires. Pip can install from either Source Distributions (sdist) or Wheel (. whl) files.
They are not safe. It would be easy to upload malicious code to PyPI. That's debatable.
The Python Package Index (PyPI) is a repository of software for the Python programming language. PyPI helps you find and install software developed and shared by the Python community. Learn about installing packages. Package authors use PyPI to distribute their software. Learn how to package your Python code for PyPI.
The Python Package Index (PyPI) is a repository of software for the Python programming language. PyPI helps you find and install software developed and shared by the Python community. Learn about installing packages. Package authors use PyPI to distribute their software.
Your Python dependency can't be found the Python Package Index, and the library does not have any external dependencies, such as dist-packages. You want to use plugin-specific functionality, such as modifying the Airflow web interface. Your Python dependency can be found on the Python Package Index and has no external dependencies.
371,853 users. The Python Package Index (PyPI) is a repository of software for the Python programming language. PyPI helps you find and install software developed and shared by the Python community.
Extras are dependencies you can install in addition to the regular dependencies, if you ask for them explicitly. See them as optional features.
You can install these with the name after the ==
, with the name of the package. For example, if you install somepackage
and want to add the bcrypt
optional feature, use:
pip install somepackage[bcrypt]
or
pip install somepackage[argon2]
or, to include both optional extras, separate the names with commas:
pip install somepackage[bcrypt,argon2]
although using somepackage[...]
multiple times also works as pip
is smart enough to know that the main package is already installed.
pip
(or whatever other package install tool) maps names listed in <packagename>[<extras_name>(,...)]
to those entries in the requires_dict
that use the <dependency_spec>; extra == '<extras_name>'
format, adding on the dependency_spec
s to the list of things to install.
See Installing Setuptools "Extras" in the Installing Packages section of the Python Packaging User Guide.
It is up to the installed package itself to detect if all the dependencies for optional extra features are installed. A common pattern is to use try...except ImportError:
guards to test for such extra dependencies being available.
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