@@ -79,15 +79,43 @@ Entry points are represented by ``EntryPoint`` instances;
79
79
each ``EntryPoint `` has a ``.name ``, ``.group ``, and ``.value `` attributes and
80
80
a ``.load() `` method to resolve the value. There are also ``.module ``,
81
81
``.attr ``, and ``.extras `` attributes for getting the components of the
82
- ``.value `` attribute::
82
+ ``.value `` attribute.
83
+
84
+ Query all entry points::
83
85
84
86
>>> eps = entry_points() # doctest: +SKIP
87
+
88
+ The ``entry_points() `` function returns an ``EntryPoints `` object,
89
+ a sequence of all ``EntryPoint `` objects with ``names `` and ``groups ``
90
+ attributes for convenience::
91
+
85
92
>>> sorted(eps.groups) # doctest: +SKIP
86
93
['console_scripts', 'distutils.commands', 'distutils.setup_keywords', 'egg_info.writers', 'setuptools.installation']
94
+
95
+ ``EntryPoints `` has a ``select `` method to select entry points
96
+ matching specific properties. Select entry points in the
97
+ ``console_scripts `` group::
98
+
87
99
>>> scripts = eps.select(group='console_scripts') # doctest: +SKIP
100
+
101
+ Equivalently, since ``entry_points `` passes keyword arguments
102
+ through to select::
103
+
104
+ >>> scripts = entry_points(group='console_scripts') # doctest: +SKIP
105
+
106
+ Pick out a specific script named "wheel" (found in the wheel project)::
107
+
88
108
>>> 'wheel' in scripts.names # doctest: +SKIP
89
109
True
90
110
>>> wheel = scripts['wheel'] # doctest: +SKIP
111
+
112
+ Equivalently, query for that entry point during selection::
113
+
114
+ >>> (wheel,) = entry_points(group='console_scripts', name='wheel') # doctest: +SKIP
115
+ >>> (wheel,) = entry_points().select(group='console_scripts', name='wheel') # doctest: +SKIP
116
+
117
+ Inspect the resolved entry point::
118
+
91
119
>>> wheel # doctest: +SKIP
92
120
EntryPoint(name='wheel', value='wheel.cli:main', group='console_scripts')
93
121
>>> wheel.module # doctest: +SKIP
@@ -106,6 +134,17 @@ group. Read `the setuptools docs
106
134
<https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins> `_
107
135
for more information on entry points, their definition, and usage.
108
136
137
+ *Compatibility Note *
138
+
139
+ The "selectable" entry points were introduced in ``importlib_metadata ``
140
+ 3.6 and Python 3.10. Prior to those changes, ``entry_points `` accepted
141
+ no parameters and always returned a dictionary of entry points, keyed
142
+ by group. For compatibility, if no parameters are passed to entry_points,
143
+ a ``SelectableGroups `` object is returned, implementing that dict
144
+ interface. In the future, calling ``entry_points `` with no parameters
145
+ will return an ``EntryPoints `` object. Users should rely on the selection
146
+ interface to retrieve entry points by group.
147
+
109
148
110
149
.. _metadata :
111
150
@@ -199,6 +238,8 @@ Python packages or modules::
199
238
>>> packages_distributions()
200
239
{'importlib_metadata': ['importlib-metadata'], 'yaml': ['PyYAML'], 'jaraco': ['jaraco.classes', 'jaraco.functools'], ...}
201
240
241
+ .. versionadded :: 3.10
242
+
202
243
203
244
Distributions
204
245
=============
0 commit comments