Namespace subpackages not recognized in Plone 6.0

I am trying to upgrade a buildout from Plone 5.2 (py3) to Plone 6.0 (py 3.11). I have a package with subpackages meant to setup my site policy and theme (mysite.policy, mysite,theme) with each subpackage appearing as its own Add-on in Plone. This setup worked in 5.2 but the subpackages are not being loaded (not appearing in Add-ons list) in 6.0. After some digging around, this seems to be related to differences in plone.autoinclude vs z3c.autoinclude. I took a look at examples in the repo, but I'm not sure if any of them match my case: plone.autoinclude/test-packages at e01ebaa3633ac435cc909e1f5b54d2a8b62c938c · plone/plone.autoinclude · GitHub

How do I get Plone to recognize the subpackages in a 6.0 buildout setup?

setup.py snippets

name='mysite',
# [...]
packages=find_packages(exclude=['ez_setup']),
namespace_packages=['mysite'],
include_package_data=True,
zip_safe=False,
install_requires=[
    'setuptools',
    # ...
],
entry_points="""
# -*- Entry points: -*-
[z3c.autoinclude.plugin]
target = plone
""",

In my setup.py, I've tried both the z3c.autoinclude.plugin and plone.autoinclude.plug in entrypoints. Plone does seem to load mysite but none of the subpackages.

Example structure:

buildout_root_directory
├── setup.py
├── ...
└── mysite/
    ├── __init__.py
    ├── ...
    ├── policy/
    │   ├── __init__.py
    │   ├── configure.zcml
    │   └── ...
    └── theme/
    │   ├── __init__.py
    │   ├── configure.zcml
    │   └── ...
    └─ ...

I remember I fixed some z3c.autoinclude issues when upgrading to Plone 6 by setting the environment variable Z3C_AUTOINCLUDE_DEBUG and starting the Plone instance in foreground.
See z3c.autoinclude · PyPI for more details.

I do not remember the procedure exactly because some time has passed, but if you do that in the Plone 5.2 buildout and you start the instance, e.g.:

Z3C_AUTOINCLUDE_DEBUG=1 ./bin/instance fg

It will log the dependencies it pulls in.

You will need to write dependencies explicitely in the zcml, e.g.:

<include package="plone.app.layout" />

I hope I remember it correctly and that this can help you!