Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendoring Fall 2024 #6293

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions news/6293.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Vendoring
---------
* Update vendored dependencies:
- importlib-metadata from 8.4.0 to 8.5.0
- packaging from 24.0 to 24.1
- tomli from 2.0.1 to 2.0.2
- tomlkit from 0.12.4 to 0.13.2
- zipp from 3.18.1 to 3.20.2
58 changes: 35 additions & 23 deletions pipenv/vendor/importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
"""
APIs exposing metadata from third-party Python packages.

This codebase is shared between importlib.metadata in the stdlib
and importlib_metadata in PyPI. See
https://github.com/python/importlib_metadata/wiki/Development-Methodology
for more detail.
"""

from __future__ import annotations

import os
import re
import abc
import sys
import json
import pipenv.vendor.zipp as zipp
import collections
import email
import types
import pathlib
import operator
import textwrap
import functools
import itertools
import operator
import os
import pathlib
import posixpath
import collections
import re
import sys
import textwrap
import types
from contextlib import suppress
from importlib import import_module
from importlib.abc import MetaPathFinder
from itertools import starmap
from typing import Any, Iterable, List, Mapping, Match, Optional, Set, cast

from . import _meta
from .compat import py39, py311
from ._collections import FreezableDefaultDict, Pair
from ._compat import (
NullFinder,
Expand All @@ -26,12 +37,7 @@
from ._functools import method_cache, pass_none
from ._itertools import always_iterable, bucket, unique_everseen
from ._meta import PackageMetadata, SimplePath

from contextlib import suppress
from importlib import import_module
from importlib.abc import MetaPathFinder
from itertools import starmap
from typing import Any, Iterable, List, Mapping, Match, Optional, Set, cast
from .compat import py39, py311

__all__ = [
'Distribution',
Expand All @@ -57,7 +63,7 @@ def __str__(self) -> str:
return f"No package metadata was found for {self.name}"

@property
def name(self) -> str: # type: ignore[override]
def name(self) -> str: # type: ignore[override] # make readonly
(name,) = self.args
return name

Expand Down Expand Up @@ -275,7 +281,7 @@ class EntryPoints(tuple):

__slots__ = ()

def __getitem__(self, name: str) -> EntryPoint: # type: ignore[override]
def __getitem__(self, name: str) -> EntryPoint: # type: ignore[override] # Work with str instead of int
"""
Get the EntryPoint in self matching name.
"""
Expand Down Expand Up @@ -331,7 +337,7 @@ class PackagePath(pathlib.PurePosixPath):
size: int
dist: Distribution

def read_text(self, encoding: str = 'utf-8') -> str: # type: ignore[override]
def read_text(self, encoding: str = 'utf-8') -> str:
return self.locate().read_text(encoding=encoding)

def read_binary(self) -> bytes:
Expand Down Expand Up @@ -666,6 +672,9 @@ def origin(self):
return self._load_json('direct_url.json')

def _load_json(self, filename):
# Deferred for performance (python/importlib_metadata#503)
import json

return pass_none(json.loads)(
self.read_text(filename),
object_hook=lambda data: types.SimpleNamespace(**data),
Expand Down Expand Up @@ -750,7 +759,7 @@ class FastPath:
True
"""

@functools.lru_cache() # type: ignore
@functools.lru_cache() # type: ignore[misc]
def __new__(cls, root):
return super().__new__(cls)

Expand All @@ -768,7 +777,10 @@ def children(self):
return []

def zip_children(self):
zip_path = zipp.Path(self.root)
# deferred for performance (python/importlib_metadata#502)
from pipenv.vendor.zipp.compat.overlay import zipfile

zip_path = zipfile.Path(self.root)
names = zip_path.root.namelist()
self.joinpath = zip_path.joinpath

Expand Down Expand Up @@ -1108,7 +1120,7 @@ def _get_toplevel_name(name: PackagePath) -> str:
# Defer import of inspect for performance (python/cpython#118761)
import inspect

return _topmost(name) or (inspect.getmodulename(name) or str(name))
return _topmost(name) or inspect.getmodulename(name) or str(name)


def _top_level_inferred(dist):
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/importlib_metadata/_adapters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import email.message
import re
import textwrap
import email.message

from ._text import FoldedCase

Expand Down
3 changes: 1 addition & 2 deletions pipenv/vendor/importlib_metadata/_compat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
import platform

import sys

__all__ = ['install', 'NullFinder']

Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/importlib_metadata/_functools.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import types
import functools
import types


# from jaraco.functools 3.3
Expand Down
14 changes: 11 additions & 3 deletions pipenv/vendor/importlib_metadata/_meta.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
from __future__ import annotations

import os
from typing import Protocol
from typing import Any, Dict, Iterator, List, Optional, TypeVar, Union, overload

from typing import (
Any,
Dict,
Iterator,
List,
Optional,
Protocol,
TypeVar,
Union,
overload,
)

_T = TypeVar("_T")

Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/packaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__summary__ = "Core utilities for Python packages"
__uri__ = "https://github.com/pypa/packaging"

__version__ = "24.0"
__version__ = "24.1"

__author__ = "Donald Stufft and individual contributors"
__email__ = "[email protected]"
Expand Down
8 changes: 5 additions & 3 deletions pipenv/vendor/packaging/_elffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
ELF header: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html
"""

from __future__ import annotations

import enum
import os
import struct
from typing import IO, Optional, Tuple
from typing import IO


class ELFInvalid(ValueError):
Expand Down Expand Up @@ -87,11 +89,11 @@ def __init__(self, f: IO[bytes]) -> None:
except struct.error as e:
raise ELFInvalid("unable to parse machine and section information") from e

def _read(self, fmt: str) -> Tuple[int, ...]:
def _read(self, fmt: str) -> tuple[int, ...]:
return struct.unpack(fmt, self._f.read(struct.calcsize(fmt)))

@property
def interpreter(self) -> Optional[str]:
def interpreter(self) -> str | None:
"""
The path recorded in the ``PT_INTERP`` section header.
"""
Expand Down
22 changes: 12 additions & 10 deletions pipenv/vendor/packaging/_manylinux.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from __future__ import annotations

import collections
import contextlib
import functools
import os
import re
import sys
import warnings
from typing import Dict, Generator, Iterator, NamedTuple, Optional, Sequence, Tuple
from typing import Generator, Iterator, NamedTuple, Sequence

from ._elffile import EIClass, EIData, ELFFile, EMachine

Expand All @@ -17,7 +19,7 @@
# `os.PathLike` not a generic type until Python 3.9, so sticking with `str`
# as the type for `path` until then.
@contextlib.contextmanager
def _parse_elf(path: str) -> Generator[Optional[ELFFile], None, None]:
def _parse_elf(path: str) -> Generator[ELFFile | None, None, None]:
try:
with open(path, "rb") as f:
yield ELFFile(f)
Expand Down Expand Up @@ -72,15 +74,15 @@ def _have_compatible_abi(executable: str, archs: Sequence[str]) -> bool:
# For now, guess what the highest minor version might be, assume it will
# be 50 for testing. Once this actually happens, update the dictionary
# with the actual value.
_LAST_GLIBC_MINOR: Dict[int, int] = collections.defaultdict(lambda: 50)
_LAST_GLIBC_MINOR: dict[int, int] = collections.defaultdict(lambda: 50)


class _GLibCVersion(NamedTuple):
major: int
minor: int


def _glibc_version_string_confstr() -> Optional[str]:
def _glibc_version_string_confstr() -> str | None:
"""
Primary implementation of glibc_version_string using os.confstr.
"""
Expand All @@ -90,7 +92,7 @@ def _glibc_version_string_confstr() -> Optional[str]:
# https://github.com/python/cpython/blob/fcf1d003bf4f0100c/Lib/platform.py#L175-L183
try:
# Should be a string like "glibc 2.17".
version_string: Optional[str] = os.confstr("CS_GNU_LIBC_VERSION")
version_string: str | None = os.confstr("CS_GNU_LIBC_VERSION")
assert version_string is not None
_, version = version_string.rsplit()
except (AssertionError, AttributeError, OSError, ValueError):
Expand All @@ -99,7 +101,7 @@ def _glibc_version_string_confstr() -> Optional[str]:
return version


def _glibc_version_string_ctypes() -> Optional[str]:
def _glibc_version_string_ctypes() -> str | None:
"""
Fallback implementation of glibc_version_string using ctypes.
"""
Expand Down Expand Up @@ -143,12 +145,12 @@ def _glibc_version_string_ctypes() -> Optional[str]:
return version_str


def _glibc_version_string() -> Optional[str]:
def _glibc_version_string() -> str | None:
"""Returns glibc version string, or None if not using glibc."""
return _glibc_version_string_confstr() or _glibc_version_string_ctypes()


def _parse_glibc_version(version_str: str) -> Tuple[int, int]:
def _parse_glibc_version(version_str: str) -> tuple[int, int]:
"""Parse glibc version.

We use a regexp instead of str.split because we want to discard any
Expand All @@ -167,8 +169,8 @@ def _parse_glibc_version(version_str: str) -> Tuple[int, int]:
return int(m.group("major")), int(m.group("minor"))


@functools.lru_cache()
def _get_glibc_version() -> Tuple[int, int]:
@functools.lru_cache
def _get_glibc_version() -> tuple[int, int]:
version_str = _glibc_version_string()
if version_str is None:
return (-1, -1)
Expand Down
10 changes: 6 additions & 4 deletions pipenv/vendor/packaging/_musllinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
linked against musl, and what musl version is used.
"""

from __future__ import annotations

import functools
import re
import subprocess
import sys
from typing import Iterator, NamedTuple, Optional, Sequence
from typing import Iterator, NamedTuple, Sequence

from ._elffile import ELFFile

Expand All @@ -18,7 +20,7 @@ class _MuslVersion(NamedTuple):
minor: int


def _parse_musl_version(output: str) -> Optional[_MuslVersion]:
def _parse_musl_version(output: str) -> _MuslVersion | None:
lines = [n for n in (n.strip() for n in output.splitlines()) if n]
if len(lines) < 2 or lines[0][:4] != "musl":
return None
Expand All @@ -28,8 +30,8 @@ def _parse_musl_version(output: str) -> Optional[_MuslVersion]:
return _MuslVersion(major=int(m.group(1)), minor=int(m.group(2)))


@functools.lru_cache()
def _get_musl_version(executable: str) -> Optional[_MuslVersion]:
@functools.lru_cache
def _get_musl_version(executable: str) -> _MuslVersion | None:
"""Detect currently-running musl runtime version.

This is done by checking the specified executable's dynamic linking
Expand Down
Loading
Loading