Use importlib.util to replace imp
Since the imp module is deprecated and scheduled for removal in
Python 3.12 in favor of importlib, update the relevant libraries to
resolve any ModuleNotFoundError issues with Python 3.12.
Changes:
- use import importlib.util instead of import imp
Tested:
- Ran basic test pass with Python 3.10 and 3.12.
Change-Id: I25dde939dd25268b2ae329b0121858bec20ed03c
Signed-off-by: Brian Ma <chma0@nuvoton.com>
diff --git a/lib/obmc_boot_test.py b/lib/obmc_boot_test.py
index 5b3d7de..5550277 100755
--- a/lib/obmc_boot_test.py
+++ b/lib/obmc_boot_test.py
@@ -5,7 +5,7 @@
"""
import glob
-import imp
+import importlib.util
import os
import random
import re
@@ -36,7 +36,9 @@
from robot.utils import DotDict
base_path = (
- os.path.dirname(os.path.dirname(imp.find_module("gen_robot_print")[1]))
+ os.path.dirname(
+ os.path.dirname(importlib.util.find_spec("gen_robot_print").origin)
+ )
+ os.sep
)
sys.path.append(base_path + "extended/")