From 1f79187a1f9e56804616c0c8c01455c0b0dceb99 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 18 Apr 2025 17:24:58 +0800 Subject: [PATCH] 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 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 --- src/pybind/cephfs/setup.py | 4 ++-- src/pybind/rados/setup.py | 4 ++-- src/pybind/rbd/setup.py | 4 ++-- src/pybind/rgw/setup.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pybind/cephfs/setup.py b/src/pybind/cephfs/setup.py index e6547103c7051..6195820b810c5 100755 --- a/src/pybind/cephfs/setup.py +++ b/src/pybind/cephfs/setup.py @@ -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: diff --git a/src/pybind/rados/setup.py b/src/pybind/rados/setup.py index cd99fb457c177..c26d2faab510f 100755 --- a/src/pybind/rados/setup.py +++ b/src/pybind/rados/setup.py @@ -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: diff --git a/src/pybind/rbd/setup.py b/src/pybind/rbd/setup.py index 4f247273796e3..e7671dbb32974 100755 --- a/src/pybind/rbd/setup.py +++ b/src/pybind/rbd/setup.py @@ -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: diff --git a/src/pybind/rgw/setup.py b/src/pybind/rgw/setup.py index a39f8d4e54539..213de782955f6 100755 --- a/src/pybind/rgw/setup.py +++ b/src/pybind/rgw/setup.py @@ -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: -- 2.39.5