Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-393-Enable-configuration-of-extension-loading-mechanism-strictness 03b2d6a4f -> 19e95f77b (forced update)
ARIA-393 Enable configuration of extension loading mechanism strictness Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/19e95f77 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/19e95f77 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/19e95f77 Branch: refs/heads/ARIA-393-Enable-configuration-of-extension-loading-mechanism-strictness Commit: 19e95f77b9ac4e964da08a7c09de59aa68237b7e Parents: b1f03ef Author: max-orlov <[email protected]> Authored: Mon Oct 23 15:55:46 2017 +0300 Committer: max-orlov <[email protected]> Committed: Tue Nov 7 10:57:08 2017 +0200 ---------------------------------------------------------------------- aria/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/19e95f77/aria/__init__.py ---------------------------------------------------------------------- diff --git a/aria/__init__.py b/aria/__init__.py index 9fe8b3d..a059877 100644 --- a/aria/__init__.py +++ b/aria/__init__.py @@ -46,18 +46,29 @@ __all__ = ( ) -def install_aria_extensions(): +def install_aria_extensions(strict=True): """ Iterates all Python packages with names beginning with ``aria_extension_`` and all ``aria_extension`` entry points and loads them. It then invokes all registered extension functions. + + :param strict: if set to ``True``, Tries to load extensions with + dependency versions under consideration. Otherwise tries to load the + required package without version consideration. Defaults to True. + :type strict: bool """ for loader, module_name, _ in iter_modules(): if module_name.startswith('aria_extension_'): loader.find_module(module_name).load_module(module_name) for entry_point in pkg_resources.iter_entry_points(group='aria_extension'): - entry_point.load() + # It should be possible to enable non strict loading - use the package + # that is already installed inside the environment, and forgo the + # version demand + if strict: + entry_point.load() + else: + entry_point.resolve() extension.init()
