Salome HOME
bos# 35129 [EDF] DeprecationWarning imp module ngh/post_script_windows 5/head
authorNabil Ghodbane <nabil.ghodbane@cea.fr>
Wed, 17 May 2023 07:51:08 +0000 (09:51 +0200)
committerNabil Ghodbane <nabil.ghodbane@cea.fr>
Wed, 17 May 2023 11:09:56 +0000 (13:09 +0200)
src/fileEnviron.py

index 20cdc1a53390016443f8a079360189e52ee3f65b..b21dcb94353881fbb3b73b87bd6b3a63215208de 100644 (file)
@@ -994,7 +994,8 @@ launcher_tail_py3="""\
     extradir=out_dir_Path + r"/extra.env.d"
 
     if os.path.exists(extradir):
-        import imp
+        import importlib
+        import importlib.util
         sys.path.insert(0, os.path.join(os.getcwd(), extradir))
         for filename in sorted(
             filter(lambda x: os.path.isfile(os.path.join(extradir, x)),
@@ -1003,9 +1004,9 @@ launcher_tail_py3="""\
             if filename.endswith(".py"):
                 f = os.path.join(extradir, filename)
                 module_name = os.path.splitext(os.path.basename(f))[0]
-                fp, path, desc = imp.find_module(module_name)
-                module = imp.load_module(module_name, fp, path, desc)
-                module.init(context, out_dir_Path)
+                _specs = importlib.util.find_spec(module_name)
+                _module = importlib.util.module_from_spec(_specs)
+                _specs.loader.exec_module(_module)
 
     #[manage salome doc command]
     if len(args) >1 and args[0]=='doc':