diff --git a/hepdata_converter/parsers/__init__.py b/hepdata_converter/parsers/__init__.py index 75836f9..74e07e6 100644 --- a/hepdata_converter/parsers/__init__.py +++ b/hepdata_converter/parsers/__init__.py @@ -7,6 +7,7 @@ import pkgutil import inspect +from importlib.util import module_from_spec class BadFormat(Exception): @@ -175,7 +176,9 @@ def parse(self, data_in, *args, **kwargs): # import all packages in the parsers package, so that Parser.get_specific_parser will recognise them for loader, name, is_pkg in pkgutil.walk_packages(__path__): - module = loader.find_module(name).load_module(name) + spec = loader.find_spec(name) + module = module_from_spec(spec) + spec.loader.exec_module(module) for name, value in inspect.getmembers(module): if name.startswith('__'): diff --git a/hepdata_converter/writers/__init__.py b/hepdata_converter/writers/__init__.py index 96624d0..d10fc86 100644 --- a/hepdata_converter/writers/__init__.py +++ b/hepdata_converter/writers/__init__.py @@ -6,6 +6,7 @@ __all__ = [] import abc +from importlib.util import module_from_spec class Writer(GetConcreteSubclassMixin, OptionInitMixin, metaclass=abc.ABCMeta): @@ -36,7 +37,9 @@ def write(self, data_in, data_out, *args, **kwargs): # import all packages in the parsers package, so that Writer.get_specific_writer will recognise them for loader, name, is_pkg in pkgutil.walk_packages(__path__): - module = loader.find_module(name).load_module(name) + spec = loader.find_spec(name) + module = module_from_spec(spec) + spec.loader.exec_module(module) for name, value in inspect.getmembers(module): if name.startswith('__'):