remove old compat code

This commit is contained in:
Matthias Mair 2026-06-24 01:45:12 +02:00
parent 0a61d2746f
commit 266b837642
No known key found for this signature in database
GPG Key ID: A593429DDA23B66A
2 changed files with 8 additions and 19 deletions

View File

@ -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):

View File

@ -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)