Docker plone-backend stopped working with z3c.autoinclude.plugin

Hi all!

Yesterday I ran into an issue using the plone-backend docker image.

Suddenly I could no longer create containers due to an error that had not occurred before.

It is possible to recreate the error by doing:

docker run --rm -p 8080:8080 -e ADDONS="collective.easyform[recaptcha]" plone/plone-backend:6.0.14 start

I tested this with several plone 6 images, always the same error.

2025-02-26 11:08:52 ERROR [plone.autoinclude.loader:60][MainThread] Could not import plone_formwidget_recaptcha. Set environment variable AUTOINCLUDE_ALLOW_MODULE_NOT_FOUND_ERROR=1 if you want to allow this. Or set it to 'plone_formwidget_recaptcha' to only allow for this project. Can be a comma-separated list of project names. Or replace the z3c.autoinclude.plugin entry point of this project with plone.autoinclude.plugin and a module name.
Traceback (most recent call last):
  File "/app/lib/python3.11/site-packages/zope/configuration/xmlconfig.py", line 393, in endElementNS
    self.context.end()
  File "/app/lib/python3.11/site-packages/zope/configuration/config.py", line 703, in end
    self.stack.pop().finish()
  File "/app/lib/python3.11/site-packages/zope/configuration/config.py", line 873, in finish
    actions = self.handler(context, **args)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/plone/autoinclude/zcml.py", line 37, in includePluginsDirective
    dists = loader.load_packages(target)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/plone/autoinclude/loader.py", line 139, in load_packages
    z3c_dists = load_z3c_packages(target=target)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/lib/python3.11/site-packages/plone/autoinclude/loader.py", line 50, in load_z3c_packages
    dist = importlib.import_module(module_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'plone_formwidget_recaptcha'

plone.formwidget.recaptcha was not imported since it's using z3c.autoinclude.plugin instead of plone.autoinclude.plugin.

There is a section in the docs about switching to plone.autoinclude:

I had some addons that still used z3c.autoinclude and I modified them to use plone.autoinclude, but that alone did not solve the problem because collective.easyform depends on plone.formwidget.recaptcha.

I also tried to create a custom Dockerfile adding the same dependency and the same error occurred.

The strange thing is that this did not happen until yesterday, does anyone know what happened?

1 Like

@alert just open this:

It seems to be related to a change in setuptools:

I upgrade all my packages today locally. I run also in this "issue".

I switch the entrypoint in my setup.py files to:

entry_points="""
    [plone.autoinclude.plugin]
    target = plone
    module = my.addon
    """

and it works. Alternative you can set a environment var AUTOINCLUDE_ALLOW_MODULE_NOT_FOUND_ERROR=1

see: Raise an exception when a module cannot be imported. by mauritsvanrees · Pull Request #20 · plone/plone.autoinclude · GitHub

That's what I did!
My problem was with plone.formwidget.recaptcha that still uses z3c.autoinclude.

For the time being I made a fork with the fix and added it as a dependency to my custom image.

AUTOINCLUDE_ALLOW_MODULE_NOT_FOUND_ERROR=1

this helps as workaround for me

1 Like

Several people are working to get this fixed. Two competing PRs have been added already and I am about to add a third one. :slight_smile: See PRs linked to Problem fetching a module: · Issue #25 · plone/plone.autoinclude · GitHub.

Meanwhile, if you can't wait and need a workaround that has not been mentioned yet, here are some options:

Try again

setuptools 75.8.2 has been released with a fix, so maybe it just works again for you.

Specify maximum setuptools version

Pinning setuptools in a constraints.txt or versions.cfg does not help, or at least not always. If you have a specific add-on that gives you a problem, you can add or edit a pyproject.toml file next to the setup.py file:

[build-system]
requires = ["setuptools>=68.2,<=75.8.0"]

I set the minimum version here simply because most core Plone packages currently have this. But the important thing is that you set as maximum the last setuptools version that still works. This is then used by pip (and I guess also uv and Buildout) when installing or building this package.

Move from z3c.autoinclude to plone.autoinclude

If you are using z3c.autoinclude, move to plone.autoinclude. How? Simple: if you have z3c.autoinclude.plugin in the setup.py (or similar) of a package, replace this with plone.autoinclude.plugin.
This should fix it in some cases.

Configure module name in plone.autoinclude

If the project name in your setup.py differs from the module name that you would import, and the above is not enough, you can specify the exact module name in the entry point. For example in setup.py:

setup(
    name="example.plone-dash-addon",
...
    entry_points="""
    [plone.autoinclude.plugin]
    target = plone
    module = example.plone_dash_addon
    """,
)
3 Likes

I have published plone.autoinclude 2.0.0 with a fix for the auto-include zcml problems. Also, setuptools 75.8.2 was released, which can help for some cases as well.

Warning: this plone.autoinclude version requires Python 3.9 or higher. Older Python versions are out of security support anyway.

1 Like