Skip to content

Commit f6a1cfe

Browse files
authored
Merge pull request #888 from ashwinvis/fix/entrypoints-mech
Fix description of entry points mechanism
2 parents 114665c + 18c69bc commit f6a1cfe

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@
395395
('py:func', 'find_packages'),
396396
('py:func', 'setup'),
397397
('py:func', 'importlib.metadata.entry_points'), # remove when 3.10 is released
398+
('py:class', 'importlib.metadata.EntryPoint'), # remove when 3.10 is released
398399
('py:func', 'setuptools.find_namespace_packages'),
399400
('py:func', 'setuptools.find_packages'),
400401
('py:func', 'setuptools.setup'),

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ a list of packages to :func:`setup`'s ``packages`` argument instead of using
120120
Using package metadata
121121
======================
122122

123-
`Setuptools`_ provides `special support`_ for plugins. By
124-
providing the ``entry_points`` argument to :func:`setup` in :file:`setup.py`
125-
plugins can register themselves for discovery.
123+
`Setuptools`_ provides :doc:`special support
124+
<setuptools:userguide/entry_point>` for plugins. By providing the
125+
``entry_points`` argument to :func:`setup` in :file:`setup.py` plugins can
126+
register themselves for discovery.
126127

127128
For example if you have a package named ``myapp-plugin-a`` and it includes
128129
in its :file:`setup.py`:
@@ -150,21 +151,25 @@ Then you can discover and load all of the registered entry points by using
150151
discovered_plugins = entry_points(group='myapp.plugins')
151152
152153
153-
In this example, ``discovered_plugins`` would be:
154+
In this example, ``discovered_plugins`` would be a collection of type :class:`importlib.metadata.EntryPoint`:
154155

155156
.. code-block:: python
156157
157-
{
158-
'a': <module: 'myapp_plugin_a'>,
159-
}
158+
(
159+
EntryPoint(name='a', value='myapp_plugin_a', group='myapp.plugins'),
160+
...
161+
)
162+
163+
Now the module of your choice can be imported by executing
164+
``discovered_plugins['a'].load()``.
160165

161166
.. note:: The ``entry_point`` specification in :file:`setup.py` is fairly
162167
flexible and has a lot of options. It's recommended to read over the entire
163-
section on `entry points`_.
168+
section on :doc:`entry points <setuptools:userguide/entry_point>` .
169+
170+
.. note:: Since this specification is part of the :doc:`standard library
171+
<python:library/importlib.metadata>`, most packaging tools other than setuptools
172+
provide support for defining entry points.
164173

165174
.. _Setuptools: https://setuptools.readthedocs.io
166-
.. _special support:
167-
.. _entry points:
168-
https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins
169175
.. _backport: https://importlib-metadata.readthedocs.io/en/latest/
170-

0 commit comments

Comments
 (0)