diff options
author | Peter Sabaini <peter.sabaini@canonical.com> | 2024-09-11 16:56:50 +0200 |
---|---|---|
committer | Peter Sabaini <peter.sabaini@canonical.com> | 2024-11-19 18:37:27 +0100 |
commit | 8c78a22d2cf69892570f635735d9735169b64a75 (patch) | |
tree | 626d396855d52ae87bd2457e6a9718344d09fa1a | |
parent | Merge pull request #59635 from zdover23/wip-doc-2024-09-06-rados-ops-health-c... (diff) | |
download | ceph-8c78a22d2cf69892570f635735d9735169b64a75.tar.xz ceph-8c78a22d2cf69892570f635735d9735169b64a75.zip |
ceph-volume: fix importlib.metadata compat
The importlib.metadata library removed older shims in releases >5.0.0
where EntryPoints objects use .select() instead of dict-like access.
Fixes: https://tracker.ceph.com/issues/68032
Signed-off-by: Peter Sabaini <peter.sabaini@canonical.com>
-rw-r--r-- | src/ceph-volume/ceph_volume/main.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ceph-volume/ceph_volume/main.py b/src/ceph-volume/ceph_volume/main.py index f8eca65ec49..4f27f429e89 100644 --- a/src/ceph-volume/ceph_volume/main.py +++ b/src/ceph-volume/ceph_volume/main.py @@ -11,8 +11,16 @@ try: from importlib.metadata import entry_points def get_entry_points(group: str): # type: ignore - return entry_points().get(group, []) # type: ignore + eps = entry_points() + if hasattr(eps, 'select'): + # New importlib.metadata uses .select() + return eps.select(group=group) + else: + # Fallback to older EntryPoints that returns dicts + return eps.get(group, []) # type: ignore + except ImportError: + # Fallback to `pkg_resources` for older versions from pkg_resources import iter_entry_points as entry_points # type: ignore def get_entry_points(group: str): # type: ignore |