ir.requirements¶
Dependency check for ir: name what is missing and how to install it.
ir imports its dependencies deep inside ir/base.py and friends; on an
interpreter that lacks them (a fresh server’s system python3) that surfaces
as a bare ModuleNotFoundError: No module named 'numpy' that says nothing
about ir or the fix. check_requirements() runs first, from
ir/__init__.py, using only the standard library, and raises
MissingRequirements (a ModuleNotFoundError) listing every
missing import, the interpreter it was looked up in, and the install commands.
It also checks the version bounds ir declares for them (cw>=0.1.1,<0.2),
read from ir’s installed metadata, and raises UnsatisfiedRequirements
for an installed dependency outside them, instead of an opaque error later.
Module Attributes
the distribution whose declared requirements hold the version bounds |
|
import name -> distribution name, for everything |
Functions
|
Raise |
|
|
|
Distribution names in required whose import name cannot be found. |
|
The actionable message for missing distributions. |
|
The actionable message for unsatisfied |
|
|
|
Whether installed meets specifier ( |
Exceptions
|
|
A dependency is installed in a version outside the bounds |
- ir.requirements.DIST = 'ir'¶
the distribution whose declared requirements hold the version bounds
- exception ir.requirements.MissingRequirements[source]¶
Bases:
ModuleNotFoundErrorir’s dependencies are missing from the running interpreter.
- ir.requirements.REQUIRED: Mapping[str, str] = {'cw': 'cw', 'dol': 'dol', 'ef': 'ef', 'numpy': 'numpy', 'vd': 'vd'}¶
import name -> distribution name, for everything
import irneeds.
- exception ir.requirements.UnsatisfiedRequirements[source]¶
Bases:
ImportErrorA dependency is installed in a version outside the bounds
irdeclares.
- ir.requirements.check_requirements(required={'cw': 'cw', 'dol': 'dol', 'ef': 'ef', 'numpy': 'numpy', 'vd': 'vd'}, *, bounds=None)[source]¶
Raise
MissingRequirementsunless every dependency is importable, thenUnsatisfiedRequirementsunless each is within the boundsirdeclares (bounds:{name: specifier}, default read fromir’s metadata).- Return type:
- ir.requirements.declared_bounds(dist='ir')[source]¶
{normalized dependency name: specifier}that dist’s installed metadata declares for this environment (extras excluded; the specifiers of repeated names are joined); empty when dist is not installed or has none.
- ir.requirements.missing_requirements(required={'cw': 'cw', 'dol': 'dol', 'ef': 'ef', 'numpy': 'numpy', 'vd': 'vd'})[source]¶
Distribution names in required whose import name cannot be found.
- ir.requirements.requirements_message(missing)[source]¶
The actionable message for missing distributions.
- Return type:
- ir.requirements.unsatisfied_message(unsatisfied)[source]¶
The actionable message for unsatisfied
(dist, installed, specifier).- Return type:
- ir.requirements.unsatisfied_requirements(required={'cw': 'cw', 'dol': 'dol', 'ef': 'ef', 'numpy': 'numpy', 'vd': 'vd'}, *, bounds=None)[source]¶
(distribution, installed version, specifier)of each dependency in required that is installed outside its declared bounds.
- ir.requirements.version_satisfies(installed, specifier)[source]¶
Whether installed meets specifier (
'>=0.1.1,<0.2').Uses
packagingwhen it is installed. Without it, plain releases (1.2.3) are compared with the standard library, and anything it cannot judge (a pre-release,dev,postor local version, an unreadable specifier) is taken to hold: this check must never blockimport iron a doubt.- Return type:
>>> version_satisfies("0.1.6", ">=0.1.1,<0.2"), version_satisfies("0.2.0", "<0.2") (True, False) >>> version_satisfies("1.4", "~=1.2"), version_satisfies("2.0", "~=1.2") (True, False)