Skip to content

Cover PEP 420 namespace packages in "Creating and discovering plugins" guide #1104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
haxtibal opened this issue Jul 6, 2022 · 3 comments
Labels
component: guides type: enhancement A self-contained enhancement or new feature

Comments

@haxtibal
Copy link

haxtibal commented Jul 6, 2022

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?

@haxtibal
Copy link
Author

haxtibal commented Jul 6, 2022

Guess I'm not the only one confused. See pypa/packaging-problems#321 and https://stackoverflow.com/q/59033414.

@pradyunsg pradyunsg added component: guides type: enhancement A self-contained enhancement or new feature labels Jul 15, 2022
@pradyunsg pradyunsg changed the title Discovering plugins unclear for PEP 420 namespace packages Cover PEP 420 namespace packages in "Creating and discovering plugins" guide Jul 15, 2022
@pradyunsg
Copy link
Member

I'm pretty sure that guide section is not refering to PEP 420 namespace packages. PRs would be welcome to improve this.

@pypa pypa deleted a comment from Mohdhapizi Oct 25, 2022
@Manuelon1990
Copy link

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.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.

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__.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.

¿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.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.

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__.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.

¿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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: guides type: enhancement A self-contained enhancement or new feature
Projects
None yet
Development

No branches or pull requests

4 participants
@pradyunsg @haxtibal @Manuelon1990 and others