Skip to content

Commit d24ddc3

Browse files
committed
Upgrade setuptools to 69.5.1
1 parent f9d5e7d commit d24ddc3

File tree

3 files changed

+30
-42
lines changed

3 files changed

+30
-42
lines changed

news/setuptools.vendor.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Upgrade setuptools to 69.1.1
1+
Upgrade setuptools to 69.5.1

src/pip/_vendor/pkg_resources/__init__.py

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import time
2828
import re
2929
import types
30-
from typing import Protocol
30+
from typing import List, Protocol
3131
import zipfile
3232
import zipimport
3333
import warnings
@@ -85,9 +85,7 @@
8585
require = None
8686
working_set = None
8787
add_activation_listener = None
88-
resources_stream = None
8988
cleanup_resources = None
90-
resource_dir = None
9189
resource_stream = None
9290
set_extraction_path = None
9391
resource_isdir = None
@@ -491,19 +489,6 @@ def compatible_platforms(provided, required):
491489
return False
492490

493491

494-
def run_script(dist_spec, script_name):
495-
"""Locate distribution `dist_spec` and run its `script_name` script"""
496-
ns = sys._getframe(1).f_globals
497-
name = ns['__name__']
498-
ns.clear()
499-
ns['__name__'] = name
500-
require(dist_spec)[0].run_script(script_name, ns)
501-
502-
503-
# backward compatibility
504-
run_main = run_script
505-
506-
507492
def get_distribution(dist):
508493
"""Return a current distribution object for a Requirement or string"""
509494
if isinstance(dist, str):
@@ -531,7 +516,7 @@ def get_entry_info(dist, group, name):
531516

532517

533518
class IMetadataProvider(Protocol):
534-
def has_metadata(self, name):
519+
def has_metadata(self, name) -> bool:
535520
"""Does the package's distribution contain the named metadata?"""
536521

537522
def get_metadata(self, name):
@@ -543,7 +528,7 @@ def get_metadata_lines(self, name):
543528
Leading and trailing whitespace is stripped from each line, and lines
544529
with ``#`` as the first non-blank character are omitted."""
545530

546-
def metadata_isdir(self, name):
531+
def metadata_isdir(self, name) -> bool:
547532
"""Is the named metadata a directory? (like ``os.path.isdir()``)"""
548533

549534
def metadata_listdir(self, name):
@@ -566,8 +551,8 @@ def get_resource_stream(self, manager, resource_name):
566551
567552
`manager` must be an ``IResourceManager``"""
568553

569-
def get_resource_string(self, manager, resource_name):
570-
"""Return a string containing the contents of `resource_name`
554+
def get_resource_string(self, manager, resource_name) -> bytes:
555+
"""Return the contents of `resource_name` as :obj:`bytes`
571556
572557
`manager` must be an ``IResourceManager``"""
573558

@@ -1203,8 +1188,8 @@ def resource_stream(self, package_or_requirement, resource_name):
12031188
self, resource_name
12041189
)
12051190

1206-
def resource_string(self, package_or_requirement, resource_name):
1207-
"""Return specified resource as a string"""
1191+
def resource_string(self, package_or_requirement, resource_name) -> bytes:
1192+
"""Return specified resource as :obj:`bytes`"""
12081193
return get_provider(package_or_requirement).get_resource_string(
12091194
self, resource_name
12101195
)
@@ -1339,7 +1324,7 @@ def set_extraction_path(self, path):
13391324

13401325
self.extraction_path = path
13411326

1342-
def cleanup_resources(self, force=False):
1327+
def cleanup_resources(self, force=False) -> List[str]:
13431328
"""
13441329
Delete all extracted resource files and directories, returning a list
13451330
of the file and directory names that could not be successfully removed.
@@ -1351,6 +1336,7 @@ def cleanup_resources(self, force=False):
13511336
directory used for extractions.
13521337
"""
13531338
# XXX
1339+
return []
13541340

13551341

13561342
def get_default_cache():
@@ -1479,7 +1465,7 @@ def get_resource_filename(self, manager, resource_name):
14791465
def get_resource_stream(self, manager, resource_name):
14801466
return io.BytesIO(self.get_resource_string(manager, resource_name))
14811467

1482-
def get_resource_string(self, manager, resource_name):
1468+
def get_resource_string(self, manager, resource_name) -> bytes:
14831469
return self._get(self._fn(self.module_path, resource_name))
14841470

14851471
def has_resource(self, resource_name):
@@ -1488,9 +1474,9 @@ def has_resource(self, resource_name):
14881474
def _get_metadata_path(self, name):
14891475
return self._fn(self.egg_info, name)
14901476

1491-
def has_metadata(self, name):
1477+
def has_metadata(self, name) -> bool:
14921478
if not self.egg_info:
1493-
return self.egg_info
1479+
return False
14941480

