I have read https://peps.python.org/pep-0420/ but it does not explicitly declare that namespace packages are strictly only allowed on top-level. All examples show namespace packages as top-level packages.
Would this work (package1 and package2 are distributed in separate packages)?
package1/
+-- foo/
+-- __init__.py
+-- bar/
+-- baz.py
package2/
+-- foo/
+-- bar/
+-- zoq.py
In the above example, “foo” is a regular package and “foo/bar” is a namespace package. I assume that the answer should be “no” since “foo” would have 2 different roles, but I could be wrong.
(A reason for this question would be if foo/__init__.py
is in extensive use, and converting it to a namespace package would cause a major headache.)