polymerist.genutils.importutils.dependencies ============================================ .. py:module:: polymerist.genutils.importutils.dependencies .. autoapi-nested-parse:: Utilities for checking and enforcing module dependencies within code Attributes ---------- .. autoapisummary:: polymerist.genutils.importutils.dependencies.Params polymerist.genutils.importutils.dependencies.ReturnType polymerist.genutils.importutils.dependencies.TCall Exceptions ---------- .. autoapisummary:: polymerist.genutils.importutils.dependencies.MissingPrerequisitePackage Functions --------- .. autoapisummary:: polymerist.genutils.importutils.dependencies.module_installed polymerist.genutils.importutils.dependencies.modules_installed polymerist.genutils.importutils.dependencies.requires_modules Module Contents --------------- .. py:data:: Params .. py:data:: ReturnType .. py:data:: TCall .. py:exception:: MissingPrerequisitePackage(importing_package_name: str, use_case: str, install_link: str, dependency_name: str, dependency_name_formal: Optional[str] = None) Bases: :py:obj:`Exception` Raised when a package dependency cannot be found and the user should be alerted with install instructions .. py:function:: module_installed(module_name: str) -> bool Check whether a module of the given name is present on the system :Parameters: **module_name** (*str*) -- The name of the module, as it would occur in an import statement Do not support direct passing of module objects to avoid circularity (i.e. no reason to check if a module is present if one has already imported it elsewhere) :returns: **module_found** -- Whether or not the module was found to be installed in the current working environment :rtype: bool .. py:function:: modules_installed(*module_names: list[str]) -> bool Check whether one or more modules are all present Will only return true if ALL specified modules are found :Parameters: **module_names** (**str*) -- Any number of module names, passed as a comma-separated sequence of strings :returns: **all_modules_found** -- Whether or not all modules were found to be installed in the current working environment :rtype: bool .. py:function:: requires_modules(*required_module_names: list[str], missing_module_error: Union[Exception, type[Exception]] = ImportError) -> Callable[[TCall[Ellipsis, ReturnType]], TCall[Ellipsis, ReturnType]] Decorator which enforces optional module dependencies prior to function execution :Parameters: * **module_names** (**str*) -- Any number of module names, passed as a comma-separated sequence of strings * **missing_module_error** (*type[Exception], default ImportError*) -- The type of Exception to raise if a module is not found installed Defaults to ImportError :raises ImportError : Exception: Raised if any of the specified packages is not found to be installed Exception message will indicate the name of the specific package found missing