Skip to content

Commit 00fbad0

Browse files
authored
Merge pull request #3087 from pypa/debt/remove-pkg-resources
Remove reliance on pkg_resources for entry points
2 parents b28a19d + f4b0e3a commit 00fbad0

File tree

22 files changed

+2797
-61
lines changed

22 files changed

+2797
-61
lines changed

changelog.d/3085.change.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Setuptools no longer relies on ``pkg_resources`` for entry point handling.

setuptools/_entry_points.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import functools
2+
import operator
3+
import itertools
4+
5+
from .extern.jaraco.text import yield_lines
6+
from .extern.jaraco.functools import pass_none
7+
from ._importlib import metadata
8+
from ._itertools import ensure_unique
9+
from .extern.more_itertools import consume
10+
11+
12+
def ensure_valid(ep):
13+
"""
14+
Exercise one of the dynamic properties to trigger
15+
the pattern match.
16+
"""
17+
ep.extras
18+
19+
20+
def load_group(value, group):
21+
"""
22+
Given a value of an entry point or series of entry points,
23+
return each as an EntryPoint.
24+
"""
25+
# normalize to a single sequence of lines
26+
lines = yield_lines(value)
27+
text = f'[{group}]\n' + '\n'.join(lines)
28+
return metadata.EntryPoints._from_text(text)
29+
30+
31+
def by_group_and_name(ep):
32+
return ep.group, ep.name
33+
34+
35+
def validate(eps: metadata.EntryPoints):
36+
"""
37+
Ensure entry points are unique by group and name and validate each.
38+
"""
39+
consume(map(ensure_valid, ensure_unique(eps, key=by_group_and_name)))
40+
return eps
41+
42+
43+
@functools.singledispatch
44+
def load(eps):
45+
"""
46+
Given a Distribution.entry_points, produce EntryPoints.
47+
"""
48+
groups = itertools.chain.from_iterable(
49+
load_group(value, group)
50+
for group, value in eps.items())
51+
return validate(metadata.EntryPoints(groups))
52+
53+
54+
@load.register(str)
55+
def _(eps):
56+
return validate(metadata.EntryPoints._from_text(eps))
57+
58+
59+
load.register(type(None), lambda x: x)
60+
61+
62+
@pass_none
63+
def render(eps: metadata.EntryPoints):
64+
by_group = operator.attrgetter('group')
65+
groups = itertools.groupby(sorted(eps, key=by_group), by_group)
66+
67+
return '\n'.join(
68+
f'[{group}]\n{render_items(items)}\n'
69+
for group, items in groups
70+
)
71+
72+
73+
def render_items(eps):
74+
return '\n'.join(
75+
f'{ep.name} = {ep.value}'
76+
for ep in sorted(eps)
77+
)

setuptools/_itertools.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from setuptools.extern.more_itertools import consume # noqa: F401
2+
3+
4+
# copied from jaraco.itertools 6.1
5+
def ensure_unique(iterable, key=lambda x: x):
6+
"""
7+
Wrap an iterable to raise a ValueError if non-unique values are encountered.
8+
9+
>>> list(ensure_unique('abc'))
10+
['a', 'b', 'c']
11+
>>> consume(ensure_unique('abca'))
12+
Traceback (most recent call last):
13+
...
14+
ValueError: Duplicate element 'a' encountered.
15+
"""
16+
seen = set()
17+
seen_add = seen.add
18+
for element in iterable:
19+
k = key(element)
20+
if k in seen:
21+
raise ValueError(f"Duplicate element {element!r} encountered.")
22+
seen_add(k)
23+
yield element

setuptools/_vendor/importlib_metadata/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import abc
44
import csv
55
import sys
6-
import zipp
6+
from .. import zipp
77
import email
88
import pathlib
99
import operator

setuptools/_vendor/importlib_metadata/_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
try:
99
from typing import Protocol
1010
except ImportError: # pragma: no cover
11-
from typing_extensions import Protocol # type: ignore
11+
from ..typing_extensions import Protocol # type: ignore
1212

1313