14951481
path = self._get_metadata_path(name)
14961482
return self._has(path)
@@ -1514,8 +1500,8 @@ def get_metadata_lines(self, name):
15141500
def resource_isdir(self, resource_name):
15151501
return self._isdir(self._fn(self.module_path, resource_name))
15161502

1517-
def metadata_isdir(self, name):
1518-
return self.egg_info and self._isdir(self._fn(self.egg_info, name))
1503+
def metadata_isdir(self, name) -> bool:
1504+
return bool(self.egg_info and self._isdir(self._fn(self.egg_info, name)))
15191505

15201506
def resource_listdir(self, resource_name):
15211507
return self._listdir(self._fn(self.module_path, resource_name))
@@ -1554,12 +1540,12 @@ def run_script(self, script_name, namespace):
15541540
script_code = compile(script_text, script_filename, 'exec')
15551541
exec(script_code, namespace, namespace)
15561542

1557-
def _has(self, path):
1543+
def _has(self, path) -> bool:
15581544
raise NotImplementedError(
15591545
"Can't perform this operation for unregistered loader type"
15601546
)
15611547

1562-
def _isdir(self, path):
1548+
def _isdir(self, path) -> bool:
15631549
raise NotImplementedError(
15641550
"Can't perform this operation for unregistered loader type"
15651551
)
@@ -1649,7 +1635,7 @@ def _validate_resource_path(path):
16491635
DeprecationWarning,
16501636
)
16511637

1652-
def _get(self, path):
1638+
def _get(self, path) -> bytes:
16531639
if hasattr(self.loader, 'get_data'):
16541640
return self.loader.get_data(path)
16551641
raise NotImplementedError(
@@ -1694,10 +1680,10 @@ def _set_egg(self, path):
16941680
class DefaultProvider(EggProvider):
16951681
"""Provides access to package resources in the filesystem"""
16961682

1697-
def _has(self, path):
1683+
def _has(self, path) -> bool:
16981684
return os.path.exists(path)
16991685

1700-
def _isdir(self, path):
1686+
def _isdir(self, path) -> bool:
17011687
return os.path.isdir(path)
17021688

17031689
def _listdir(self, path):
@@ -1706,7 +1692,7 @@ def _listdir(self, path):
17061692
def get_resource_stream(self, manager, resource_name):
17071693
return open(self._fn(self.module_path, resource_name), 'rb')
17081694

1709-
def _get(self, path):
1695+
def _get(self, path) -> bytes:
17101696
with open(path, 'rb') as stream:
17111697
return stream.read()
17121698

@@ -1731,8 +1717,8 @@ class EmptyProvider(NullProvider):
17311717

17321718
_isdir = _has = lambda self, path: False
17331719

1734-
def _get(self, path):
1735-
return ''
1720+
def _get(self, path) -> bytes:
1721+
return b''
17361722

17371723
def _listdir(self, path):
17381724
return []
@@ -1939,11 +1925,11 @@ def _index(self):
19391925
self._dirindex = ind
19401926
return ind
19411927

1942-
def _has(self, fspath):
1928+
def _has(self, fspath) -> bool:
19431929
zip_path = self._zipinfo_name(fspath)
19441930
return zip_path in self.zipinfo or zip_path in self._index()
19451931

1946-
def _isdir(self, fspath):
1932+
def _isdir(self, fspath) -> bool:
19471933
return self._zipinfo_name(fspath) in self._index()
19481934

19491935
def _listdir(self, fspath):
@@ -1977,7 +1963,7 @@ def __init__(self, path):
19771963
def _get_metadata_path(self, name):
19781964
return self.path
19791965

1980-
def has_metadata(self, name):
1966+
def has_metadata(self, name) -> bool:
19811967
return name == 'PKG-INFO' and os.path.isfile(self.path)
19821968

19831969
def get_metadata(self, name):
@@ -3207,7 +3193,9 @@ def _find_adapter(registry, ob):
32073193
for t in types:
32083194
if t in registry:
32093195
return registry[t]
3210-
return None
3196+
# _find_adapter would previously return None, and immediately be called.
3197+
# So we're raising a TypeError to keep backward compatibility if anyone depended on that behaviour.
3198+
raise TypeError(f"Could not find adapter for {registry} and {ob}")
32113199

32123200

32133201
def ensure_directory(path):

src/pip/_vendor/vendor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ rich==13.7.1
1616
pygments==2.17.2
1717
typing_extensions==4.11.0
1818
resolvelib==1.0.1
19-
setuptools==69.1.1
19+
setuptools==69.5.1
2020
six==1.16.0
2121
tenacity==8.2.3
2222
tomli==2.0.1

0 commit comments

Comments
 (0)