]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: use importlib from stdlib on Python 3.8 and up
authorKefu Chai <tchaikov@gmail.com>
Thu, 23 May 2024 04:47:26 +0000 (12:47 +0800)
committerZac Dover <zac.dover@proton.me>
Thu, 13 Jun 2024 11:07:41 +0000 (21:07 +1000)
since packaging was apparently removed from pkg_resources, let's use
importlib.metadata when it is available and pkg_resources on older
Python versions.

Refs https://tracker.ceph.com/issues/66201
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
(cherry picked from commit 24f8e5c61b19deab7397b0237f8376c6c03a5dcb)

src/ceph-volume/ceph_volume/main.py

index 7868665cecbf59e32856be3f38462615947f36d1..afdb786fabeaf80a6549743125cbb2bf423a17b0 100644 (file)
@@ -1,10 +1,15 @@
 from __future__ import print_function
 import argparse
 import os
-import pkg_resources
 import sys
 import logging
 
+try:
+    from importlib.metadata import entry_points
+except ImportError:
+    from pkg_resources import iter_entry_points as entry_points
+
+
 from ceph_volume.decorators import catches
 from ceph_volume import log, devices, configuration, conf, exceptions, terminal, inventory, drive_group, activate
 
@@ -170,9 +175,9 @@ def _load_library_extensions():
     """
     logger = logging.getLogger('ceph_volume.plugins')
     group = 'ceph_volume_handlers'
-    entry_points = pkg_resources.iter_entry_points(group=group)
+
     plugins = []
-    for ep in entry_points:
+    for ep in entry_points(group=group):
         try:
             logger.debug('loading %s' % ep.name)
             plugin = ep.load()