I have a bunch of packages under the namespace "ims" and some nested namespaces like "ims.policies". I wanted to convert all of them to PEP 420 – Implicit Namespace Packages | peps.python.org style packages, removing the init.py from namespace directories and setting up a pyproject.toml. I was able to pip install everything this way but with a big problem - zope-testrunner is unable to discover any of my tests.
I also tried going back to more of a legacy style by putting a init.py in every directory with
This leads to strange behavior. zope-testrunner is able to discover all of my test again, but one of my packages cannot be imported. Everything on a single level can be imported and I can import ims.policies.checkout but not ims.policies.portal. I have double checked that everything has the same init.py. I tried changing the include to ["ims", "ims.policies"] but that didn't matter.
Anyone with more expertise have thoughts on removing this if block? I'm guessing the benefit of avoiding dead ends is small compared to the benefit of being able to use this with pep 420 style packages. And users can still configure tests to explicitly ignore dirs.
setuptools uses a specialized PackageFinder: PEP420PackageFinder for PEP420 namespace packages when declared as find_namespace: ([tool.setuptools.packages.find] in toml).
The PEP420PackageFinder._looks_like_package() returns simply True for every package declared with find_namespace:. Compare it to PackageFinder._looks_like_package():