diff mbox series

[4/5,v3] scripts: Remove dependency on the Python module distutils

Message ID 20221104143616.1089636-5-jwcart2@gmail.com (mailing list archive)
State Accepted
Commit 2b5d5585754e
Headers show
Series Remove dependency on the Python module distutils | expand

Commit Message

James Carter Nov. 4, 2022, 2:36 p.m. UTC
The distutils package is deprecated and scheduled to be removed in
Python 3.12. Use the sysconfig module instead.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 scripts/env_use_destdir | 2 +-
 scripts/run-scan-build  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/scripts/env_use_destdir b/scripts/env_use_destdir
index 8274013e..89d989a2 100755
--- a/scripts/env_use_destdir
+++ b/scripts/env_use_destdir
@@ -43,7 +43,7 @@  if [ -n "${SBINDIR:-}" ] ; then
     PATH="$DESTDIR$SBINDIR:$PATH"
 fi
 
-NEW_PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(plat_specific=1, prefix='/usr'))"):$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")"
+NEW_PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('platlib', vars={'platbase': '/usr', 'base': '/usr'}))"):$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '/usr', 'base': '/usr'}))")"
 if [ -n "${PYTHONPATH:-}" ] ; then
     # Prefix the PYTHONPATH with the new directories
     export PYTHONPATH="$NEW_PYTHONPATH:$PYTHONPATH"
diff --git a/scripts/run-scan-build b/scripts/run-scan-build
index 77e02ca9..931ffd2a 100755
--- a/scripts/run-scan-build
+++ b/scripts/run-scan-build
@@ -21,7 +21,7 @@  fi
 # Make sure to use the newly-installed libraries when running tests
 export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib"
 export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH"
-export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")"
+export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "import sysconfig; print(sysconfig.get_path('purelib', vars={'platbase': '/usr', 'base': '/usr'}))")"
 export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')"
 
 if [ -f /etc/debian_version ] && [ -z "${IS_CIRCLE_CI:-}" ] ; then