SOLVED: Pip install --editable fails for lack of finder

After installing a pair of packages using pip install --editable (in 3.12.11 venv) I get an error because the second package __init__.py is importing the first in an incomplete state when running a python -mA.utils.xx command.

I tried and failed to replicate with a simplified pair of packages.

I looked in the venv site-packages and find that the second package has only__editable… .pth, but no __editable..finder.py. The structure of the .pth files is different and the second package has just a pointer to the required package source folder.

If I handomatically create the required finder file my error disappears so it seems that my import structure needs a finder to make it work properly. whats even stranger is that this makes a difference even though the second package’s .pth file makes no use of it.

Can anyone describe what controls the construction of a finder? When is the finder required?

Looks like a failed installation, no? Maybe a bug in the build backend. As far as I understand, big parts of an editable installation falls under the responsibility of the build backend. Do you know what are the build backends of these projects? If I understood correctly, each build backend handles this in its own way.

I found out that the problem resides in setuptools. The first setup.py had package_dir = {‘’:‘src’} and the other had {‘’:‘src’, ‘reportlab’:‘src’} which should really be the same as the first. Because the package_dir setup is non-simple setuptools creates a meta finder. The problem is then that the finder creates a namespace which is not fully populated on import by the first.

Solution is just to make reportlab’s setup.py use the correct package_dir; then both get just a simple .pth file pointing at their ‘src’ folder and no namespace modules are created.

1 Like