summaryrefslogtreecommitdiff
path: root/stevedore/_cache.py
diff options
context:
space:
mode:
Diffstat (limited to 'stevedore/_cache.py')
-rw-r--r--stevedore/_cache.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/stevedore/_cache.py b/stevedore/_cache.py
index 20b631d..6a76bc8 100644
--- a/stevedore/_cache.py
+++ b/stevedore/_cache.py
@@ -97,8 +97,16 @@ def _hash_settings_for_path(path):
return (h.hexdigest(), paths)
-def _build_cacheable_data(path):
+def _build_cacheable_data():
real_groups = importlib_metadata.entry_points()
+
+ if not isinstance(real_groups, dict):
+ # importlib-metadata 4.0 or later (or stdlib importlib.metadata in
+ # Python 3.9 or later)
+ real_groups = {
+ name: real_groups.select(name=name) for name in real_groups.names
+ }
+
# Convert the namedtuple values to regular tuples
groups = {}
for name, group_data in real_groups.items():
@@ -153,7 +161,7 @@ class Cache:
with open(filename, 'r') as f:
data = json.load(f)
except (IOError, json.JSONDecodeError):
- data = _build_cacheable_data(path)
+ data = _build_cacheable_data()
data['path_values'] = path_values
if not self._disable_caching:
try: