Skip to content

Commit

Permalink
Upgrade setuptools to 69.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Feb 18, 2024
1 parent e9bb196 commit 5f9da67
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 72 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.0.3
Upgrade setuptools to 69.1.0
113 changes: 46 additions & 67 deletions src/pip/_vendor/pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@
"""

import sys

if sys.version_info < (3, 8):
raise RuntimeError("Python 3.8 or later is required")

import os
import io
import time
import re
import types
from typing import Protocol
import zipfile
import zipimport
import warnings
Expand All @@ -41,18 +46,10 @@
import ntpath
import posixpath
import importlib
import importlib.machinery
from pkgutil import get_importer

try:
import _imp
except ImportError:
# Python 3.2 compatibility
import imp as _imp

try:
FileExistsError
except NameError:
FileExistsError = OSError
import _imp

# capture these to bypass sandboxing
from os import utime
Expand All @@ -68,14 +65,6 @@
from os import open as os_open
from os.path import isdir, split

try:
import importlib.machinery as importlib_machinery

# access attribute to force import under delayed import mechanisms.
importlib_machinery.__name__
except ImportError:
importlib_machinery = None

from pip._internal.utils._jaraco_text import (
yield_lines,
drop_comment,
Expand All @@ -91,9 +80,6 @@
__import__('pip._vendor.packaging.markers')
__import__('pip._vendor.packaging.utils')

if sys.version_info < (3, 5):
raise RuntimeError("Python 3.5 or later is required")

# declare some globals that will be defined later to
# satisfy the linters.
require = None
Expand Down Expand Up @@ -407,20 +393,18 @@ def get_provider(moduleOrReq):
return _find_adapter(_provider_factories, loader)(module)


def _macos_vers(_cache=[]):
if not _cache:
version = platform.mac_ver()[0]
# fallback for MacPorts
if version == '':
plist = '/System/Library/CoreServices/SystemVersion.plist'
if os.path.exists(plist):
if hasattr(plistlib, 'readPlist'):
plist_content = plistlib.readPlist(plist)
if 'ProductVersion' in plist_content:
version = plist_content['ProductVersion']

_cache.append(version.split('.'))
return _cache[0]
@functools.lru_cache(maxsize=None)
def _macos_vers():
version = platform.mac_ver()[0]
# fallback for MacPorts
if version == '':
plist = '/System/Library/CoreServices/SystemVersion.plist'
if os.path.exists(plist):
with open(plist, 'rb') as fh:
plist_content = plistlib.load(fh)
if 'ProductVersion' in plist_content:
version = plist_content['ProductVersion']
return version.split('.')


def _macos_arch(machine):
Expand Down Expand Up @@ -546,54 +530,54 @@ def get_entry_info(dist, group, name):
return get_distribution(dist).get_entry_info(group, name)


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

def get_metadata(name):
def get_metadata(self, name):
"""The named metadata resource as a string"""

def get_metadata_lines(name):
def get_metadata_lines(self, name):
"""Yield named metadata resource as list of non-blank non-comment lines
Leading and trailing whitespace is stripped from each line, and lines
with ``#`` as the first non-blank character are omitted."""

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

def metadata_listdir(name):
def metadata_listdir(self, name):
"""List of metadata names in the directory (like ``os.listdir()``)"""

def run_script(script_name, namespace):
def run_script(self, script_name, namespace):
"""Execute the named script in the supplied namespace dictionary"""


class IResourceProvider(IMetadataProvider):
class IResourceProvider(IMetadataProvider, Protocol):
"""An object that provides access to package resources"""

def get_resource_filename(manager, resource_name):
def get_resource_filename(self, manager, resource_name):
"""Return a true filesystem path for `resource_name`
`manager` must be an ``IResourceManager``"""

def get_resource_stream(manager, resource_name):
def get_resource_stream(self, manager, resource_name):
"""Return a readable file-like object for `resource_name`
`manager` must be an ``IResourceManager``"""

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

def has_resource(resource_name):
def has_resource(self, resource_name):
"""Does the package contain the named resource?"""

def resource_isdir(resource_name):
def resource_isdir(self, resource_name):
"""Is the named resource a directory? (like ``os.path.isdir()``)"""

def resource_listdir(resource_name):
def resource_listdir(self, resource_name):
"""List of resource names in the directory (like ``os.listdir()``)"""


