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

DIST

the distribution whose declared requirements hold the version bounds

REQUIRED

import name -> distribution name, for everything import ir needs.

Functions

check_requirements([required, bounds])

Raise MissingRequirements unless every dependency is importable, then UnsatisfiedRequirements unless each is within the bounds ir declares (bounds: {name: specifier}, default read from ir's metadata).

declared_bounds([dist])

{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.

missing_requirements([required])

Distribution names in required whose import name cannot be found.

requirements_message(missing)

The actionable message for missing distributions.

unsatisfied_message(unsatisfied)

The actionable message for unsatisfied (dist, installed, specifier).

unsatisfied_requirements([required, bounds])

(distribution, installed version, specifier) of each dependency in required that is installed outside its declared bounds.

version_satisfies(installed, specifier)

Whether installed meets specifier ('>=0.1.1,<0.2').

Exceptions

MissingRequirements

ir's dependencies are missing from the running interpreter.

UnsatisfiedRequirements

A dependency is installed in a version outside the bounds ir declares.

ir.requirements.DIST = 'ir'

the distribution whose declared requirements hold the version bounds

exception ir.requirements.MissingRequirements[source]

Bases: ModuleNotFoundError

ir’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 ir needs.

exception ir.requirements.UnsatisfiedRequirements[source]

Bases: ImportError

A dependency is installed in a version outside the bounds ir declares.

ir.requirements.check_requirements(required={'cw': 'cw', 'dol': 'dol', 'ef': 'ef', 'numpy': 'numpy', 'vd': 'vd'}, *, bounds=None)[source]

Raise MissingRequirements unless every dependency is importable, then UnsatisfiedRequirements unless each is within the bounds ir declares (bounds: {name: specifier}, default read from ir’s metadata).

Return type:

None

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.

Return type:

dict[str, str]

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.

Return type:

list[str]

ir.requirements.requirements_message(missing)[source]

The actionable message for missing distributions.

Return type:

str

ir.requirements.unsatisfied_message(unsatisfied)[source]

The actionable message for unsatisfied (dist, installed, specifier).

Return type:

str

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.

Return type:

list[tuple[str, str, str]]

ir.requirements.version_satisfies(installed, specifier)[source]

Whether installed meets specifier ('>=0.1.1,<0.2').

Uses packaging when 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, post or local version, an unreadable specifier) is taken to hold: this check must never block import ir on a doubt.

Return type:

bool

>>> 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)