@@ -67,18 +67,48 @@ This package provides the following functionality via its public API.
6767Entry points
6868------------
6969
70- The ``entry_points() `` function returns a dictionary of all entry points,
71- keyed by group. Entry points are represented by ``EntryPoint `` instances;
70+ The ``entry_points() `` function returns a collection of entry points.
71+ Entry points are represented by ``EntryPoint `` instances;
7272each ``EntryPoint `` has a ``.name ``, ``.group ``, and ``.value `` attributes and
7373a ``.load() `` method to resolve the value. There are also ``.module ``,
7474``.attr ``, and ``.extras `` attributes for getting the components of the
75- ``.value `` attribute::
75+ ``.value `` attribute.
76+
77+ Query all entry points::
7678
7779 >>> eps = entry_points()
78- >>> list(eps)
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+
85+ >>> sorted(eps.groups)
7986 ['console_scripts', 'distutils.commands', 'distutils.setup_keywords', 'egg_info.writers', 'setuptools.installation']
80- >>> scripts = eps['console_scripts']
81- >>> wheel = [ep for ep in scripts if ep.name == 'wheel'][0]
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+
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+
101+ >>> 'wheel' in scripts.names
102+ True
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+
82112 >>> wheel
83113 EntryPoint(name='wheel', value='wheel.cli:main', group='console_scripts')
84114 >>> wheel.module
@@ -97,6 +127,17 @@ group. Read `the setuptools docs
97127<https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins> `_
98128for more information on entry points, their definition, and usage.
99129
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+
100141
101142.. _metadata :
102143
@@ -180,6 +221,17 @@ function::
180221 ["pytest (>=3.0.0) ; extra == 'test'", "pytest-cov ; extra == 'test'"]
181222
182223
224+ Package distributions
225+ ---------------------
226+
227+ A convience method to resolve the distribution or
228+ distributions (in the case of a namespace package) for top-level
229+ Python packages or modules::
230+
231+ >>> packages_distributions()
232+ {'importlib_metadata': ['importlib-metadata'], 'yaml': ['PyYAML'], 'jaraco': ['jaraco.classes', 'jaraco.functools'], ...}
233+
234+
183235Distributions
184236=============
185237
0 commit comments