From 10ec659fc81dbdf62622559da4839792789c8eab Mon Sep 17 00:00:00 2001 From: ale-rt Date: Wed, 26 Feb 2025 17:53:07 +0100 Subject: [PATCH] Fix an error when loading namespace packages Fixes #25 Refs. https://github.com/plone/Products.CMFPlone/issues/4126 --- news/25.bugfix.rst | 1 + src/plone/autoinclude/loader.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 news/25.bugfix.rst diff --git a/news/25.bugfix.rst b/news/25.bugfix.rst new file mode 100644 index 0000000..efc4be8 --- /dev/null +++ b/news/25.bugfix.rst @@ -0,0 +1 @@ +Fix an error when loading namespace packages. [ale-rt] diff --git a/src/plone/autoinclude/loader.py b/src/plone/autoinclude/loader.py index 3ff523d..88af1a1 100644 --- a/src/plone/autoinclude/loader.py +++ b/src/plone/autoinclude/loader.py @@ -1,4 +1,3 @@ -from pkg_resources import iter_entry_points from pkg_resources import resource_filename from pkg_resources import working_set from zope.configuration.xmlconfig import include @@ -37,14 +36,16 @@ def load_z3c_packages(target=""): This returns a dictionary of package names and packages. """ dists = {} - for ep in iter_entry_points(group="z3c.autoinclude.plugin"): + + for ep in importlib.metadata.entry_points(group="z3c.autoinclude.plugin"): # If we look for target 'plone' then only consider entry points # that are registered for this target (module name). # But if the entry point is not registered for a specific target, # we can include it. - if target and ep.module_name != target: + module_name = ep.dist.name + if target and module_name != target: continue - module_name = ep.dist.project_name.replace("-", "_") + if module_name not in _known_module_names: try: dist = importlib.import_module(module_name)