1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
From 12cc90a8dac62824c9326f5a4b31744c3f2bf10b Mon Sep 17 00:00:00 2001
From: Peter Sabaini <peter.sabaini@canonical.com>
Date: Wed, 11 Sep 2024 16:56:50 +0200
Subject: [PATCH] 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>
---
src/ceph-volume/ceph_volume/main.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/ceph-volume/ceph_volume/main.py b/src/ceph-volume/ceph_volume/main.py
index f8eca65ec497c..110ccf727c82e 100644
--- a/src/ceph-volume/ceph_volume/main.py
+++ b/src/ceph-volume/ceph_volume/main.py
@@ -9,15 +9,25 @@
# `entry_points` from `importlib.metadata` does not.
try:
from importlib.metadata import entry_points
+ from importlib.metadata import EntryPoints
def get_entry_points(group: str): # type: ignore
- return entry_points().get(group, []) # type: ignore
+ eps = entry_points()
+ if isinstance(eps, EntryPoints) and 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
return entry_points(group=group) # type: ignore
+
from ceph_volume.decorators import catches
from ceph_volume import log, devices, configuration, conf, exceptions, terminal, inventory, drive_group, activate
|