Skip to content

Add PEP 621 tab for entry points docs #1115

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

Merged
merged 9 commits into from
Dec 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions source/guides/creating-and-discovering-plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,20 @@ a list of packages to :func:`setup`'s ``packages`` argument instead of using
Using package metadata
======================

:doc:`Setuptools <setuptools:index>` provides :doc:`special support
<setuptools:userguide/entry_point>` for plugins. By providing the
``entry_points`` argument to :func:`setup` in :file:`setup.py` plugins can
register themselves for discovery.
Packages can have metadata for plugins described in the :ref:`entry-points`.
By specifying them, a package announces that it contains a specific kind of plugin.
Another package supporting this kind of plugin can use the metadata to discover that plugin.

For example if you have a package named ``myapp-plugin-a`` and it includes
in its :file:`setup.py`:
the following in its ``pyproject.toml``:

.. code-block:: python
.. code-block:: toml

setup(
...
entry_points={'myapp.plugins': 'a = myapp_plugin_a'},
...
)
[project.entry-points.'myapp.plugins']
a = 'myapp_plugin_a'

Then you can discover and load all of the registered entry points by using
:func:`importlib.metadata.entry_points` (or the `backport`_
:func:`importlib.metadata.entry_points` (or the backport_
``importlib_metadata >= 3.6`` for Python 3.6-3.9):

.. code-block:: python
Expand Down