Skip to content

Clarify namespace package requirements in plugin discovery guide - #2194

Merged
rgommers merged 2 commits into
python:mainfrom
jeej3000:clarify-plugin-namespace-packages
Nov 26, 2026
Merged

rgommers merged 2 commits into
python:mainfrom
jeej3000:clarify-plugin-namespace-packages

Conversation

@jeej3000

@jeej3000 jeej3000 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

The "Using namespace packages" section of the plugin discovery guide only described pkgutil-style namespace sub-packages (requiring an __init__.py), which contradicts PEP 420 native namespace packages.

This change:

  • describes both variants (native and pkgutil-style) and says all plugins must use the same one,
  • mentions setuptools.find_namespace_packages instead of setup(packages=...), since find_packages skips directories without __init__.py,
  • notes that with native namespace packages import myapp.plugins raises ModuleNotFoundError when no plugin is installed.

Tested: docs build with sphinx-build -W; I also checked the native-namespace behaviour described with a small script.

Fixes #1104

jeej3000 and jeej1k are both my accounts; jeej1k is credited as co-author as a backup in case one account is lost.

🤖 Generated with Claude Code


📚 Documentation preview 📚: https://python-packaging-user-guide--2194.org.readthedocs.build/en/2194/

@rgommers rgommers added component: guides type: maintenance Regular maintenance of the guide, CI and repo labels Nov 18, 2026

@rgommers rgommers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jeej3000, this is a useful change, and pretty close to ready - I have two suggestions.

jeej3000 and others added 2 commits November 19, 2026 17:39
The "Using namespace packages" section only described pkgutil-style
namespace sub-packages (requiring an `__init__.py`), which contradicts
PEP 420 native namespace packages. Describe both variants, mention
`find_namespace_packages`, and note that `import myapp.plugins` fails
when no plugin is installed.

Fixes python#1104

Co-authored-by: jeej1k <351634202+jeej1k@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… note

Co-authored-by: jeej1k <351634202+jeej1k@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@jeej3000
jeej3000 force-pushed the clarify-plugin-namespace-packages branch from 1b89453 to 4dfa8d8 Compare November 19, 2026 16:40

@rgommers rgommers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jeej3000. That addressed the remaining comments, and this resolves the concerns in #1104. So in it goes.

@rgommers
rgommers added this pull request to the merge queue Nov 26, 2026
Merged via the queue into python:main with commit 727c67b Nov 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: guides type: maintenance Regular maintenance of the guide, CI and repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants