Skip to content

Commit 8c49113

Browse files
matteiusoz123
authored andcommitted
perform fall vendoring
1 parent 5556e52 commit 8c49113

32 files changed

+544
-384
lines changed

pipenv/vendor/importlib_metadata/__init__.py

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
1+
"""
2+
APIs exposing metadata from third-party Python packages.
3+
4+
This codebase is shared between importlib.metadata in the stdlib
5+
and importlib_metadata in PyPI. See
6+
https://github.com/python/importlib_metadata/wiki/Development-Methodology
7+
for more detail.
8+
"""
9+
110
from __future__ import annotations
211

3-
import os
4-
import re
512
import abc
6-
import sys
7-
import json
8-
import pipenv.vendor.zipp as zipp
13+
import collections
914
import email
10-
import types
11-
import pathlib
12-
import operator
13-
import textwrap
1415
import functools
1516
import itertools
17+
import operator
18+
import os
19+
import pathlib
1620
import posixpath
17-
import collections
21+
import re
22+
import sys
23+
import textwrap
24+
import types
25+
from contextlib import suppress
26+
from importlib import import_module
27+
from importlib.abc import MetaPathFinder
28+
from itertools import starmap
29+
from typing import Any, Iterable, List, Mapping, Match, Optional, Set, cast
1830

