locan.dependencies

Module to deal with required and optional dependencies.

Optional dependencies are defined in pyproject.toml.

In any module that requires an optional dependency the import should be conditioned:

if HAS_DEPENDENCY[“package”]: import package

Any function that makes use of the optional dependency should be decorated with

@needs_package(“package”)

Keys of HAS_DEPENDENCY are import names. Distribution names from pyproject.toml are normalized (PEP 503) and mapped through IMPORT_NAMES; a distribution without an entry is looked up under its name with - replaced by _. Looking up a name that is not a dependency of locan yields False (with a warning logged once) instead of raising KeyError.

CONSTANTS

INSTALL_REQUIRES

List of required dependencies (PyPi package names)

EXTRAS_REQUIRE

List of optional dependencies (PyPi package names)

IMPORT_NAMES

A dictionary mapping normalized PyPi package names (PEP 503) to import names if they differ in more than - versus _.

HAS_DEPENDENCY

A dictionary indicating if dependency (import name) is available.

Classes

QtBindings(value)

Python bindings to interact with Qt.

Functions

needs_package(package[, import_names, ...])

Function that returns a decorator to check for optional dependency.

needs_package_version(package, major)

Function that returns a decorator to check for package.version starting with major.