]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: switch from pkgutil.find_loader() to importlib.util.find_spec() 62879/head
authorKefu Chai <tchaikov@gmail.com>
Fri, 18 Apr 2025 09:24:58 +0000 (17:24 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sat, 19 Apr 2025 01:03:37 +0000 (09:03 +0800)
Replace pkgutil.find_loader() with importlib.util.find_spec() throughout
Python bindings. This addresses the deprecation warning in Python 3.10
(scheduled for removal in 3.14) that appeared when generating librbd
Python bindings.

The importlib.util.find_spec() API has been available since Python 3.4
and is compatible with our minimum required Python version (3.9, since
commit 51f71fc1).

The warning resolved:
```
/home/kefu/dev/ceph/src/pybind/rbd/setup.py:8: DeprecationWarning: 'pkgutil.find_loader' is deprecated and slated for removal in Python 3.14; use importlib.util.find_spec() instead
  if not pkgutil.find_loader('setuptools'):
```

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/pybind/cephfs/setup.py
src/pybind/rados/setup.py
src/pybind/rbd/setup.py
src/pybind/rgw/setup.py

index e6547103c705100983a899256d239dcb70529f1a..6195820b810c5950396ab30c622cd75660ecf735 100755 (executable)
@@ -1,11 +1,11 @@
 import os
-import pkgutil
+import importlib.util
 import shutil
 import subprocess
 import sys
 import tempfile
 import textwrap
-if not pkgutil.find_loader('setuptools'):
+if not importlib.util.find_spec('setuptools'):
     from distutils.core import setup
     from distutils.extension import Extension
 else:
index cd99fb457c177a1a773480d36f0fdf804632823d..c26d2faab510f7082e58937efa33bd929edaf9fb 100755 (executable)
@@ -1,5 +1,5 @@
-import pkgutil
-if not pkgutil.find_loader('setuptools'):
+import importlib.util
+if not importlib.util.find_spec('setuptools'):
     from distutils.core import setup
     from distutils.extension import Extension
 else:
index 4f247273796e3e88f7721653865f87a5386c8ce4..e7671dbb329746a374ab97fb6a79d4751e593a36 100755 (executable)
@@ -1,11 +1,11 @@
 import os
-import pkgutil
+import importlib.util
 import shutil
 import subprocess
 import sys
 import tempfile
 import textwrap
-if not pkgutil.find_loader('setuptools'):
+if not importlib.util.find_spec('setuptools'):
     from distutils.core import setup
     from distutils.extension import Extension
 else:
index a39f8d4e54539ad7b48de94542de1fe839236d3b..213de782955f6b8a3326665ce5935e17315d9a80 100755 (executable)
@@ -1,5 +1,5 @@
-import pkgutil
-if not pkgutil.find_loader('setuptools'):
+import importlib.util
+if not importlib.util.find_spec('setuptools'):
     from distutils.core import setup
     from distutils.extension import Extension
 else: