Skip to content

Commit 1f79187

Browse files
committed
pybind: switch from pkgutil.find_loader() to importlib.util.find_spec()
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 51f71fc). 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 <[email protected]>
1 parent eb3d949 commit 1f79187

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/pybind/cephfs/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import os
2-
import pkgutil
2+
import importlib.util
33
import shutil
44
import subprocess
55
import sys
66
import tempfile
77
import textwrap
8-
if not pkgutil.find_loader('setuptools'):
8+
if not importlib.util.find_spec('setuptools'):
99
from distutils.core import setup
1010
from distutils.extension import Extension
1111
else:

src/pybind/rados/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import pkgutil
2-
if not pkgutil.find_loader('setuptools'):
1+
import importlib.util
2+
if not importlib.util.find_spec('setuptools'):
33
from distutils.core import setup
44
from distutils.extension import Extension
55
else:

src/pybind/rbd/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import os
2-
import pkgutil
2+
import importlib.util
33
import shutil
44
import subprocess
55
import sys
66
import tempfile
77
import textwrap
8-
if not pkgutil.find_loader('setuptools'):
8+
if not importlib.util.find_spec('setuptools'):
99
from distutils.core import setup
1010
from distutils.extension import Extension
1111
else:

src/pybind/rgw/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import pkgutil
2-
if not pkgutil.find_loader('setuptools'):
1+
import importlib.util
2+
if not importlib.util.find_spec('setuptools'):
33
from distutils.core import setup
44
from distutils.extension import Extension
55
else:

0 commit comments

Comments
 (0)