diff --git a/DDCore/python/dd4hep_base.py b/DDCore/python/dd4hep_base.py index b3f843380..3d5073c8d 100644 --- a/DDCore/python/dd4hep_base.py +++ b/DDCore/python/dd4hep_base.py @@ -10,7 +10,8 @@ # ========================================================================== from __future__ import absolute_import, unicode_literals import cppyy -import imp +import importlib +import types import logging @@ -35,8 +36,8 @@ def compileAClick(dictionary, g4=True): gSystem.AddIncludePath(inc) gSystem.AddLinkedLibs(lib) logger.info('Loading AClick %s', dictionary) - package = imp.find_module('DDG4') - dic = os.path.dirname(package[1]) + os.sep + dictionary + package_spec = importlib.util.find_spec('DDG4') + dic = os.path.dirname(package_spec.origin) + os.sep + dictionary gInterpreter.ProcessLine('.L ' + dic + '+') from ROOT import dd4hep as module return module @@ -155,7 +156,7 @@ def unicode_2_string(value): tools = dd4hep.tools align = dd4hep.align detail = dd4hep.detail -units = imp.new_module('units') +units = types.ModuleType('units') # --------------------------------------------------------------------------- import_namespace_item('tools', 'Evaluator') # --------------------------------------------------------------------------- diff --git a/DDDigi/python/dddigi.py b/DDDigi/python/dddigi.py index 4e68c842c..4b3ba73cb 100644 --- a/DDDigi/python/dddigi.py +++ b/DDDigi/python/dddigi.py @@ -94,8 +94,8 @@ def importConstants(description, namespace=None, debug=False): """ ns = current if namespace is not None and not hasattr(current, namespace): - import imp - m = imp.new_module('dddigi.' + namespace) + import types + m = types.ModuleType('dddigi.' + namespace) setattr(current, namespace, m) ns = m evaluator = dd4hep.g4Evaluator() diff --git a/DDG4/python/DDG4.py b/DDG4/python/DDG4.py index afccaa280..10584b35f 100644 --- a/DDG4/python/DDG4.py +++ b/DDG4/python/DDG4.py @@ -82,8 +82,8 @@ def importConstants(description, namespace=None, debug=False): """ ns = current if namespace is not None and not hasattr(current, namespace): - import imp - m = imp.new_module('DDG4.' + namespace) + import types + m = types.ModuleType('DDG4.' + namespace) setattr(current, namespace, m) ns = m evaluator = dd4hep.g4Evaluator()