Skip to content

Commit 60fb233

Browse files
committed
Merge branch 'main' into epp
2 parents 01cf7b4 + a06aa30 commit 60fb233

File tree

12 files changed

+571
-77
lines changed

12 files changed

+571
-77
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[run]
22
omit =
3+
# leading `*/` for pytest-dev/pytest-cov#456
34
*/.tox/*
45
tests/*
56
prepare/*

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = tab
6+
indent_size = 4
7+
insert_final_newline = true
8+
end_of_line = lf
9+
10+
[*.py]
11+
indent_style = space
12+
13+
[*.{yml,yaml}]
14+
indent_style = space
15+
indent_size = 2

CHANGES.rst

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,83 @@
1+
v3.9.0
2+
======
3+
4+
* Use of Mapping (dict) interfaces on ``SelectableGroups``
5+
is now flagged as deprecated. Instead, users are advised
6+
to use the select interface for future compatibility.
7+
8+
Suppress the warning with this filter:
9+
``ignore:SelectableGroups dict interface``.
10+
11+
Or with this invocation in the Python environment:
12+
``warnings.filterwarnings('ignore', 'SelectableGroups dict interface')``.
13+
14+
Preferably, switch to the ``select`` interface introduced
15+
in 3.7.0.
16+
17+
v3.8.0
18+
======
19+
20+
* #290: Add mtime-based caching for ``FastPath`` and its
21+
lookups, dramatically increasing performance for repeated
22+
distribution lookups.
23+
24+
v3.7.3
25+
======
26+
27+
* Docs enhancements and cleanup following review in
28+
`GH-24782 <https://github.com/python/cpython/pull/24782>`_.
29+
30+
v3.7.2
31+
======
32+
33+
* Cleaned up cruft in entry_points docstring.
34+
35+
v3.7.1
36+
======
37+
38+
* Internal refactoring to facilitate ``entry_points() -> dict``
39+
deprecation.
40+
41+
v3.7.0
42+
======
43+
44+
* #131: Added ``packages_distributions`` to conveniently
45+
resolve a top-level package or module to its distribution(s).
46+
47+
v3.6.0
48+
======
49+
50+
* #284: Introduces new ``EntryPoints`` object, a tuple of
51+
``EntryPoint`` objects but with convenience properties for
52+
selecting and inspecting the results:
53+
54+
- ``.select()`` accepts ``group`` or ``name`` keyword
55+
parameters and returns a new ``EntryPoints`` tuple
56+
with only those that match the selection.
57+
- ``.groups`` property presents all of the group names.
58+
- ``.names`` property presents the names of the entry points.
59+
- Item access (e.g. ``eps[name]``) retrieves a single
60+
entry point by name.
61+
62+
``entry_points`` now accepts "selection parameters",
63+
same as ``EntryPoint.select()``.
64+
65+
``entry_points()`` now provides a future-compatible
66+
``SelectableGroups`` object that supplies the above interface
67+
(except item access) but remains a dict for compatibility.
68+
69+
In the future, ``entry_points()`` will return an
70+
``EntryPoints`` object for all entry points.
71+
72+
If passing selection parameters to ``entry_points``, the
73+
future behavior is invoked and an ``EntryPoints`` is the
74+
result.
75+
76+
Construction of entry points using
77+
``dict([EntryPoint, ...])`` is now deprecated and raises
78+
an appropriate DeprecationWarning and will be removed in
79+
a future version.
80+
181
v3.5.0
282
======
383

docs/using.rst

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,48 @@ This package provides the following functionality via its public API.
6767
Entry 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;
7272
each ``EntryPoint`` has a ``.name``, ``.group``, and ``.value`` attributes and
7373
a ``.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>`_
98128
for 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+
183235
Distributions
184236
=============
185237

0 commit comments

Comments
 (0)