diff mbox series

[12/14] rteval: Use sysconfig instead of deprecated distutils

Message ID 20230221195828.17919-2-jkacur@redhat.com
State New
Headers show
Series None | expand

Commit Message

John Kacur Feb. 21, 2023, 7:58 p.m. UTC
Use sysconfig instead of deprecated distutils to add the
rteval directory to the module search path.

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 rteval/__init__.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/rteval/__init__.py b/rteval/__init__.py
index d8127425febe..a245ef935568 100644
--- a/rteval/__init__.py
+++ b/rteval/__init__.py
@@ -37,7 +37,7 @@  import sys
 import threading
 import time
 from datetime import datetime
-from distutils import sysconfig
+import sysconfig
 from rteval.modules.loads import LoadModules
 from rteval.modules.measurement import MeasurementModules, MeasurementProfile
 from rteval.rtevalReport import rtevalReport
@@ -99,7 +99,12 @@  class RtEval(rtevalReport):
             raise RuntimeError(f"can't find XSL template ({self.__rtevcfg.xslt_report})!")
 
         # Add rteval directory into module search path
-        sys.path.insert(0, f'{sysconfig.get_python_lib()}/rteval')
+        scheme = 'rpm_prefix'
+        if scheme not in sysconfig.get_scheme_names():
+            scheme = 'posix_prefix'
+        pypath = f"{sysconfig.get_path('platlib', scheme)}/rteval"
+        sys.path.insert(0, pypath)
+        self.__logger.log(Log.DEBUG, f"Adding {pypath} to search path")
 
         # Initialise the report module
         rtevalReport.__init__(self, self.__version,