@@ -72,15 +72,43 @@ Entry points are represented by ``EntryPoint`` instances;
72
72
each ``EntryPoint `` has a ``.name ``, ``.group ``, and ``.value `` attributes and
73
73
a ``.load() `` method to resolve the value. There are also ``.module ``,
74
74
``.attr ``, and ``.extras `` attributes for getting the components of the
75
- ``.value `` attribute::
75
+ ``.value `` attribute.
76
+
77
+ Query all entry points::
76
78
77
79
>>> eps = entry_points()
80
+
81
+ The ``entry_points() `` function returns an ``EntryPoints `` object,
82
+ a sequence of all ``EntryPoint `` objects with ``names `` and ``groups ``
83
+ attributes for convenience.
84
+
78
85
>>> sorted (eps.groups)
79
86
['console_scripts', 'distutils.commands', 'distutils.setup_keywords', 'egg_info.writers', 'setuptools.installation']
87
+
88
+ ``EntryPoints `` has a ``select `` method to select entry points
89
+ matching specific properties. Select entry points in the
90
+ ``console_scripts `` group::
91
+
80
92
>>> scripts = eps.select(group='console_scripts')
93
+
94
+ Equivalently, since ``entry_points `` passes keyword arguments
95
+ through to select::
96
+
97
+ >>> scripts = entry_points(group='console_scripts')
98
+
99
+ Pick out a specific script named "wheel" (found in the wheel project)::
100
+
81
101
>>> 'wheel' in scripts.names
82
102
True
83
103
>>> wheel = scripts['wheel']
104
+
105
+ Equivalently, query for that entry point during selection::
106
+
107
+ >>> (wheel,) = entry_points(group='console_scripts', name='wheel')
108
+ >>> (wheel,) = entry_points().select(group='console_scripts', name='wheel')
109
+
110
+ Inspect the resolved entry point::
111
+
84
112
>>> wheel
85
113
EntryPoint(name='wheel', value='wheel.cli:main', group='console_scripts')
86
114
>>> wheel.module
@@ -99,6 +127,17 @@ group. Read `the setuptools docs
99
127
<https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins> `_
100
128
for more information on entry points, their definition, and usage.
101
129
130
+ *Compatibility Note *
131
+
132
+ The "selectable" entry points were introduced in ``importlib_metadata ``
133
+ 3.6 and Python 3.10. Prior to those changes, ``entry_points `` accepted
134
+ no parameters and always returned a dictionary of entry points, keyed
135
+ by group. For compatibility, if no parameters are passed to entry_points,
136
+ a ``SelectableGroups `` object is returned, implementing that dict
137
+ interface. In the future, calling ``entry_points `` with no parameters
138
+ will return an ``EntryPoints `` object. Users should rely on the selection
139
+ interface to retrieve entry points by group.
140
+
102
141
103
142
.. _metadata :
104
143
0 commit comments