]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
spns #16824 : replace obsolete imp by importlib for python>=3.5
authorcrouzet <nicolas.crouzet@cea.fr>
Fri, 10 May 2019 14:06:30 +0000 (16:06 +0200)
committercrouzet <nicolas.crouzet@cea.fr>
Fri, 10 May 2019 14:06:30 +0000 (16:06 +0200)
commands/package.py

index 2d67ac917a56141b0aa0d40911acabbff8703c22..bf3fbee67c2763ae56b55503f75992263be78b77 100644 (file)
@@ -301,9 +301,16 @@ def hack_for_distene_licence(filepath, licence_file):
         return
     del text[num_line +1]
     del text[num_line +1]
-    text_to_insert ="""    import imp
-    try:
-        distene = imp.load_source('distene_licence', '%s')
+    text_to_insert ="""    try:
+        distene_licence_file="%s"
+        if sys.version_info[0] >= 3 and sys.version_info[1] >= 5:
+            import importlib.util
+            spec_dist = importlib.util.spec_from_file_location("distene_licence", distene_licence_file)
+            distene=importlib.util.module_from_spec(spec_dist)
+            spec_dist.loader.exec_module(distene)
+        else:
+            import imp
+            distene = imp.load_source('distene_licence', distene_licence_file)
         distene.set_distene_variables(context)
     except:
         pass\n"""  % licence_file