Skip to content

Commit

Permalink
Replace imp module usage
Browse files Browse the repository at this point in the history
`imp` was removed in Python 3.12.
  • Loading branch information
paulgessinger authored and MarkusFrankATcernch committed Dec 14, 2023
1 parent eb029b7 commit 92f911d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions DDCore/python/dd4hep_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# ==========================================================================
from __future__ import absolute_import, unicode_literals
import cppyy
import imp
import importlib
import logging


Expand All @@ -35,8 +35,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
Expand Down
4 changes: 2 additions & 2 deletions DDDigi/python/dddigi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions DDG4/python/DDG4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 92f911d

Please sign in to comment.