Skip to content

Commit

Permalink
Upgrade setuptools to 69.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed May 3, 2024
1 parent f9d5e7d commit d24ddc3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 42 deletions.
2 changes: 1 addition & 1 deletion news/setuptools.vendor.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Upgrade setuptools to 69.1.1
Upgrade setuptools to 69.5.1
68 changes: 28 additions & 40 deletions src/pip/_vendor/pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import time
import re
import types
from typing import Protocol
from typing import List, Protocol
import zipfile
import zipimport
import warnings
Expand Down Expand Up @@ -85,9 +85,7 @@
require = None
working_set = None
add_activation_listener = None
resources_stream = None
cleanup_resources = None
resource_dir = None
resource_stream = None
set_extraction_path = None
resource_isdir = None
Expand Down Expand Up @@ -491,19 +489,6 @@ def compatible_platforms(provided, required):
return False


def run_script(dist_spec, script_name):
"""Locate distribution `dist_spec` and run its `script_name` script"""
ns = sys._getframe(1).f_globals
name = ns['__name__']
ns.clear()
ns['__name__'] = name
require(dist_spec)[0].run_script(script_name, ns)


# backward compatibility
run_main = run_script


def get_distribution(dist):
"""Return a current distribution object for a Requirement or string"""
if isinstance(dist, str):
Expand Down Expand Up @@ -531,7 +516,7 @@ def get_entry_info(dist, group, name):


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

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

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

def metadata_listdir(self, name):
Expand All @@ -566,8 +551,8 @@ def get_resource_stream(self, manager, resource_name):
`manager` must be an ``IResourceManager``"""

def get_resource_string(self, manager, resource_name):
"""Return a string containing the contents of `resource_name`
def get_resource_string(self, manager, resource_name) -> bytes:
"""Return the contents of `resource_name` as :obj:`bytes`
`manager` must be an ``IResourceManager``"""

Expand Down Expand Up @@ -1203,8 +1188,8 @@ def resource_stream(self, package_or_requirement, resource_name):
self, resource_name
)

def resource_string(self, package_or_requirement, resource_name):
"""Return specified resource as a string"""
def resource_string(self, package_or_requirement, resource_name) -> bytes:
"""Return specified resource as :obj:`bytes`"""
return get_provider(package_or_requirement).get_resource_string(
self, resource_name
)
Expand Down Expand Up @@ -1339,7 +1324,7 @@ def set_extraction_path(self, path):

self.extraction_path = path

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


def get_default_cache():
Expand Down Expand Up @@ -1479,7 +1465,7 @@ def get_resource_filename(self, manager, resource_name):
def get_resource_stream(self, manager, resource_name):
return io.BytesIO(self.get_resource_string(manager, resource_name))

def get_resource_string(self, manager, resource_name):
def get_resource_string(self, manager, resource_name) -> bytes:
return self._get(self._fn(self.module_path, resource_name))

def has_resource(self, resource_name):
Expand All @@ -1488,9 +1474,9 @@ def has_resource(self, resource_name):
def _get_metadata_path(self, name):
return self._fn(self.egg_info, name)

def has_metadata(self, name):
def has_metadata(self, name) -> bool:
if not self.egg_info:
return self.egg_info
return False

path = self._get_metadata_path(name)
return self._has(path)
Expand All @@ -1514,8 +1500,8 @@ def get_metadata_lines(self, name):
def resource_isdir(self, resource_name):
return self._isdir(self._fn(self.module_path, resource_name))

def metadata_isdir(self, name):
return self.egg_info and self._isdir(self._fn(self.egg_info, name))
def metadata_isdir(self, name) -> bool:
return bool(self.egg_info and self._isdir(self._fn(self.egg_info, name)))

def resource_listdir(self, resource_name):
return self._listdir(self._fn(self.module_path, resource_name))
Expand Down Expand Up @@ -1554,12 +1540,12 @@ def run_script(self, script_name, namespace):
script_code = compile(script_text, script_filename, 'exec')
exec(script_code, namespace, namespace)

def _has(self, path):
def _has(self, path) -> bool:
raise NotImplementedError(
"Can't perform this operation for unregistered loader type"
)

def _isdir(self, path):
def _isdir(self, path) -> bool:
raise NotImplementedError(
"Can't perform this operation for unregistered loader type"
)
Expand Down Expand Up @@ -1649,7 +1635,7 @@ def _validate_resource_path(path):
DeprecationWarning,
)

def _get(self, path):
def _get(self, path) -> bytes:
if hasattr(self.loader, 'get_data'):
return self.loader.get_data(path)
raise NotImplementedError(
Expand Down Expand Up @@ -1694,10 +1680,10 @@ def _set_egg(self, path):
class DefaultProvider(EggProvider):
"""Provides access to package resources in the filesystem"""

def _has(self, path):
def _has(self, path) -> bool:
return os.path.exists(path)

def _isdir(self, path):
def _isdir(self, path) -> bool:
return os.path.isdir(path)

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

def _get(self, path):
def _get(self, path) -> bytes:
with open(path, 'rb') as stream:
return stream.read()

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

_isdir = _has = lambda self, path: False

def _get(self, path):
return ''
def _get(self, path) -> bytes:
return b''

def _listdir(self, path):
return []
Expand Down Expand Up @@ -1939,11 +1925,11 @@ def _index(self):
self._dirindex = ind
return ind

def _has(self, fspath):
def _has(self, fspath) -> bool:
zip_path = self._zipinfo_name(fspath)
return zip_path in self.zipinfo or zip_path in self._index()

def _isdir(self, fspath):
def _isdir(self, fspath) -> bool:
return self._zipinfo_name(fspath) in self._index()

def _listdir(self, fspath):
Expand Down Expand Up @@ -1977,7 +1963,7 @@ def __init__(self, path):
def _get_metadata_path(self, name):
return self.path

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

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


def ensure_directory(path):
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rich==13.7.1
pygments==2.17.2
typing_extensions==4.11.0
resolvelib==1.0.1
setuptools==69.1.1
setuptools==69.5.1
six==1.16.0
tenacity==8.2.3
tomli==2.0.1
Expand Down

0 comments on commit d24ddc3

Please sign in to comment.