Skip to content

Commit 1ed254c

Browse files
committed
Fix description of entry points mechanism
- Show how a module would be loaded. A dictionary of modules will not be loaded, unless created by the user - Update links to external documentation - Hint that specifying entry points is not limited setuptools. For example flit (https://flit.readthedocs.io/en/latest/pyproject_toml.html#entry-points-sections) and poetry (https://python-poetry.org/docs/pyproject/#plugins) support it too.
1 parent 114665c commit 1ed254c

2 files changed

Lines changed: 15 additions & 5 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.EntryPoints'), # 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: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,30 @@ Then you can discover and load all of the registered entry points by using
150150
discovered_plugins = entry_points(group='myapp.plugins')
151151
152152
153-
In this example, ``discovered_plugins`` would be:
153+
In this example, ``discovered_plugins`` would be a collection of type :class:`importlib.metadata.EntryPoints`:
154154

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

161165
.. note:: The ``entry_point`` specification in :file:`setup.py` is fairly
162166
flexible and has a lot of options. It's recommended to read over the entire
163167
section on `entry points`_.
164168

169+
.. note:: Since this specification is part of the `standard library`_, most
170+
packaging tools other than setuptools provide support for defining entry
171+
points.
172+
165173
.. _Setuptools: https://setuptools.readthedocs.io
166174
.. _special support:
167175
.. _entry points:
168-
https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins
176+
https://setuptools.readthedocs.io/en/stable/userguide/entry_point.html
177+
.. _standard library: https://docs.python.org/3/library/importlib.metadata.html#entry-points
169178
.. _backport: https://importlib-metadata.readthedocs.io/en/latest/
170179

0 commit comments

Comments
 (0)