Skip to contentSkip to conversation

perf python: Avoid deprecation warning on distutils

PATCH Applied Ian Rogers 3 participants 3 messages Jun 15, 2022 – Jul 18, 2022 perf events

lore
Share & tools
lore

Ian Rogers

author
#0 lore raw

PATCH 1/1 perf python: Avoid deprecation warning on distutils

Fix the following DeprecationWarning:

tools/perf/util/setup.py:31: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives

Note: the setuptools module may need installing, for example:
sudo apt install python-setuptools

---
 tools/perf/util/setup.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/setup.py +4 -4
index c255a2c90cd6..5a3c74bce836 100644
@@ -11,7 +11,7 @@ def clang_has_option(option):
     return [o for o in cc_output if ((b"unknown argument" in o) or (b"is not supported" in o))] == [ ]
 
 if cc_is_clang:
-    from distutils.sysconfig import get_config_vars
+    from sysconfig import get_config_vars
     vars = get_config_vars()
     for var in ('CFLAGS', 'OPT'):
         vars[var] = sub("-specs=[^ ]+", "", vars[var])
@@ -28,10 +28,10 @@ if cc_is_clang:
         if not clang_has_option("-ffat-lto-objects"):
             vars[var] = sub("-ffat-lto-objects", "", vars[var])
 
-from distutils.core import setup, Extension
+from setuptools import setup, Extension
 
-from distutils.command.build_ext   import build_ext   as _build_ext
-from distutils.command.install_lib import install_lib as _install_lib
+from setuptools.command.build_ext   import build_ext   as _build_ext
+from setuptools.command.install_lib import install_lib as _install_lib
 
 class build_ext(_build_ext):
     def finalize_options(self):
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines · Ian Rogers

Fix the following DeprecationWarning:

tools/perf/util/setup.py:31: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives

Note: the setuptools module may need installing, for example:
sudo apt install python-setuptools

---
 tools/perf/util/setup.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/setup.py +1 -1
index c255a2c90cd6..5a3c74bce836 100644
@@ -11,7 +11,7 @@ def clang_has_option(option):
     return [o for o in cc_output if ((b"unknown argument" in o) or (b"is not supported" in o))] == [ ]
 
 if cc_is_clang:
-    from distutils.sysconfig import get_config_vars
+    from sysconfig import get_config_vars
     vars = get_config_vars()
     for var in ('CFLAGS', 'OPT'):
         vars[var] = sub("-specs=[^ ]+", "", vars[var])
@@ -28,10 +28,10 @@ if cc_is_clang:
         if not clang_has_option("-ffat-lto-objects"):
             vars[var] = sub("-ffat-lto-objects", "", vars[var])
 

tools/perf/util/setup.py if cc_is_clang: · line 37

Quoted 10 lines
tools/perf/util/setup.py +3 -3
-from distutils.core import setup, Extension
+from setuptools import setup, Extension
 
-from distutils.command.build_ext   import build_ext   as _build_ext
-from distutils.command.install_lib import install_lib as _install_lib
+from setuptools.command.build_ext   import build_ext   as _build_ext
+from setuptools.command.install_lib import install_lib as _install_lib
 
 class build_ext(_build_ext):
     def finalize_options(self):

Tested it with python 2.7 and 3.8 by running "make install-python_ext PYTHON=..."

maintainer Applied
#2 lore raw

Em Mon, Jul 18, 2022 at 01:50:22PM +0100, James Clark escreveu:

Quoted 9 lines · Ian Rogers
Quoted 8 lines

Fix the following DeprecationWarning:

tools/perf/util/setup.py:31: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives

Note: the setuptools module may need installing, for example:
sudo apt install python-setuptools

Thanks, applied, added this to the cset log:

Reviewer comments:

James said:

Tested it with python 2.7 and 3.8 by running "make install-python_ext PYTHON=..."

Committer notes:

Tested with:

$ make -k BUILD_BPF_SKEL=1 PYTHON=python2 O=/tmp/build/perf-urgent -C tools/perf install-bin ; perf test python

$ make -k BUILD_BPF_SKEL=1 PYTHON=python3 O=/tmp/build/perf-urgent -C tools/perf install-bin ; perf test python

$ make -k BUILD_BPF_SKEL=1 O=/tmp/build/perf-urgent -C tools/perf install-bin ; perf test python

- Arnaldo

Quoted 37 lines
Quoted 23 lines
---
 tools/perf/util/setup.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/setup.py +1 -1
index c255a2c90cd6..5a3c74bce836 100644
@@ -11,7 +11,7 @@ def clang_has_option(option):
     return [o for o in cc_output if ((b"unknown argument" in o) or (b"is not supported" in o))] == [ ]
 
 if cc_is_clang:
-    from distutils.sysconfig import get_config_vars
+    from sysconfig import get_config_vars
     vars = get_config_vars()
     for var in ('CFLAGS', 'OPT'):
         vars[var] = sub("-specs=[^ ]+", "", vars[var])
@@ -28,10 +28,10 @@ if cc_is_clang:
         if not clang_has_option("-ffat-lto-objects"):
             vars[var] = sub("-ffat-lto-objects", "", vars[var])
 

tools/perf/util/setup.py if cc_is_clang: · line 37

Quoted 10 lines
tools/perf/util/setup.py +3 -3
-from distutils.core import setup, Extension
+from setuptools import setup, Extension
 
-from distutils.command.build_ext   import build_ext   as _build_ext
-from distutils.command.install_lib import install_lib as _install_lib
+from setuptools.command.build_ext   import build_ext   as _build_ext
+from setuptools.command.install_lib import install_lib as _install_lib
 
 class build_ext(_build_ext):
     def finalize_options(self):

Tested it with python 2.7 and 3.8 by running "make install-python_ext PYTHON=..."

Signature · 1 line
- Arnaldo