summaryrefslogtreecommitdiff
path: root/novaclient/utils.py
diff options
context:
space:
mode:
authorDoug Hellmann <doug@doughellmann.com>2015-05-27 18:08:02 +0000
committerDoug Hellmann <doug@doughellmann.com>2015-05-27 18:08:02 +0000
commite649cea843b8453d268da8ea74ea180f513d5ea3 (patch)
treeb7db76b04552c9ea1f68b4dbcb45e7f3c0a4b801 /novaclient/utils.py
parent0a327ce3752736dbc91535355b05fc09a43c7110 (diff)
downloadpython-novaclient-e649cea843b8453d268da8ea74ea180f513d5ea3.tar.gz
Do not check requirements when loading entry points
Update the calls to pkg_resources to avoid forcing a requirements check when the plugins are being loaded. There are 2 versions of the entry point API in different releases of setuptools. In one version, the require keyword argument can be passed to load(). In the other, separate methods resolve() and require() need to be used. This change updates the mock and fake objects to support either, since the fakes are subclasses of the EntryPoint class in pkg_resources. It would be better to replace the calls to pkg_resources with stevedore, which provides a more stable API, abstracts away this difference, and provides an API for creating test managers directly. That change would have required more extensive updates to the test suite, though, and since I'm not as familiar with this code base as others will be, I will leave those changes for someone else. Change-Id: I2a9aeb53ccad04c7fa687f25340306b84218f9ff Partial-bug: #1457100
Diffstat (limited to 'novaclient/utils.py')
-rw-r--r--novaclient/utils.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/novaclient/utils.py b/novaclient/utils.py
index 50310bfd..1f4df7a5 100644
--- a/novaclient/utils.py
+++ b/novaclient/utils.py
@@ -319,7 +319,14 @@ def _load_entry_point(ep_name, name=None):
"""Try to load the entry point ep_name that matches name."""
for ep in pkg_resources.iter_entry_points(ep_name, name=name):
try:
- return ep.load()
+ # FIXME(dhellmann): It would be better to use stevedore
+ # here, since it abstracts this difference in behavior
+ # between versions of setuptools, but this seemed like a
+ # more expedient fix.
+ if hasattr(ep, 'resolve') and hasattr(ep, 'require'):
+ return ep.resolve()
+ else:
+ return ep.load(require=False)
except (ImportError, pkg_resources.UnknownExtra, AttributeError):
continue