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/gen_call_robot.py b/lib/gen_call_robot.py
index 91231bf..4a8e2b0 100755
--- a/lib/gen_call_robot.py
+++ b/lib/gen_call_robot.py
@@ -5,7 +5,7 @@
robot program calls.
"""
-import imp
+import importlib.util
import os
import re
import subprocess
@@ -18,7 +18,9 @@
import gen_valid as gv
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
)