pypa / pypa/packaging.python.org

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

Aperta
#1,104 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

component: guides type: enhancement
Lingua principale
Python
Stelle
1.7k
Fork
1.7k
Merge medio
3g 12h
PR unite (30g)
4

Descrizione

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?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con la sezione “Using namespace packages” della guida Creating and discovering plugins, quindi confronta il suo esempio con PEP 420 e la guida packaging namespace-packages. Chiarisci se le istruzioni esistenti descrivono native o pkg-style namespaces e documenta un esempio minimo corretto di native namespace, se appropriato. Il lavoro è completato quando la guida non è più in conflitto con PEP 420 e spiega il caso senza plugin.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.