Expand Down Expand Up @@ -1143,8 +1127,7 @@ def obtain(self, requirement, installer=None):
None is returned instead. This method is a hook that allows subclasses
to attempt other ways of obtaining a distribution before falling back
to the `installer` argument."""
if installer is not None:
return installer(requirement)
return installer(requirement) if installer else None

def __iter__(self):
"""Yield the unique project names of the available distributions"""
Expand Down Expand Up @@ -1734,7 +1717,7 @@ def _register(cls):
'SourcelessFileLoader',
)
for name in loader_names:
loader_cls = getattr(importlib_machinery, name, type(None))
loader_cls = getattr(importlib.machinery, name, type(None))
register_loader_type(loader_cls, cls)


Expand Down Expand Up @@ -1895,7 +1878,7 @@ def _extract_resource(self, manager, zip_path): # noqa: C901
try:
rename(tmpnam, real_path)

except os.error:
except OSError:
if os.path.isfile(real_path):
if self._is_current(real_path, zip_path):
# the file became current since it was checked above,
Expand All @@ -1908,7 +1891,7 @@ def _extract_resource(self, manager, zip_path): # noqa: C901
return real_path
raise

except os.error:
except OSError:
# report a user-friendly error
manager.extraction_error()

Expand Down Expand Up @@ -2229,7 +2212,7 @@ def resolve_egg_link(path):
if hasattr(pkgutil, 'ImpImporter'):
register_finder(pkgutil.ImpImporter, find_on_path)

register_finder(importlib_machinery.FileFinder, find_on_path)
register_finder(importlib.machinery.FileFinder, find_on_path)

_declare_state('dict', _namespace_handlers={})
_declare_state('dict', _namespace_packages={})
Expand Down Expand Up @@ -2396,7 +2379,7 @@ def file_ns_handler(importer, path_item, packageName, module):
register_namespace_handler(pkgutil.ImpImporter, file_ns_handler)

register_namespace_handler(zipimport.zipimporter, file_ns_handler)
register_namespace_handler(importlib_machinery.FileFinder, file_ns_handler)
register_namespace_handler(importlib.machinery.FileFinder, file_ns_handler)


def null_ns_handler(importer, path_item, packageName, module):
Expand All @@ -2422,12 +2405,9 @@ def _cygwin_patch(filename): # pragma: nocover
return os.path.abspath(filename) if sys.platform == 'cygwin' else filename


def _normalize_cached(filename, _cache={}):
try:
return _cache[filename]
except KeyError:
_cache[filename] = result = normalize_path(filename)
return result
@functools.lru_cache(maxsize=None)
def _normalize_cached(filename):
return normalize_path(filename)


def _is_egg_path(path):
Expand Down Expand Up @@ -2852,9 +2832,7 @@ def _get_metadata(self, name):

def _get_version(self):
lines = self._get_metadata(self.PKG_INFO)
version = _version_from_file(lines)

return version
return _version_from_file(lines)

def activate(self, path=None, replace=False):
"""Ensure distribution is importable on `path` (default=sys.path)"""
Expand Down Expand Up @@ -2901,7 +2879,7 @@ def __getattr__(self, attr):

def __dir__(self):
return list(
set(super(Distribution, self).__dir__())
set(super().__dir__())
| set(attr for attr in self._provider.__dir__() if not attr.startswith('_'))
)

Expand Down Expand Up @@ -3168,7 +3146,7 @@ class RequirementParseError(packaging.requirements.InvalidRequirement):
class Requirement(packaging.requirements.Requirement):
def __init__(self, requirement_string):
"""DO NOT CALL THIS UNDOCUMENTED METHOD; use Requirement.parse()!"""
super(Requirement, self).__init__(requirement_string)
super().__init__(requirement_string)
self.unsafe_name = self.name
project_name = safe_name(self.name)
self.project_name, self.key = project_name, project_name.lower()
Expand Down Expand Up @@ -3229,6 +3207,7 @@ def _find_adapter(registry, ob):
for t in types:
if t in registry:
return registry[t]
return None


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.0
pygments==2.17.2
typing_extensions==4.9.0
resolvelib==1.0.1
setuptools==69.0.3
setuptools==69.1.0
six==1.16.0
tenacity==8.2.3
tomli==2.0.1
Expand Down
6 changes: 3 additions & 3 deletions tools/vendoring/patches/pkg_resources.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ diff --git a/src/pip/_vendor/pkg_resources/__init__.py b/src/pip/_vendor/pkg_res
index 3f2476a0c..8d5727d35 100644
--- a/src/pip/_vendor/pkg_resources/__init__.py
+++ b/src/pip/_vendor/pkg_resources/__init__.py
@@ -71,7 +71,7 @@
except ImportError:
importlib_machinery = None
@@ -65,7 +65,7 @@
from os import open as os_open
from os.path import isdir, split

-from pkg_resources.extern.jaraco.text import (
+from pip._internal.utils._jaraco_text import (
Expand Down

0 comments on commit 5f9da67

Please sign in to comment.