packaging.python.org
packaging.python.org copied to clipboard
Cover PEP 420 namespace packages in "Creating and discovering plugins" guide
Using namespace packages is not explicit whether it talks about native PEP 420 namespace packages, or pkg-style namespace packages.
I tried to apply it for PEP 420 namespace packages and stumbled over two issues:
First, the given example doesn't wrap import myapp.plugin in try/except, but actually ModuleNotFoundError should be handled because, as a core package maintainer, you can't know how many plugins will be installed at runtime. In case of zero plugins installed, how would you guarantee a myapp.plugins namespace will exists anyways? At least setuptools won't let you install empty directories.
Second, the guide says
include the namespace-package style init.py in the namespace sub-package directory
But PEP 420 explicitly requires the absence of __init__.py files. Then, what is a namespace-package style __init__.py in the context of PEP 420? I believe @theacodes had pkg-style namespace packages in mind when adding that sentence with #296.
Could we make it either more clear the guide is not 1:1 applicable for native namespace packages, or even better, find a suggested minimal working PEP 420 example and adapt the guide accordingly?
Guess I'm not the only one confused. See pypa/packaging-problems#321 and https://stackoverflow.com/q/59033414.
I'm pretty sure that guide section is not refering to PEP 420 namespace packages. PRs would be welcome to improve this.
El uso de paquetes de espacio de nombres no es explícito si habla de paquetes de espacios de nombres nativos PEP 420 o de paquetes de nombres de estilo pkg.
Intenté aplicarlo para los paquetes de espacios de nombres PEP 420 y me topé con dos problemas:
First, the given example doesn't wrap
import myapp.pluginintry/except, but actuallyModuleNotFoundErrorshould be handled because, as a core package maintainer, you can't know how many plugins will be installed at runtime. In case of zero plugins installed, how would you guarantee amyapp.pluginsnamespace will exists anyways? At leastsetuptoolswon't let you install empty directories.En segundo lugar, la guía dice
incluir el paquete de espacio de nombres styleinit.py en el directorio de subpaquete de espacio de nombres
But PEP 420 explicitly requires the absence of
__init__.pyfiles. Then, what is a namespace-package style init.py in the context of PEP 420? I believe @theacodes had pkg-style namespace packages in mind when adding that sentence with #296.¿Podríamos dejar más claro que la guía no es 1:1 aplicable a los paquetes de espacios de nombres nativos, o incluso mejor, encontrar un ejemplo de PEP 420 de trabajo mínimo sugerido y adaptar la guía en consecuencia?
El uso de paquetes de espacio de nombres no es explícito si habla de paquetes de espacios de nombres nativos PEP 420 o de paquetes de nombres de estilo pkg.
Intenté aplicarlo para los paquetes de espacios de nombres PEP 420 y me topé con dos problemas:
First, the given example doesn't wrap
import myapp.pluginintry/except, but actuallyModuleNotFoundErrorshould be handled because, as a core package maintainer, you can't know how many plugins will be installed at runtime. In case of zero plugins installed, how would you guarantee amyapp.pluginsnamespace will exists anyways? At leastsetuptoolswon't let you install empty directories.En segundo lugar, la guía dice
incluir el paquete de espacio de nombres styleinit.py en el directorio de subpaquete de espacio de nombres
But PEP 420 explicitly requires the absence of
__init__.pyfiles. Then, what is a namespace-package style init.py in the context of PEP 420? I believe @theacodes had pkg-style namespace packages in mind when adding that sentence with #296.¿Podríamos dejar más claro que la guía no es 1:1 aplicable a los paquetes de espacios de nombres nativos, o incluso mejor, encontrar un ejemplo de PEP 420 de trabajo mínimo sugerido y adaptar la guía en consecuencia?
yea