Skip to content

Commit 617bc8d

Browse files
authored
Merge branch 'main' into docs/pypug-namespace-plugin-keys
2 parents f35ad0d + 727c67b commit 617bc8d

11 files changed

Lines changed: 180 additions & 605 deletions

‎source/guides/creating-and-discovering-plugins.rst‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,17 @@ but it's not recommended to make your project's main top-level package
101101
bad plugin could cause the entire namespace to break which would in turn make
102102
your project unimportable. For the "namespace sub-package" approach to work,
103103
the plugin packages must omit the :file:`__init__.py` for your top-level
104-
package directory (``myapp`` in this case) and include the namespace-package
105-
style :file:`__init__.py` in the namespace sub-package directory
106-
(``myapp/plugins``). This also means that plugins will need to explicitly pass
107-
a list of packages to :func:`setup`'s ``packages`` argument instead of using
108-
:func:`setuptools.find_packages`.
104+
package directory (``myapp`` in this case). In the namespace sub-package
105+
directory (``myapp/plugins``) they must either omit :file:`__init__.py`, if
106+
you use :ref:`native namespace packages <native-namespace-packages>`, or
107+
include a pkgutil-style :file:`__init__.py`, if you use the legacy approach.
108+
Plugins will also need to list their packages explicitly or use :func:`setuptools.find_namespace_packages`, as
109+
:func:`setuptools.find_packages` skips directories without an
110+
:file:`__init__.py`.
111+
112+
With native namespace packages, ``import myapp.plugins`` raises
113+
:exc:`ModuleNotFoundError` if no installed distribution provides the
114+
``myapp/plugins`` directory. Make sure your discovery code handles that case.
109115

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

‎source/guides/creating-command-line-tools.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Conclusion
176176
==========
177177

178178
You know by now how to package a command-line application written in Python. A further step could be to distribute your package,
179-
meaning uploading it to a :term:`package index <Package Index>`, most commonly :term:`PyPI <Python Package Index (PyPI)>`. To do that, follow the instructions at :ref:`Packaging your project`. And once you're done, don't forget to :ref:`do some research <analyzing-pypi-package-downloads>` on how your package is received!
179+
meaning uploading it to a :term:`package index <Package Index>`, most commonly :term:`PyPI <Python Package Index (PyPI)>`. To do that, follow the instructions in the :doc:`packaging tutorial </tutorials/packaging-projects>`. And once you're done, don't forget to :ref:`do some research <analyzing-pypi-package-downloads>` on how your package is received!
180180

181181
.. _click: https://click.palletsprojects.com/
182182
.. _docopt: https://docopt.readthedocs.io/en/latest/

0 commit comments

Comments
 (0)