remove old compat code
This commit is contained in:
parent
0a61d2746f
commit
266b837642
|
|
@ -108,9 +108,6 @@ def handle_error(error, do_raise: bool = True, do_log: bool = True, log_name: st
|
|||
|
||||
def get_entrypoints():
|
||||
"""Returns list for entrypoints for InvenTree plugins."""
|
||||
# on python before 3.12, we need to use importlib_metadata
|
||||
if sys.version_info < (3, 12):
|
||||
return entry_points().get('inventree_plugins', [])
|
||||
return entry_points(group='inventree_plugins')
|
||||
|
||||
|
||||
|
|
@ -190,13 +187,11 @@ def get_modules(pkg, path=None):
|
|||
continue
|
||||
|
||||
try:
|
||||
if sys.version_info < (3, 12):
|
||||
module = finder.find_module(name).load_module(name)
|
||||
else:
|
||||
spec = finder.find_spec(name, path)
|
||||
module = module_from_spec(spec)
|
||||
sys.modules[name] = module
|
||||
spec.loader.exec_module(module)
|
||||
spec = finder.find_spec(name, path)
|
||||
module = module_from_spec(spec)
|
||||
sys.modules[name] = module
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
pkg_names = getattr(module, '__all__', None)
|
||||
for k, v in vars(module).items():
|
||||
if not k.startswith('_') and (pkg_names is None or k in pkg_names):
|
||||
|
|
|
|||
|
|
@ -585,15 +585,9 @@ class PluginsRegistry:
|
|||
|
||||
# Gather Modules
|
||||
if parent_path:
|
||||
# On python 3.12 use new loader method
|
||||
if sys.version_info < (3, 12):
|
||||
raw_module = _load_source(
|
||||
plugin_dir, str(parent_obj.joinpath('__init__.py'))
|
||||
)
|
||||
else:
|
||||
raw_module = SourceFileLoader(
|
||||
plugin_dir, str(parent_obj.joinpath('__init__.py'))
|
||||
).load_module()
|
||||
raw_module = SourceFileLoader(
|
||||
plugin_dir, str(parent_obj.joinpath('__init__.py'))
|
||||
).load_module()
|
||||
else:
|
||||
raw_module = importlib.import_module(plugin_dir)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue