Skip to content

Commit 37edf1b

Browse files
Jon Wayne Parrottncoghlan
authored andcommitted
Add a note about namespace sub-packages to plugin discovery (#296)
1 parent 22b14f6 commit 37edf1b

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎source/plugin_discovery.rst‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,16 @@ and ``myapp.plugin.b`` then ``myapp_plugins`` in this case would be:
104104
This sample uses a sub-package as the namespace package (``myapp.plugin``), but
105105
it's also possible to use a top-level package for this purpose (such as
106106
``myapp_plugins``). How to pick the namespace to use is a matter of preference,
107-
but it's not recommended to make the top-level package (``myapp`` in this case)
108-
a namespace package for the purpose of plugins, as one bad plugin could cause
109-
the entire namespace to break which would in turn make your project
110-
unimportable.
107+
but it's not recommended to make your project's main top-level package (
108+
``myapp`` in this case) a namespace package for the purpose of plugins, as one
109+
bad plugin could cause the entire namespace to break which would in turn make
110+
your project unimportable. For the "namespace sub-package" approach to work,
111+
the plugin packages must omit the ``__init__.py`` for your top-level package
112+
directory (``myapp`` in this case) and include the namespace-package style
113+
``__init__.py`` in the namespace sub-package directory (``myapp/plugins``).
114+
This also means that plugins will need to explicitly pass a list of packages
115+
to :func:`setup`'s ``packages`` argument instead of using
116+
:func:`setuptools.find_packages`.
111117

112118
.. warning:: Namespace packages are a complex feature and there are several
113119
different ways to create them. It's highly recommended to read the

0 commit comments

Comments
 (0)