Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace imp module usage #1195

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions DDCore/python/dd4hep_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
# ==========================================================================
from __future__ import absolute_import, unicode_literals
import cppyy
import imp
import importlib
import types
import logging


Expand All @@ -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
Expand Down Expand Up @@ -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')
# ---------------------------------------------------------------------------
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
Loading