1931
from . import _meta
20-
from .compat import py39, py311
2132
from ._collections import FreezableDefaultDict, Pair
2233
from ._compat import (
2334
NullFinder,
@@ -26,12 +37,7 @@
2637
from ._functools import method_cache, pass_none
2738
from ._itertools import always_iterable, bucket, unique_everseen
2839
from ._meta import PackageMetadata, SimplePath
29-
30-
from contextlib import suppress
31-
from importlib import import_module
32-
from importlib.abc import MetaPathFinder
33-
from itertools import starmap
34-
from typing import Any, Iterable, List, Mapping, Match, Optional, Set, cast
40+
from .compat import py39, py311
3541

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

5965
@property
60-
def name(self) -> str: # type: ignore[override]
66+
def name(self) -> str: # type: ignore[override] # make readonly
6167
(name,) = self.args
6268
return name
6369

@@ -275,7 +281,7 @@ class EntryPoints(tuple):
275281

276282
__slots__ = ()
277283

278-
def __getitem__(self, name: str) -> EntryPoint: # type: ignore[override]
284+
def __getitem__(self, name: str) -> EntryPoint: # type: ignore[override] # Work with str instead of int
279285
"""
280286
Get the EntryPoint in self matching name.
281287
"""
@@ -331,7 +337,7 @@ class PackagePath(pathlib.PurePosixPath):
331337
size: int
332338
dist: Distribution
333339

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

337343
def read_binary(self) -> bytes:
@@ -666,6 +672,9 @@ def origin(self):
666672
return self._load_json('direct_url.json')
667673

668674
def _load_json(self, filename):
675+
# Deferred for performance (python/importlib_metadata#503)
676+
import json
677+
669678
return pass_none(json.loads)(
670679
self.read_text(filename),
671680
object_hook=lambda data: types.SimpleNamespace(**data),
@@ -750,7 +759,7 @@ class FastPath:
750759
True
751760
"""
752761

753-
@functools.lru_cache() # type: ignore
762+
@functools.lru_cache() # type: ignore[misc]
754763
def __new__(cls, root):
755764
return super().__new__(cls)
756765

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

770779
def zip_children(self):
771-
zip_path = zipp.Path(self.root)
780+
# deferred for performance (python/importlib_metadata#502)
781+
from pipenv.vendor.zipp.compat.overlay import zipfile
782+
783+
zip_path = zipfile.Path(self.root)
772784
names = zip_path.root.namelist()
773785
self.joinpath = zip_path.joinpath
774786

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

1111-
return _topmost(name) or (inspect.getmodulename(name) or str(name))
1123+
return _topmost(name) or inspect.getmodulename(name) or str(name)
11121124

11131125

11141126
def _top_level_inferred(dist):

pipenv/vendor/importlib_metadata/_adapters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import email.message
12
import re
23
import textwrap
3-
import email.message
44

55
from ._text import FoldedCase
66

pipenv/vendor/importlib_metadata/_compat.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import sys
21
import platform
3-
2+
import sys
43

54
__all__ = ['install', 'NullFinder']
65

pipenv/vendor/importlib_metadata/_functools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import types
21
import functools
2+
import types
33

44

55
# from jaraco.functools 3.3

pipenv/vendor/importlib_metadata/_meta.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
from __future__ import annotations
22

33
import os
4-
from typing import Protocol
5-
from typing import Any, Dict, Iterator, List, Optional, TypeVar, Union, overload
6-
4+
from typing import (
5+
Any,
6+
Dict,
7+
Iterator,
8+
List,
9+
Optional,
10+
Protocol,
11+
TypeVar,
12+
Union,
13+
overload,
14+
)
715

816
_T = TypeVar("_T")
917

pipenv/vendor/packaging/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
__summary__ = "Core utilities for Python packages"
77
__uri__ = "https://github.com/pypa/packaging"
88

9-
__version__ = "24.0"
9+
__version__ = "24.1"
1010

1111
__author__ = "Donald Stufft and individual contributors"
1212
__email__ = "donald@stufft.io"

pipenv/vendor/packaging/_elffile.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
ELF header: https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html
99
"""
1010

11+
from __future__ import annotations
12+
1113
import enum
1214
import os
1315
import struct
14-
from typing import IO, Optional, Tuple
16+
from typing import IO
1517

1618

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

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

9395
@property
94-
def interpreter(self) -> Optional[str]:
96+
def interpreter(self) -> str | None:
9597
"""
9698
The path recorded in the ``PT_INTERP`` section header.
9799
"""

pipenv/vendor/packaging/_manylinux.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
from __future__ import annotations
2+
13
import collections
24
import contextlib
35
import functools
46
import os
57
import re
68
import sys
79
import warnings
8-
from typing import Dict, Generator, Iterator, NamedTuple, Optional, Sequence, Tuple
10+
from typing import Generator, Iterator, NamedTuple, Sequence
911

1012
from ._elffile import EIClass, EIData, ELFFile, EMachine
1113

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

7779

7880
class _GLibCVersion(NamedTuple):
7981
major: int
8082
minor: int
8183

8284

83-
def _glibc_version_string_confstr() -> Optional[str]:
85+
def _glibc_version_string_confstr() -> str | None:
8486
"""
8587
Primary implementation of glibc_version_string using os.confstr.
8688
"""
@@ -90,7 +92,7 @@ def _glibc_version_string_confstr() -> Optional[str]:
9092
# https://github.com/python/cpython/blob/fcf1d003bf4f0100c/Lib/platform.py#L175-L183
9193
try:
9294
# Should be a string like "glibc 2.17".
93-
version_string: Optional[str] = os.confstr("CS_GNU_LIBC_VERSION")
95+
version_string: str | None = os.confstr("CS_GNU_LIBC_VERSION")
9496
assert version_string is not None
9597
_, version = version_string.rsplit()
9698
except (AssertionError, AttributeError, OSError, ValueError):
@@ -99,7 +101,7 @@ def _glibc_version_string_confstr() -> Optional[str]:
99101
return version
100102

101103

102-
def _glibc_version_string_ctypes() -> Optional[str]:
104+
def _glibc_version_string_ctypes() -> str | None:
103105
"""
104106
Fallback implementation of glibc_version_string using ctypes.
105107
"""
@@ -143,12 +145,12 @@ def _glibc_version_string_ctypes() -> Optional[str]:
143145
return version_str
144146

145147

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

150152

151-
def _parse_glibc_version(version_str: str) -> Tuple[int, int]:
153+
def _parse_glibc_version(version_str: str) -> tuple[int, int]:
152154
"""Parse glibc version.
153155
154156
We use a regexp instead of str.split because we want to discard any
@@ -167,8 +169,8 @@ def _parse_glibc_version(version_str: str) -> Tuple[int, int]:
167169
return int(m.group("major")), int(m.group("minor"))
168170

169171

170-
@functools.lru_cache()
171-
def _get_glibc_version() -> Tuple[int, int]:
172+
@functools.lru_cache
173+
def _get_glibc_version() -> tuple[int, int]:
172174
version_str = _glibc_version_string()
173175
if version_str is None:
174176
return (-1, -1)

pipenv/vendor/packaging/_musllinux.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
linked against musl, and what musl version is used.
55
"""
66

7+
from __future__ import annotations
8+
79
import functools
810
import re
911
import subprocess
1012
import sys
11-
from typing import Iterator, NamedTuple, Optional, Sequence
13+
from typing import Iterator, NamedTuple, Sequence
1214

1315
from ._elffile import ELFFile
1416

@@ -18,7 +20,7 @@ class _MuslVersion(NamedTuple):
1820
minor: int
1921

2022

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

3032

31-
@functools.lru_cache()
32-
def _get_musl_version(executable: str) -> Optional[_MuslVersion]:
33+
@functools.lru_cache
34+
def _get_musl_version(executable: str) -> _MuslVersion | None:
3335
"""Detect currently-running musl runtime version.
3436
3537
This is done by checking the specified executable's dynamic linking

0 commit comments

Comments
 (0)