glyph/publication

Breaks submodules

Closed this issue · 1 comments

Given a file structure like:

.
└── foo
    ├── __init__.py
    └── bar
        └── __init__.py

Where each __init__.py contains a single class, and the publish() call, publication makes it impossible to import bar. Attempting to do so gives an error like:

$ python -c "import foo.bar"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'foo.bar'; 'foo' is not a package

Attempting to add "bar" to the __all__ inside of foo/__init__.py does not appear to help.

However, if you first import bar and then add it to __all__ then it works as expected.

Is this expected behavior? Does using publication mean that you have to enumerate all of the sub-modules (and their submodules, etc recursively) and add each of those to __all__ in order to get fully functional packages?

Personally, I feel like name hiding even submodules without explicit declaration is more than is required?

I've tested 47be8a6 and it seems to be working correctly (though I have more testing to do).

However, it appears that __spec__ should also be added to that list, otherwise importlib.resources breaks.