summarylogtreecommitdiffstats
path: root/ceph-19.2.3-backport-pybind-use-importlib.patch
blob: 3c4cbd36508f21781737e77812a15ea1c0f427dc (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
From 1f79187a1f9e56804616c0c8c01455c0b0dceb99 Mon Sep 17 00:00:00 2001
From: Kefu Chai <tchaikov@gmail.com>
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 <tchaikov@gmail.com>
---
 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: