From 90027de9087c18b289ba7b2d2550dc99fdd41fb7 Mon Sep 17 00:00:00 2001 From: Philipp A Date: Mon, 5 Dec 2022 00:31:11 +0100 Subject: [PATCH] Add PEP 621 tab for entry points docs (#1115) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add PEP 621 tab for entry points * Maybe fix ref * maybe it can’t handle links in tab headers? * remove tabs again * Better explanation * fix link Co-authored-by: Brian Rutledge --- .../creating-and-discovering-plugins.rst | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/source/guides/creating-and-discovering-plugins.rst b/source/guides/creating-and-discovering-plugins.rst index 2928d22e2..386b09c87 100644 --- a/source/guides/creating-and-discovering-plugins.rst +++ b/source/guides/creating-and-discovering-plugins.rst @@ -120,24 +120,20 @@ a list of packages to :func:`setup`'s ``packages`` argument instead of using Using package metadata ====================== -:doc:`Setuptools ` provides :doc:`special support -` 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