1414
def install(cls):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pip
Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
A. HISTORY OF THE SOFTWARE
2+
==========================
3+
4+
Python was created in the early 1990s by Guido van Rossum at Stichting
5+
Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
6+
as a successor of a language called ABC. Guido remains Python's
7+
principal author, although it includes many contributions from others.
8+
9+
In 1995, Guido continued his work on Python at the Corporation for
10+
National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
11+
in Reston, Virginia where he released several versions of the
12+
software.
13+
14+
In May 2000, Guido and the Python core development team moved to
15+
BeOpen.com to form the BeOpen PythonLabs team. In October of the same
16+
year, the PythonLabs team moved to Digital Creations (now Zope
17+
Corporation, see http://www.zope.com). In 2001, the Python Software
18+
Foundation (PSF, see http://www.python.org/psf/) was formed, a
19+
non-profit organization created specifically to own Python-related
20+
Intellectual Property. Zope Corporation is a sponsoring member of
21+
the PSF.
22+
23+
All Python releases are Open Source (see http://www.opensource.org for
24+
the Open Source Definition). Historically, most, but not all, Python
25+
releases have also been GPL-compatible; the table below summarizes
26+
the various releases.
27+
28+
Release Derived Year Owner GPL-
29+
from compatible? (1)
30+
31+
0.9.0 thru 1.2 1991-1995 CWI yes
32+
1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
33+
1.6 1.5.2 2000 CNRI no
34+
2.0 1.6 2000 BeOpen.com no
35+
1.6.1 1.6 2001 CNRI yes (2)
36+
2.1 2.0+1.6.1 2001 PSF no
37+
2.0.1 2.0+1.6.1 2001 PSF yes
38+
2.1.1 2.1+2.0.1 2001 PSF yes
39+
2.1.2 2.1.1 2002 PSF yes
40+
2.1.3 2.1.2 2002 PSF yes
41+
2.2 and above 2.1.1 2001-now PSF yes
42+
43+
Footnotes:
44+
45+
(1) GPL-compatible doesn't mean that we're distributing Python under
46+
the GPL. All Python licenses, unlike the GPL, let you distribute
47+
a modified version without making your changes open source. The
48+
GPL-compatible licenses make it possible to combine Python with
49+
other software that is released under the GPL; the others don't.
50+
51+
(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
52+
because its license has a choice of law clause. According to
53+
CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
54+
is "not incompatible" with the GPL.
55+
56+
Thanks to the many outside volunteers who have worked under Guido's
57+
direction to make these releases possible.
58+
59+
60+
B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
61+
===============================================================
62+
63+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
64+
--------------------------------------------
65+
66+
1. This LICENSE AGREEMENT is between the Python Software Foundation
67+
("PSF"), and the Individual or Organization ("Licensee") accessing and
68+
otherwise using this software ("Python") in source or binary form and
69+
its associated documentation.
70+
71+
2. Subject to the terms and conditions of this License Agreement, PSF hereby
72+
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
73+
analyze, test, perform and/or display publicly, prepare derivative works,
74+
distribute, and otherwise use Python alone or in any derivative version,
75+
provided, however, that PSF's License Agreement and PSF's notice of copyright,
76+
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
77+
2011, 2012, 2013, 2014 Python Software Foundation; All Rights Reserved" are
78+
retained in Python alone or in any derivative version prepared by Licensee.
79+
80+
3. In the event Licensee prepares a derivative work that is based on
81+
or incorporates Python or any part thereof, and wants to make
82+
the derivative work available to others as provided herein, then
83+
Licensee hereby agrees to include in any such work a brief summary of
84+
the changes made to Python.
85+
86+
4. PSF is making Python available to Licensee on an "AS IS"
87+
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
88+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
89+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
90+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
91+
INFRINGE ANY THIRD PARTY RIGHTS.
92+
93+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
94+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
95+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
96+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
97+
98+
6. This License Agreement will automatically terminate upon a material
99+
breach of its terms and conditions.
100+
101+
7. Nothing in this License Agreement shall be deemed to create any
102+
relationship of agency, partnership, or joint venture between PSF and
103+
Licensee. This License Agreement does not grant permission to use PSF
104+
trademarks or trade name in a trademark sense to endorse or promote
105+
products or services of Licensee, or any third party.
106+
107+
8. By copying, installing or otherwise using Python, Licensee
108+
agrees to be bound by the terms and conditions of this License
109+
Agreement.
110+
111+
112+
BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
113+
-------------------------------------------
114+
115+
BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
116+
117+
1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
118+
office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
119+
Individual or Organization ("Licensee") accessing and otherwise using
120+
this software in source or binary form and its associated
121+
documentation ("the Software").
122+
123+
2. Subject to the terms and conditions of this BeOpen Python License
124+
Agreement, BeOpen hereby grants Licensee a non-exclusive,
125+
royalty-free, world-wide license to reproduce, analyze, test, perform
126+
and/or display publicly, prepare derivative works, distribute, and
127+
otherwise use the Software alone or in any derivative version,
128+
provided, however, that the BeOpen Python License is retained in the
129+
Software, alone or in any derivative version prepared by Licensee.
130+
131+
3. BeOpen is making the Software available to Licensee on an "AS IS"
132+
basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
133+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
134+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
135+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
136+
INFRINGE ANY THIRD PARTY RIGHTS.
137+
138+
4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
139+
SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
140+
AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
141+
DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
142+
143+
5. This License Agreement will automatically terminate upon a material
144+
breach of its terms and conditions.
145+
146+
6. This License Agreement shall be governed by and interpreted in all
147+
respects by the law of the State of California, excluding conflict of
148+
law provisions. Nothing in this License Agreement shall be deemed to
149+
create any relationship of agency, partnership, or joint venture
150+
between BeOpen and Licensee. This License Agreement does not grant
151+
permission to use BeOpen trademarks or trade names in a trademark
152+
sense to endorse or promote products or services of Licensee, or any
153+
third party. As an exception, the "BeOpen Python" logos available at
154+
http://www.pythonlabs.com/logos.html may be used according to the
155+
permissions granted on that web page.
156+
157+
7. By copying, installing or otherwise using the software, Licensee
158+
agrees to be bound by the terms and conditions of this License
159+
Agreement.
160+
161+
162+
CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
163+
---------------------------------------
164+
165+
1. This LICENSE AGREEMENT is between the Corporation for National
166+
Research Initiatives, having an office at 1895 Preston White Drive,
167+
Reston, VA 20191 ("CNRI"), and the Individual or Organization
168+
("Licensee") accessing and otherwise using Python 1.6.1 software in
169+
source or binary form and its associated documentation.
170+
171+
2. Subject to the terms and conditions of this License Agreement, CNRI
172+
hereby grants Licensee a nonexclusive, royalty-free, world-wide
173+
license to reproduce, analyze, test, perform and/or display publicly,
174+
prepare derivative works, distribute, and otherwise use Python 1.6.1
175+
alone or in any derivative version, provided, however, that CNRI's
176+
License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
177+
1995-2001 Corporation for National Research Initiatives; All Rights
178+
Reserved" are retained in Python 1.6.1 alone or in any derivative
179+
version prepared by Licensee. Alternately, in lieu of CNRI's License
180+
Agreement, Licensee may substitute the following text (omitting the
181+
quotes): "Python 1.6.1 is made available subject to the terms and
182+
conditions in CNRI's License Agreement. This Agreement together with
183+
Python 1.6.1 may be located on the Internet using the following
184+
unique, persistent identifier (known as a handle): 1895.22/1013. This
185+
Agreement may also be obtained from a proxy server on the Internet
186+
using the following URL: http://hdl.handle.net/1895.22/1013".
187+
188+
3. In the event Licensee prepares a derivative work that is based on
189+
or incorporates Python 1.6.1 or any part thereof, and wants to make
190+
the derivative work available to others as provided herein, then
191+
Licensee hereby agrees to include in any such work a brief summary of
192+
the changes made to Python 1.6.1.
193+
194+
4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
195+
basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
196+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
197+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
198+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
199+
INFRINGE ANY THIRD PARTY RIGHTS.
200+
201+
5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
202+
1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
203+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
204+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
205+
206+
6. This License Agreement will automatically terminate upon a material
207+
breach of its terms and conditions.
208+
209+
7. This License Agreement shall be governed by the federal
210+
intellectual property law of the United States, including without
211+
limitation the federal copyright law, and, to the extent such
212+
U.S. federal law does not apply, by the law of the Commonwealth of
213+
Virginia, excluding Virginia's conflict of law provisions.
214+
Notwithstanding the foregoing, with regard to derivative works based
215+
on Python 1.6.1 that incorporate non-separable material that was
216+
previously distributed under the GNU General Public License (GPL), the
217+
law of the Commonwealth of Virginia shall govern this License
218+
Agreement only as to issues arising under or with respect to
219+
Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
220+
License Agreement shall be deemed to create any relationship of
221+
agency, partnership, or joint venture between CNRI and Licensee. This
222+
License Agreement does not grant permission to use CNRI trademarks or
223+
trade name in a trademark sense to endorse or promote products or
224+
services of Licensee, or any third party.
225+
226+
8. By clicking on the "ACCEPT" button where indicated, or by copying,
227+
installing or otherwise using Python 1.6.1, Licensee agrees to be
228+
bound by the terms and conditions of this License Agreement.
229+
230+
ACCEPT
231+
232+
233+
CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
234+
--------------------------------------------------
235+
236+
Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
237+
The Netherlands. All rights reserved.
238+
239+
Permission to use, copy, modify, and distribute this software and its
240+
documentation for any purpose and without fee is hereby granted,
241+
provided that the above copyright notice appear in all copies and that
242+
both that copyright notice and this permission notice appear in
243+
supporting documentation, and that the name of Stichting Mathematisch
244+
Centrum or CWI not be used in advertising or publicity pertaining to
245+
distribution of the software without specific, written prior
246+
permission.
247+
248+
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
249+
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
250+
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
251+
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
252+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
253+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
254+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

0 commit comments

Comments
 (0)