pip 25.1__py3-none-any.whl → 25.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pip/__init__.py +3 -3
- pip/_internal/__init__.py +2 -2
- pip/_internal/build_env.py +118 -94
- pip/_internal/cache.py +16 -14
- pip/_internal/cli/autocompletion.py +13 -4
- pip/_internal/cli/base_command.py +18 -7
- pip/_internal/cli/cmdoptions.py +14 -9
- pip/_internal/cli/command_context.py +4 -3
- pip/_internal/cli/index_command.py +11 -9
- pip/_internal/cli/main.py +3 -2
- pip/_internal/cli/main_parser.py +4 -3
- pip/_internal/cli/parser.py +26 -22
- pip/_internal/cli/progress_bars.py +19 -12
- pip/_internal/cli/req_command.py +16 -12
- pip/_internal/cli/spinners.py +81 -5
- pip/_internal/commands/__init__.py +5 -3
- pip/_internal/commands/cache.py +18 -15
- pip/_internal/commands/check.py +1 -2
- pip/_internal/commands/completion.py +1 -2
- pip/_internal/commands/configuration.py +26 -18
- pip/_internal/commands/debug.py +8 -6
- pip/_internal/commands/download.py +2 -3
- pip/_internal/commands/freeze.py +2 -3
- pip/_internal/commands/hash.py +1 -2
- pip/_internal/commands/help.py +1 -2
- pip/_internal/commands/index.py +15 -9
- pip/_internal/commands/inspect.py +4 -4
- pip/_internal/commands/install.py +45 -40
- pip/_internal/commands/list.py +35 -26
- pip/_internal/commands/lock.py +1 -2
- pip/_internal/commands/search.py +14 -12
- pip/_internal/commands/show.py +14 -11
- pip/_internal/commands/uninstall.py +1 -2
- pip/_internal/commands/wheel.py +2 -3
- pip/_internal/configuration.py +39 -25
- pip/_internal/distributions/base.py +6 -4
- pip/_internal/distributions/installed.py +8 -4
- pip/_internal/distributions/sdist.py +20 -13
- pip/_internal/distributions/wheel.py +6 -4
- pip/_internal/exceptions.py +58 -39
- pip/_internal/index/collector.py +24 -29
- pip/_internal/index/package_finder.py +70 -61
- pip/_internal/index/sources.py +17 -14
- pip/_internal/locations/__init__.py +18 -16
- pip/_internal/locations/_distutils.py +12 -11
- pip/_internal/locations/_sysconfig.py +5 -4
- pip/_internal/locations/base.py +4 -3
- pip/_internal/main.py +2 -2
- pip/_internal/metadata/__init__.py +8 -6
- pip/_internal/metadata/_json.py +5 -4
- pip/_internal/metadata/base.py +22 -27
- pip/_internal/metadata/importlib/_compat.py +6 -4
- pip/_internal/metadata/importlib/_dists.py +12 -17
- pip/_internal/metadata/importlib/_envs.py +9 -6
- pip/_internal/metadata/pkg_resources.py +11 -14
- pip/_internal/models/direct_url.py +24 -21
- pip/_internal/models/format_control.py +5 -5
- pip/_internal/models/installation_report.py +4 -3
- pip/_internal/models/link.py +39 -34
- pip/_internal/models/pylock.py +27 -22
- pip/_internal/models/search_scope.py +6 -7
- pip/_internal/models/selection_prefs.py +3 -3
- pip/_internal/models/target_python.py +10 -9
- pip/_internal/models/wheel.py +7 -5
- pip/_internal/network/auth.py +20 -22
- pip/_internal/network/cache.py +22 -6
- pip/_internal/network/download.py +169 -141
- pip/_internal/network/lazy_wheel.py +10 -7
- pip/_internal/network/session.py +32 -27
- pip/_internal/network/utils.py +2 -2
- pip/_internal/network/xmlrpc.py +2 -2
- pip/_internal/operations/build/build_tracker.py +10 -8
- pip/_internal/operations/build/wheel.py +3 -2
- pip/_internal/operations/build/wheel_editable.py +3 -2
- pip/_internal/operations/build/wheel_legacy.py +9 -8
- pip/_internal/operations/check.py +21 -26
- pip/_internal/operations/freeze.py +12 -9
- pip/_internal/operations/install/editable_legacy.py +5 -3
- pip/_internal/operations/install/wheel.py +53 -44
- pip/_internal/operations/prepare.py +35 -30
- pip/_internal/pyproject.py +7 -10
- pip/_internal/req/__init__.py +12 -10
- pip/_internal/req/constructors.py +33 -31
- pip/_internal/req/req_dependency_group.py +9 -8
- pip/_internal/req/req_file.py +32 -35
- pip/_internal/req/req_install.py +37 -34
- pip/_internal/req/req_set.py +4 -5
- pip/_internal/req/req_uninstall.py +20 -17
- pip/_internal/resolution/base.py +3 -3
- pip/_internal/resolution/legacy/resolver.py +21 -20
- pip/_internal/resolution/resolvelib/base.py +16 -13
- pip/_internal/resolution/resolvelib/candidates.py +29 -26
- pip/_internal/resolution/resolvelib/factory.py +41 -50
- pip/_internal/resolution/resolvelib/found_candidates.py +11 -9
- pip/_internal/resolution/resolvelib/provider.py +15 -20
- pip/_internal/resolution/resolvelib/reporter.py +5 -3
- pip/_internal/resolution/resolvelib/requirements.py +8 -6
- pip/_internal/resolution/resolvelib/resolver.py +39 -23
- pip/_internal/self_outdated_check.py +8 -6
- pip/_internal/utils/appdirs.py +1 -2
- pip/_internal/utils/compat.py +7 -1
- pip/_internal/utils/compatibility_tags.py +17 -16
- pip/_internal/utils/deprecation.py +11 -9
- pip/_internal/utils/direct_url_helpers.py +2 -2
- pip/_internal/utils/egg_link.py +6 -5
- pip/_internal/utils/entrypoints.py +3 -2
- pip/_internal/utils/filesystem.py +8 -5
- pip/_internal/utils/filetypes.py +4 -6
- pip/_internal/utils/glibc.py +6 -5
- pip/_internal/utils/hashes.py +9 -6
- pip/_internal/utils/logging.py +8 -5
- pip/_internal/utils/misc.py +54 -44
- pip/_internal/utils/packaging.py +3 -2
- pip/_internal/utils/retry.py +7 -4
- pip/_internal/utils/setuptools_build.py +12 -10
- pip/_internal/utils/subprocess.py +20 -17
- pip/_internal/utils/temp_dir.py +10 -12
- pip/_internal/utils/unpacking.py +6 -4
- pip/_internal/utils/urls.py +1 -1
- pip/_internal/utils/virtualenv.py +3 -2
- pip/_internal/utils/wheel.py +3 -4
- pip/_internal/vcs/bazaar.py +26 -8
- pip/_internal/vcs/git.py +59 -24
- pip/_internal/vcs/mercurial.py +34 -11
- pip/_internal/vcs/subversion.py +27 -16
- pip/_internal/vcs/versioncontrol.py +56 -51
- pip/_internal/wheel_builder.py +14 -12
- pip/_vendor/cachecontrol/__init__.py +1 -1
- pip/_vendor/certifi/__init__.py +1 -1
- pip/_vendor/certifi/cacert.pem +102 -221
- pip/_vendor/certifi/core.py +1 -32
- pip/_vendor/dependency_groups/_implementation.py +7 -11
- pip/_vendor/distlib/__init__.py +2 -2
- pip/_vendor/distlib/scripts.py +1 -1
- pip/_vendor/msgpack/__init__.py +2 -2
- pip/_vendor/pkg_resources/__init__.py +1 -1
- pip/_vendor/platformdirs/version.py +2 -2
- pip/_vendor/pygments/__init__.py +1 -1
- pip/_vendor/requests/__version__.py +2 -2
- pip/_vendor/requests/compat.py +12 -0
- pip/_vendor/requests/models.py +3 -1
- pip/_vendor/requests/utils.py +6 -16
- pip/_vendor/resolvelib/__init__.py +3 -3
- pip/_vendor/resolvelib/reporters.py +1 -1
- pip/_vendor/resolvelib/resolvers/__init__.py +4 -4
- pip/_vendor/resolvelib/resolvers/resolution.py +91 -10
- pip/_vendor/rich/__main__.py +12 -40
- pip/_vendor/rich/_inspect.py +1 -1
- pip/_vendor/rich/_ratio.py +1 -7
- pip/_vendor/rich/align.py +1 -7
- pip/_vendor/rich/box.py +1 -7
- pip/_vendor/rich/console.py +25 -20
- pip/_vendor/rich/control.py +1 -7
- pip/_vendor/rich/diagnose.py +1 -0
- pip/_vendor/rich/emoji.py +1 -6
- pip/_vendor/rich/live.py +32 -7
- pip/_vendor/rich/live_render.py +1 -7
- pip/_vendor/rich/logging.py +1 -1
- pip/_vendor/rich/panel.py +3 -4
- pip/_vendor/rich/progress.py +15 -15
- pip/_vendor/rich/spinner.py +7 -13
- pip/_vendor/rich/syntax.py +24 -5
- pip/_vendor/rich/traceback.py +32 -17
- pip/_vendor/truststore/_api.py +1 -1
- pip/_vendor/vendor.txt +10 -11
- {pip-25.1.dist-info → pip-25.2.dist-info}/METADATA +26 -4
- {pip-25.1.dist-info → pip-25.2.dist-info}/RECORD +194 -181
- {pip-25.1.dist-info → pip-25.2.dist-info}/WHEEL +1 -1
- {pip-25.1.dist-info → pip-25.2.dist-info}/licenses/AUTHORS.txt +12 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/cachecontrol/LICENSE.txt +13 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/certifi/LICENSE +20 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/dependency_groups/LICENSE.txt +9 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/distlib/LICENSE.txt +284 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/distro/LICENSE +202 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/idna/LICENSE.md +31 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/msgpack/COPYING +14 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE +3 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.APACHE +177 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/packaging/LICENSE.BSD +23 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/pkg_resources/LICENSE +17 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/platformdirs/LICENSE +21 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/pygments/LICENSE +25 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/pyproject_hooks/LICENSE +21 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/requests/LICENSE +175 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/resolvelib/LICENSE +13 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/rich/LICENSE +19 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/tomli/LICENSE +21 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/tomli/LICENSE-HEADER +3 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/tomli_w/LICENSE +21 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/truststore/LICENSE +21 -0
- pip-25.2.dist-info/licenses/src/pip/_vendor/urllib3/LICENSE.txt +21 -0
- pip/_vendor/distlib/database.py +0 -1329
- pip/_vendor/distlib/index.py +0 -508
- pip/_vendor/distlib/locators.py +0 -1295
- pip/_vendor/distlib/manifest.py +0 -384
- pip/_vendor/distlib/markers.py +0 -162
- pip/_vendor/distlib/metadata.py +0 -1031
- pip/_vendor/distlib/version.py +0 -750
- pip/_vendor/distlib/wheel.py +0 -1100
- pip/_vendor/typing_extensions.py +0 -4584
- {pip-25.1.dist-info → pip-25.2.dist-info}/entry_points.txt +0 -0
- {pip-25.1.dist-info → pip-25.2.dist-info}/licenses/LICENSE.txt +0 -0
- {pip-25.1.dist-info → pip-25.2.dist-info}/top_level.txt +0 -0
pip/_internal/utils/misc.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import errno
|
|
2
4
|
import getpass
|
|
3
5
|
import hashlib
|
|
@@ -9,8 +11,10 @@ import stat
|
|
|
9
11
|
import sys
|
|
10
12
|
import sysconfig
|
|
11
13
|
import urllib.parse
|
|
14
|
+
from collections.abc import Generator, Iterable, Iterator, Mapping, Sequence
|
|
12
15
|
from dataclasses import dataclass
|
|
13
16
|
from functools import partial
|
|
17
|
+
from io import StringIO
|
|
14
18
|
from itertools import filterfalse, tee, zip_longest
|
|
15
19
|
from pathlib import Path
|
|
16
20
|
from types import FunctionType, TracebackType
|
|
@@ -18,17 +22,9 @@ from typing import (
|
|
|
18
22
|
Any,
|
|
19
23
|
BinaryIO,
|
|
20
24
|
Callable,
|
|
21
|
-
Generator,
|
|
22
|
-
Iterable,
|
|
23
|
-
Iterator,
|
|
24
|
-
List,
|
|
25
|
-
Mapping,
|
|
26
25
|
Optional,
|
|
27
|
-
|
|
28
|
-
Tuple,
|
|
29
|
-
Type,
|
|
26
|
+
TextIO,
|
|
30
27
|
TypeVar,
|
|
31
|
-
Union,
|
|
32
28
|
cast,
|
|
33
29
|
)
|
|
34
30
|
|
|
@@ -62,9 +58,9 @@ __all__ = [
|
|
|
62
58
|
logger = logging.getLogger(__name__)
|
|
63
59
|
|
|
64
60
|
T = TypeVar("T")
|
|
65
|
-
ExcInfo =
|
|
66
|
-
VersionInfo =
|
|
67
|
-
NetlocTuple =
|
|
61
|
+
ExcInfo = tuple[type[BaseException], BaseException, TracebackType]
|
|
62
|
+
VersionInfo = tuple[int, int, int]
|
|
63
|
+
NetlocTuple = tuple[str, tuple[Optional[str], Optional[str]]]
|
|
68
64
|
OnExc = Callable[[FunctionType, Path, BaseException], Any]
|
|
69
65
|
OnErr = Callable[[FunctionType, Path, ExcInfo], Any]
|
|
70
66
|
|
|
@@ -78,7 +74,7 @@ def get_pip_version() -> str:
|
|
|
78
74
|
return f"pip {__version__} from {pip_pkg_dir} (python {get_major_minor_version()})"
|
|
79
75
|
|
|
80
76
|
|
|
81
|
-
def normalize_version_info(py_version_info:
|
|
77
|
+
def normalize_version_info(py_version_info: tuple[int, ...]) -> tuple[int, int, int]:
|
|
82
78
|
"""
|
|
83
79
|
Convert a tuple of ints representing a Python version to one of length
|
|
84
80
|
three.
|
|
@@ -121,9 +117,7 @@ def get_prog() -> str:
|
|
|
121
117
|
|
|
122
118
|
# Retry every half second for up to 3 seconds
|
|
123
119
|
@retry(stop_after_delay=3, wait=0.5)
|
|
124
|
-
def rmtree(
|
|
125
|
-
dir: str, ignore_errors: bool = False, onexc: Optional[OnExc] = None
|
|
126
|
-
) -> None:
|
|
120
|
+
def rmtree(dir: str, ignore_errors: bool = False, onexc: OnExc | None = None) -> None:
|
|
127
121
|
if ignore_errors:
|
|
128
122
|
onexc = _onerror_ignore
|
|
129
123
|
if onexc is None:
|
|
@@ -147,7 +141,7 @@ def _onerror_reraise(*_args: Any) -> None:
|
|
|
147
141
|
def rmtree_errorhandler(
|
|
148
142
|
func: FunctionType,
|
|
149
143
|
path: Path,
|
|
150
|
-
exc_info:
|
|
144
|
+
exc_info: ExcInfo | BaseException,
|
|
151
145
|
*,
|
|
152
146
|
onexc: OnExc = _onerror_reraise,
|
|
153
147
|
) -> None:
|
|
@@ -274,7 +268,7 @@ def format_size(bytes: float) -> str:
|
|
|
274
268
|
return f"{int(bytes)} bytes"
|
|
275
269
|
|
|
276
270
|
|
|
277
|
-
def tabulate(rows: Iterable[Iterable[Any]]) ->
|
|
271
|
+
def tabulate(rows: Iterable[Iterable[Any]]) -> tuple[list[str], list[int]]:
|
|
278
272
|
"""Return a list of formatted rows and a list of column sizes.
|
|
279
273
|
|
|
280
274
|
For example::
|
|
@@ -329,7 +323,7 @@ def normalize_path(path: str, resolve_symlinks: bool = True) -> str:
|
|
|
329
323
|
return os.path.normcase(path)
|
|
330
324
|
|
|
331
325
|
|
|
332
|
-
def splitext(path: str) ->
|
|
326
|
+
def splitext(path: str) -> tuple[str, str]:
|
|
333
327
|
"""Like os.path.splitext, but take off .tar too"""
|
|
334
328
|
base, ext = posixpath.splitext(path)
|
|
335
329
|
if base.lower().endswith(".tar"):
|
|
@@ -373,15 +367,31 @@ def write_output(msg: Any, *args: Any) -> None:
|
|
|
373
367
|
logger.info(msg, *args)
|
|
374
368
|
|
|
375
369
|
|
|
370
|
+
class StreamWrapper(StringIO):
|
|
371
|
+
orig_stream: TextIO
|
|
372
|
+
|
|
373
|
+
@classmethod
|
|
374
|
+
def from_stream(cls, orig_stream: TextIO) -> StreamWrapper:
|
|
375
|
+
ret = cls()
|
|
376
|
+
ret.orig_stream = orig_stream
|
|
377
|
+
return ret
|
|
378
|
+
|
|
379
|
+
# compileall.compile_dir() needs stdout.encoding to print to stdout
|
|
380
|
+
# type ignore is because TextIOBase.encoding is writeable
|
|
381
|
+
@property
|
|
382
|
+
def encoding(self) -> str: # type: ignore
|
|
383
|
+
return self.orig_stream.encoding
|
|
384
|
+
|
|
385
|
+
|
|
376
386
|
# Simulates an enum
|
|
377
|
-
def enum(*sequential: Any, **named: Any) ->
|
|
387
|
+
def enum(*sequential: Any, **named: Any) -> type[Any]:
|
|
378
388
|
enums = dict(zip(sequential, range(len(sequential))), **named)
|
|
379
389
|
reverse = {value: key for key, value in enums.items()}
|
|
380
390
|
enums["reverse_mapping"] = reverse
|
|
381
391
|
return type("Enum", (), enums)
|
|
382
392
|
|
|
383
393
|
|
|
384
|
-
def build_netloc(host: str, port:
|
|
394
|
+
def build_netloc(host: str, port: int | None) -> str:
|
|
385
395
|
"""
|
|
386
396
|
Build a netloc from a host-port pair
|
|
387
397
|
"""
|
|
@@ -403,7 +413,7 @@ def build_url_from_netloc(netloc: str, scheme: str = "https") -> str:
|
|
|
403
413
|
return f"{scheme}://{netloc}"
|
|
404
414
|
|
|
405
415
|
|
|
406
|
-
def parse_netloc(netloc: str) ->
|
|
416
|
+
def parse_netloc(netloc: str) -> tuple[str | None, int | None]:
|
|
407
417
|
"""
|
|
408
418
|
Return the host-port pair from a netloc.
|
|
409
419
|
"""
|
|
@@ -425,7 +435,7 @@ def split_auth_from_netloc(netloc: str) -> NetlocTuple:
|
|
|
425
435
|
# behaves if more than one @ is present (which can be checked using
|
|
426
436
|
# the password attribute of urlsplit()'s return value).
|
|
427
437
|
auth, netloc = netloc.rsplit("@", 1)
|
|
428
|
-
pw:
|
|
438
|
+
pw: str | None = None
|
|
429
439
|
if ":" in auth:
|
|
430
440
|
# Split from the left because that's how urllib.parse.urlsplit()
|
|
431
441
|
# behaves if more than one : is present (which again can be checked
|
|
@@ -462,8 +472,8 @@ def redact_netloc(netloc: str) -> str:
|
|
|
462
472
|
|
|
463
473
|
|
|
464
474
|
def _transform_url(
|
|
465
|
-
url: str, transform_netloc: Callable[[str],
|
|
466
|
-
) ->
|
|
475
|
+
url: str, transform_netloc: Callable[[str], tuple[Any, ...]]
|
|
476
|
+
) -> tuple[str, NetlocTuple]:
|
|
467
477
|
"""Transform and replace netloc in a url.
|
|
468
478
|
|
|
469
479
|
transform_netloc is a function taking the netloc and returning a
|
|
@@ -485,13 +495,13 @@ def _get_netloc(netloc: str) -> NetlocTuple:
|
|
|
485
495
|
return split_auth_from_netloc(netloc)
|
|
486
496
|
|
|
487
497
|
|
|
488
|
-
def _redact_netloc(netloc: str) ->
|
|
498
|
+
def _redact_netloc(netloc: str) -> tuple[str]:
|
|
489
499
|
return (redact_netloc(netloc),)
|
|
490
500
|
|
|
491
501
|
|
|
492
502
|
def split_auth_netloc_from_url(
|
|
493
503
|
url: str,
|
|
494
|
-
) ->
|
|
504
|
+
) -> tuple[str, str, tuple[str | None, str | None]]:
|
|
495
505
|
"""
|
|
496
506
|
Parse a url into separate netloc, auth, and url with no auth.
|
|
497
507
|
|
|
@@ -596,7 +606,7 @@ def is_console_interactive() -> bool:
|
|
|
596
606
|
return sys.stdin is not None and sys.stdin.isatty()
|
|
597
607
|
|
|
598
608
|
|
|
599
|
-
def hash_file(path: str, blocksize: int = 1 << 20) ->
|
|
609
|
+
def hash_file(path: str, blocksize: int = 1 << 20) -> tuple[Any, int]:
|
|
600
610
|
"""Return (hash, length) for path using hashlib.sha256()"""
|
|
601
611
|
|
|
602
612
|
h = hashlib.sha256()
|
|
@@ -608,7 +618,7 @@ def hash_file(path: str, blocksize: int = 1 << 20) -> Tuple[Any, int]:
|
|
|
608
618
|
return h, length
|
|
609
619
|
|
|
610
620
|
|
|
611
|
-
def pairwise(iterable: Iterable[Any]) -> Iterator[
|
|
621
|
+
def pairwise(iterable: Iterable[Any]) -> Iterator[tuple[Any, Any]]:
|
|
612
622
|
"""
|
|
613
623
|
Return paired elements.
|
|
614
624
|
|
|
@@ -621,7 +631,7 @@ def pairwise(iterable: Iterable[Any]) -> Iterator[Tuple[Any, Any]]:
|
|
|
621
631
|
|
|
622
632
|
def partition(
|
|
623
633
|
pred: Callable[[T], bool], iterable: Iterable[T]
|
|
624
|
-
) ->
|
|
634
|
+
) -> tuple[Iterable[T], Iterable[T]]:
|
|
625
635
|
"""
|
|
626
636
|
Use a predicate to partition entries into false entries and true entries,
|
|
627
637
|
like
|
|
@@ -638,9 +648,9 @@ class ConfiguredBuildBackendHookCaller(BuildBackendHookCaller):
|
|
|
638
648
|
config_holder: Any,
|
|
639
649
|
source_dir: str,
|
|
640
650
|
build_backend: str,
|
|
641
|
-
backend_path:
|
|
642
|
-
runner:
|
|
643
|
-
python_executable:
|
|
651
|
+
backend_path: str | None = None,
|
|
652
|
+
runner: Callable[..., None] | None = None,
|
|
653
|
+
python_executable: str | None = None,
|
|
644
654
|
):
|
|
645
655
|
super().__init__(
|
|
646
656
|
source_dir, build_backend, backend_path, runner, python_executable
|
|
@@ -650,8 +660,8 @@ class ConfiguredBuildBackendHookCaller(BuildBackendHookCaller):
|
|
|
650
660
|
def build_wheel(
|
|
651
661
|
self,
|
|
652
662
|
wheel_directory: str,
|
|
653
|
-
config_settings:
|
|
654
|
-
metadata_directory:
|
|
663
|
+
config_settings: Mapping[str, Any] | None = None,
|
|
664
|
+
metadata_directory: str | None = None,
|
|
655
665
|
) -> str:
|
|
656
666
|
cs = self.config_holder.config_settings
|
|
657
667
|
return super().build_wheel(
|
|
@@ -661,7 +671,7 @@ class ConfiguredBuildBackendHookCaller(BuildBackendHookCaller):
|
|
|
661
671
|
def build_sdist(
|
|
662
672
|
self,
|
|
663
673
|
sdist_directory: str,
|
|
664
|
-
config_settings:
|
|
674
|
+
config_settings: Mapping[str, Any] | None = None,
|
|
665
675
|
) -> str:
|
|
666
676
|
cs = self.config_holder.config_settings
|
|
667
677
|
return super().build_sdist(sdist_directory, config_settings=cs)
|
|
@@ -669,8 +679,8 @@ class ConfiguredBuildBackendHookCaller(BuildBackendHookCaller):
|
|
|
669
679
|
def build_editable(
|
|
670
680
|
self,
|
|
671
681
|
wheel_directory: str,
|
|
672
|
-
config_settings:
|
|
673
|
-
metadata_directory:
|
|
682
|
+
config_settings: Mapping[str, Any] | None = None,
|
|
683
|
+
metadata_directory: str | None = None,
|
|
674
684
|
) -> str:
|
|
675
685
|
cs = self.config_holder.config_settings
|
|
676
686
|
return super().build_editable(
|
|
@@ -678,19 +688,19 @@ class ConfiguredBuildBackendHookCaller(BuildBackendHookCaller):
|
|
|
678
688
|
)
|
|
679
689
|
|
|
680
690
|
def get_requires_for_build_wheel(
|
|
681
|
-
self, config_settings:
|
|
691
|
+
self, config_settings: Mapping[str, Any] | None = None
|
|
682
692
|
) -> Sequence[str]:
|
|
683
693
|
cs = self.config_holder.config_settings
|
|
684
694
|
return super().get_requires_for_build_wheel(config_settings=cs)
|
|
685
695
|
|
|
686
696
|
def get_requires_for_build_sdist(
|
|
687
|
-
self, config_settings:
|
|
697
|
+
self, config_settings: Mapping[str, Any] | None = None
|
|
688
698
|
) -> Sequence[str]:
|
|
689
699
|
cs = self.config_holder.config_settings
|
|
690
700
|
return super().get_requires_for_build_sdist(config_settings=cs)
|
|
691
701
|
|
|
692
702
|
def get_requires_for_build_editable(
|
|
693
|
-
self, config_settings:
|
|
703
|
+
self, config_settings: Mapping[str, Any] | None = None
|
|
694
704
|
) -> Sequence[str]:
|
|
695
705
|
cs = self.config_holder.config_settings
|
|
696
706
|
return super().get_requires_for_build_editable(config_settings=cs)
|
|
@@ -698,7 +708,7 @@ class ConfiguredBuildBackendHookCaller(BuildBackendHookCaller):
|
|
|
698
708
|
def prepare_metadata_for_build_wheel(
|
|
699
709
|
self,
|
|
700
710
|
metadata_directory: str,
|
|
701
|
-
config_settings:
|
|
711
|
+
config_settings: Mapping[str, Any] | None = None,
|
|
702
712
|
_allow_fallback: bool = True,
|
|
703
713
|
) -> str:
|
|
704
714
|
cs = self.config_holder.config_settings
|
|
@@ -711,9 +721,9 @@ class ConfiguredBuildBackendHookCaller(BuildBackendHookCaller):
|
|
|
711
721
|
def prepare_metadata_for_build_editable(
|
|
712
722
|
self,
|
|
713
723
|
metadata_directory: str,
|
|
714
|
-
config_settings:
|
|
724
|
+
config_settings: Mapping[str, Any] | None = None,
|
|
715
725
|
_allow_fallback: bool = True,
|
|
716
|
-
) ->
|
|
726
|
+
) -> str | None:
|
|
717
727
|
cs = self.config_holder.config_settings
|
|
718
728
|
return super().prepare_metadata_for_build_editable(
|
|
719
729
|
metadata_directory=metadata_directory,
|
pip/_internal/utils/packaging.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import functools
|
|
2
4
|
import logging
|
|
3
|
-
from typing import Optional, Tuple
|
|
4
5
|
|
|
5
6
|
from pip._vendor.packaging import specifiers, version
|
|
6
7
|
from pip._vendor.packaging.requirements import Requirement
|
|
@@ -10,7 +11,7 @@ logger = logging.getLogger(__name__)
|
|
|
10
11
|
|
|
11
12
|
@functools.lru_cache(maxsize=32)
|
|
12
13
|
def check_requires_python(
|
|
13
|
-
requires_python:
|
|
14
|
+
requires_python: str | None, version_info: tuple[int, ...]
|
|
14
15
|
) -> bool:
|
|
15
16
|
"""
|
|
16
17
|
Check if the given Python version matches a "Requires-Python" specifier.
|
pip/_internal/utils/retry.py
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import functools
|
|
2
4
|
from time import perf_counter, sleep
|
|
3
|
-
from typing import Callable, TypeVar
|
|
5
|
+
from typing import TYPE_CHECKING, Callable, TypeVar
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from typing_extensions import ParamSpec
|
|
6
9
|
|
|
7
|
-
T = TypeVar("T")
|
|
8
|
-
P = ParamSpec("P")
|
|
10
|
+
T = TypeVar("T")
|
|
11
|
+
P = ParamSpec("P")
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
def retry(
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import sys
|
|
2
4
|
import textwrap
|
|
3
|
-
from
|
|
5
|
+
from collections.abc import Sequence
|
|
4
6
|
|
|
5
7
|
# Shim to wrap setup.py invocation with setuptools
|
|
6
8
|
# Note that __file__ is handled via two {!r} *and* %r, to ensure that paths on
|
|
@@ -49,10 +51,10 @@ _SETUPTOOLS_SHIM = textwrap.dedent(
|
|
|
49
51
|
|
|
50
52
|
def make_setuptools_shim_args(
|
|
51
53
|
setup_py_path: str,
|
|
52
|
-
global_options:
|
|
54
|
+
global_options: Sequence[str] | None = None,
|
|
53
55
|
no_user_config: bool = False,
|
|
54
56
|
unbuffered_output: bool = False,
|
|
55
|
-
) ->
|
|
57
|
+
) -> list[str]:
|
|
56
58
|
"""
|
|
57
59
|
Get setuptools command arguments with shim wrapped setup file invocation.
|
|
58
60
|
|
|
@@ -78,7 +80,7 @@ def make_setuptools_bdist_wheel_args(
|
|
|
78
80
|
global_options: Sequence[str],
|
|
79
81
|
build_options: Sequence[str],
|
|
80
82
|
destination_dir: str,
|
|
81
|
-
) ->
|
|
83
|
+
) -> list[str]:
|
|
82
84
|
# NOTE: Eventually, we'd want to also -S to the flags here, when we're
|
|
83
85
|
# isolating. Currently, it breaks Python in virtualenvs, because it
|
|
84
86
|
# relies on site.py to find parts of the standard library outside the
|
|
@@ -94,7 +96,7 @@ def make_setuptools_bdist_wheel_args(
|
|
|
94
96
|
def make_setuptools_clean_args(
|
|
95
97
|
setup_py_path: str,
|
|
96
98
|
global_options: Sequence[str],
|
|
97
|
-
) ->
|
|
99
|
+
) -> list[str]:
|
|
98
100
|
args = make_setuptools_shim_args(
|
|
99
101
|
setup_py_path, global_options=global_options, unbuffered_output=True
|
|
100
102
|
)
|
|
@@ -107,10 +109,10 @@ def make_setuptools_develop_args(
|
|
|
107
109
|
*,
|
|
108
110
|
global_options: Sequence[str],
|
|
109
111
|
no_user_config: bool,
|
|
110
|
-
prefix:
|
|
111
|
-
home:
|
|
112
|
+
prefix: str | None,
|
|
113
|
+
home: str | None,
|
|
112
114
|
use_user_site: bool,
|
|
113
|
-
) ->
|
|
115
|
+
) -> list[str]:
|
|
114
116
|
assert not (use_user_site and prefix)
|
|
115
117
|
|
|
116
118
|
args = make_setuptools_shim_args(
|
|
@@ -134,9 +136,9 @@ def make_setuptools_develop_args(
|
|
|
134
136
|
|
|
135
137
|
def make_setuptools_egg_info_args(
|
|
136
138
|
setup_py_path: str,
|
|
137
|
-
egg_info_dir:
|
|
139
|
+
egg_info_dir: str | None,
|
|
138
140
|
no_user_config: bool,
|
|
139
|
-
) ->
|
|
141
|
+
) -> list[str]:
|
|
140
142
|
args = make_setuptools_shim_args(setup_py_path, no_user_config=no_user_config)
|
|
141
143
|
|
|
142
144
|
args += ["egg_info"]
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import logging
|
|
2
4
|
import os
|
|
3
5
|
import shlex
|
|
4
6
|
import subprocess
|
|
5
|
-
from
|
|
7
|
+
from collections.abc import Iterable, Mapping
|
|
8
|
+
from typing import Any, Callable, Literal, Union
|
|
6
9
|
|
|
7
10
|
from pip._vendor.rich.markup import escape
|
|
8
11
|
|
|
@@ -11,10 +14,10 @@ from pip._internal.exceptions import InstallationSubprocessError
|
|
|
11
14
|
from pip._internal.utils.logging import VERBOSE, subprocess_logger
|
|
12
15
|
from pip._internal.utils.misc import HiddenText
|
|
13
16
|
|
|
14
|
-
CommandArgs =
|
|
17
|
+
CommandArgs = list[Union[str, HiddenText]]
|
|
15
18
|
|
|
16
19
|
|
|
17
|
-
def make_command(*args:
|
|
20
|
+
def make_command(*args: str | HiddenText | CommandArgs) -> CommandArgs:
|
|
18
21
|
"""
|
|
19
22
|
Create a CommandArgs object.
|
|
20
23
|
"""
|
|
@@ -31,7 +34,7 @@ def make_command(*args: Union[str, HiddenText, CommandArgs]) -> CommandArgs:
|
|
|
31
34
|
return command_args
|
|
32
35
|
|
|
33
36
|
|
|
34
|
-
def format_command_args(args:
|
|
37
|
+
def format_command_args(args: list[str] | CommandArgs) -> str:
|
|
35
38
|
"""
|
|
36
39
|
Format command arguments for display.
|
|
37
40
|
"""
|
|
@@ -46,7 +49,7 @@ def format_command_args(args: Union[List[str], CommandArgs]) -> str:
|
|
|
46
49
|
)
|
|
47
50
|
|
|
48
51
|
|
|
49
|
-
def reveal_command_args(args:
|
|
52
|
+
def reveal_command_args(args: list[str] | CommandArgs) -> list[str]:
|
|
50
53
|
"""
|
|
51
54
|
Return the arguments in their raw, unredacted form.
|
|
52
55
|
"""
|
|
@@ -54,16 +57,16 @@ def reveal_command_args(args: Union[List[str], CommandArgs]) -> List[str]:
|
|
|
54
57
|
|
|
55
58
|
|
|
56
59
|
def call_subprocess(
|
|
57
|
-
cmd:
|
|
60
|
+
cmd: list[str] | CommandArgs,
|
|
58
61
|
show_stdout: bool = False,
|
|
59
|
-
cwd:
|
|
60
|
-
on_returncode:
|
|
61
|
-
extra_ok_returncodes:
|
|
62
|
-
extra_environ:
|
|
63
|
-
unset_environ:
|
|
64
|
-
spinner:
|
|
65
|
-
log_failed_cmd:
|
|
66
|
-
stdout_only:
|
|
62
|
+
cwd: str | None = None,
|
|
63
|
+
on_returncode: Literal["raise", "warn", "ignore"] = "raise",
|
|
64
|
+
extra_ok_returncodes: Iterable[int] | None = None,
|
|
65
|
+
extra_environ: Mapping[str, Any] | None = None,
|
|
66
|
+
unset_environ: Iterable[str] | None = None,
|
|
67
|
+
spinner: SpinnerInterface | None = None,
|
|
68
|
+
log_failed_cmd: bool | None = True,
|
|
69
|
+
stdout_only: bool | None = False,
|
|
67
70
|
*,
|
|
68
71
|
command_desc: str,
|
|
69
72
|
) -> str:
|
|
@@ -229,9 +232,9 @@ def runner_with_spinner_message(message: str) -> Callable[..., None]:
|
|
|
229
232
|
"""
|
|
230
233
|
|
|
231
234
|
def runner(
|
|
232
|
-
cmd:
|
|
233
|
-
cwd:
|
|
234
|
-
extra_environ:
|
|
235
|
+
cmd: list[str],
|
|
236
|
+
cwd: str | None = None,
|
|
237
|
+
extra_environ: Mapping[str, Any] | None = None,
|
|
235
238
|
) -> None:
|
|
236
239
|
with open_spinner(message) as spinner:
|
|
237
240
|
call_subprocess(
|
pip/_internal/utils/temp_dir.py
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import errno
|
|
2
4
|
import itertools
|
|
3
5
|
import logging
|
|
4
6
|
import os.path
|
|
5
7
|
import tempfile
|
|
6
8
|
import traceback
|
|
9
|
+
from collections.abc import Generator
|
|
7
10
|
from contextlib import ExitStack, contextmanager
|
|
8
11
|
from pathlib import Path
|
|
9
12
|
from typing import (
|
|
10
13
|
Any,
|
|
11
14
|
Callable,
|
|
12
|
-
Dict,
|
|
13
|
-
Generator,
|
|
14
|
-
List,
|
|
15
|
-
Optional,
|
|
16
15
|
TypeVar,
|
|
17
|
-
Union,
|
|
18
16
|
)
|
|
19
17
|
|
|
20
18
|
from pip._internal.utils.misc import enum, rmtree
|
|
@@ -33,7 +31,7 @@ tempdir_kinds = enum(
|
|
|
33
31
|
)
|
|
34
32
|
|
|
35
33
|
|
|
36
|
-
_tempdir_manager:
|
|
34
|
+
_tempdir_manager: ExitStack | None = None
|
|
37
35
|
|
|
38
36
|
|
|
39
37
|
@contextmanager
|
|
@@ -51,7 +49,7 @@ class TempDirectoryTypeRegistry:
|
|
|
51
49
|
"""Manages temp directory behavior"""
|
|
52
50
|
|
|
53
51
|
def __init__(self) -> None:
|
|
54
|
-
self._should_delete:
|
|
52
|
+
self._should_delete: dict[str, bool] = {}
|
|
55
53
|
|
|
56
54
|
def set_delete(self, kind: str, value: bool) -> None:
|
|
57
55
|
"""Indicate whether a TempDirectory of the given kind should be
|
|
@@ -66,7 +64,7 @@ class TempDirectoryTypeRegistry:
|
|
|
66
64
|
return self._should_delete.get(kind, True)
|
|
67
65
|
|
|
68
66
|
|
|
69
|
-
_tempdir_registry:
|
|
67
|
+
_tempdir_registry: TempDirectoryTypeRegistry | None = None
|
|
70
68
|
|
|
71
69
|
|
|
72
70
|
@contextmanager
|
|
@@ -113,8 +111,8 @@ class TempDirectory:
|
|
|
113
111
|
|
|
114
112
|
def __init__(
|
|
115
113
|
self,
|
|
116
|
-
path:
|
|
117
|
-
delete:
|
|
114
|
+
path: str | None = None,
|
|
115
|
+
delete: bool | None | _Default = _default,
|
|
118
116
|
kind: str = "temp",
|
|
119
117
|
globally_managed: bool = False,
|
|
120
118
|
ignore_cleanup_errors: bool = True,
|
|
@@ -184,7 +182,7 @@ class TempDirectory:
|
|
|
184
182
|
if not os.path.exists(self._path):
|
|
185
183
|
return
|
|
186
184
|
|
|
187
|
-
errors:
|
|
185
|
+
errors: list[BaseException] = []
|
|
188
186
|
|
|
189
187
|
def onerror(
|
|
190
188
|
func: Callable[..., Any],
|
|
@@ -245,7 +243,7 @@ class AdjacentTempDirectory(TempDirectory):
|
|
|
245
243
|
# with leading '-' and invalid metadata
|
|
246
244
|
LEADING_CHARS = "-~.=%0123456789"
|
|
247
245
|
|
|
248
|
-
def __init__(self, original: str, delete:
|
|
246
|
+
def __init__(self, original: str, delete: bool | None = None) -> None:
|
|
249
247
|
self.original = original.rstrip("/\\")
|
|
250
248
|
super().__init__(delete=delete)
|
|
251
249
|
|
pip/_internal/utils/unpacking.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Utilities related archives."""
|
|
2
2
|
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
3
5
|
import logging
|
|
4
6
|
import os
|
|
5
7
|
import shutil
|
|
@@ -7,7 +9,7 @@ import stat
|
|
|
7
9
|
import sys
|
|
8
10
|
import tarfile
|
|
9
11
|
import zipfile
|
|
10
|
-
from
|
|
12
|
+
from collections.abc import Iterable
|
|
11
13
|
from zipfile import ZipInfo
|
|
12
14
|
|
|
13
15
|
from pip._internal.exceptions import InstallationError
|
|
@@ -47,7 +49,7 @@ def current_umask() -> int:
|
|
|
47
49
|
return mask
|
|
48
50
|
|
|
49
51
|
|
|
50
|
-
def split_leading_dir(path: str) ->
|
|
52
|
+
def split_leading_dir(path: str) -> list[str]:
|
|
51
53
|
path = path.lstrip("/").lstrip("\\")
|
|
52
54
|
if "/" in path and (
|
|
53
55
|
("\\" in path and path.find("/") < path.find("\\")) or "\\" not in path
|
|
@@ -131,7 +133,7 @@ def unzip_file(filename: str, location: str, flatten: bool = True) -> None:
|
|
|
131
133
|
"outside target directory ({})"
|
|
132
134
|
)
|
|
133
135
|
raise InstallationError(message.format(filename, fn, location))
|
|
134
|
-
if fn.endswith("/"
|
|
136
|
+
if fn.endswith(("/", "\\")):
|
|
135
137
|
# A directory
|
|
136
138
|
ensure_dir(fn)
|
|
137
139
|
else:
|
|
@@ -307,7 +309,7 @@ def _untar_without_filter(
|
|
|
307
309
|
def unpack_file(
|
|
308
310
|
filename: str,
|
|
309
311
|
location: str,
|
|
310
|
-
content_type:
|
|
312
|
+
content_type: str | None = None,
|
|
311
313
|
) -> None:
|
|
312
314
|
filename = os.path.realpath(filename)
|
|
313
315
|
if (
|
pip/_internal/utils/urls.py
CHANGED
|
@@ -12,7 +12,7 @@ def path_to_url(path: str) -> str:
|
|
|
12
12
|
quoted path parts.
|
|
13
13
|
"""
|
|
14
14
|
path = os.path.normpath(os.path.abspath(path))
|
|
15
|
-
url = urllib.parse.urljoin("file
|
|
15
|
+
url = urllib.parse.urljoin("file://", urllib.request.pathname2url(path))
|
|
16
16
|
return url
|
|
17
17
|
|
|
18
18
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import logging
|
|
2
4
|
import os
|
|
3
5
|
import re
|
|
4
6
|
import site
|
|
5
7
|
import sys
|
|
6
|
-
from typing import List, Optional
|
|
7
8
|
|
|
8
9
|
logger = logging.getLogger(__name__)
|
|
9
10
|
_INCLUDE_SYSTEM_SITE_PACKAGES_REGEX = re.compile(
|
|
@@ -33,7 +34,7 @@ def running_under_virtualenv() -> bool:
|
|
|
33
34
|
return _running_under_venv() or _running_under_legacy_virtualenv()
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
def _get_pyvenv_cfg_lines() ->
|
|
37
|
+
def _get_pyvenv_cfg_lines() -> list[str] | None:
|
|
37
38
|
"""Reads {sys.prefix}/pyvenv.cfg and returns its contents as list of lines
|
|
38
39
|
|
|
39
40
|
Returns None, if it could not read/access the file.
|
pip/_internal/utils/wheel.py
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
from email.message import Message
|
|
5
5
|
from email.parser import Parser
|
|
6
|
-
from typing import Tuple
|
|
7
6
|
from zipfile import BadZipFile, ZipFile
|
|
8
7
|
|
|
9
8
|
from pip._vendor.packaging.utils import canonicalize_name
|
|
@@ -16,7 +15,7 @@ VERSION_COMPATIBLE = (1, 0)
|
|
|
16
15
|
logger = logging.getLogger(__name__)
|
|
17
16
|
|
|
18
17
|
|
|
19
|
-
def parse_wheel(wheel_zip: ZipFile, name: str) ->
|
|
18
|
+
def parse_wheel(wheel_zip: ZipFile, name: str) -> tuple[str, Message]:
|
|
20
19
|
"""Extract information from the provided wheel, ensuring it meets basic
|
|
21
20
|
standards.
|
|
22
21
|
|
|
@@ -93,7 +92,7 @@ def wheel_metadata(source: ZipFile, dist_info_dir: str) -> Message:
|
|
|
93
92
|
return Parser().parsestr(wheel_text)
|
|
94
93
|
|
|
95
94
|
|
|
96
|
-
def wheel_version(wheel_data: Message) ->
|
|
95
|
+
def wheel_version(wheel_data: Message) -> tuple[int, ...]:
|
|
97
96
|
"""Given WHEEL metadata, return the parsed Wheel-Version.
|
|
98
97
|
Otherwise, raise UnsupportedWheel.
|
|
99
98
|
"""
|
|
@@ -109,7 +108,7 @@ def wheel_version(wheel_data: Message) -> Tuple[int, ...]:
|
|
|
109
108
|
raise UnsupportedWheel(f"invalid Wheel-Version: {version!r}")
|
|
110
109
|
|
|
111
110
|
|
|
112
|
-
def check_compatibility(version:
|
|
111
|
+
def check_compatibility(version: tuple[int, ...], name: str) -> None:
|
|
113
112
|
"""Raises errors or warns if called with an incompatible Wheel-Version.
|
|
114
113
|
|
|
115
114
|
pip should refuse to install a Wheel-Version that's a major series
|