Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .venv/lib/python3.12/site-packages/pip/_internal/cli/__pycache__/autocompletion.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/debug.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/index.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/inspect.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/install.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/list.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/lock.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/search.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/show.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/uninstall.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/wheel.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/distributions/__pycache__/__init__.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/distributions/__pycache__/base.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/distributions/__pycache__/installed.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/distributions/__pycache__/sdist.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/distributions/__pycache__/wheel.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/index/__pycache__/__init__.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/index/__pycache__/collector.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/index/__pycache__/package_finder.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/index/__pycache__/sources.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/locations/__pycache__/__init__.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/locations/__pycache__/_distutils.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/locations/__pycache__/_sysconfig.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/locations/__pycache__/base.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/__pycache__/__init__.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/__pycache__/_json.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/__pycache__/base.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/__pycache__/pkg_resources.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__init__.py +6 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__pycache__/__init__.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__pycache__/_compat.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__pycache__/_dists.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__pycache__/_envs.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_compat.py +87 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_dists.py +229 -0
- .venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py +143 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/__init__.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/candidate.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/direct_url.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/format_control.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/index.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/installation_report.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/link.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/release_control.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/scheme.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/search_scope.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/selection_prefs.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/target_python.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/wheel.cpython-312.pyc +0 -0
- .venv/lib/python3.12/site-packages/pip/_internal/network/__pycache__/__init__.cpython-312.pyc +0 -0
.venv/lib/python3.12/site-packages/pip/_internal/cli/__pycache__/autocompletion.cpython-312.pyc
ADDED
|
Binary file (9.09 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/debug.cpython-312.pyc
ADDED
|
Binary file (9.96 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/index.cpython-312.pyc
ADDED
|
Binary file (7.46 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/inspect.cpython-312.pyc
ADDED
|
Binary file (3.94 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/install.cpython-312.pyc
ADDED
|
Binary file (30 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/list.cpython-312.pyc
ADDED
|
Binary file (17.2 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/lock.cpython-312.pyc
ADDED
|
Binary file (7.98 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/search.cpython-312.pyc
ADDED
|
Binary file (7.6 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/show.cpython-312.pyc
ADDED
|
Binary file (11.2 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/uninstall.cpython-312.pyc
ADDED
|
Binary file (4.67 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/commands/__pycache__/wheel.cpython-312.pyc
ADDED
|
Binary file (8.21 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/distributions/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (936 Bytes). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/distributions/__pycache__/base.cpython-312.pyc
ADDED
|
Binary file (2.91 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/distributions/__pycache__/installed.cpython-312.pyc
ADDED
|
Binary file (1.76 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/distributions/__pycache__/sdist.cpython-312.pyc
ADDED
|
Binary file (8.32 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/distributions/__pycache__/wheel.cpython-312.pyc
ADDED
|
Binary file (2.31 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/index/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (224 Bytes). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/index/__pycache__/collector.cpython-312.pyc
ADDED
|
Binary file (21.1 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/index/__pycache__/package_finder.cpython-312.pyc
ADDED
|
Binary file (44.5 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/index/__pycache__/sources.cpython-312.pyc
ADDED
|
Binary file (12.3 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/locations/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (15.3 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/locations/__pycache__/_distutils.cpython-312.pyc
ADDED
|
Binary file (6.77 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/locations/__pycache__/_sysconfig.cpython-312.pyc
ADDED
|
Binary file (8.03 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/locations/__pycache__/base.cpython-312.pyc
ADDED
|
Binary file (3.7 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (6.76 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/__pycache__/_json.cpython-312.pyc
ADDED
|
Binary file (2.87 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/__pycache__/base.cpython-312.pyc
ADDED
|
Binary file (34.4 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/__pycache__/pkg_resources.cpython-312.pyc
ADDED
|
Binary file (15.8 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__init__.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ._dists import Distribution
|
| 2 |
+
from ._envs import Environment
|
| 3 |
+
|
| 4 |
+
__all__ = ["NAME", "Distribution", "Environment"]
|
| 5 |
+
|
| 6 |
+
NAME = "importlib"
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (353 Bytes). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__pycache__/_compat.cpython-312.pyc
ADDED
|
Binary file (4.23 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__pycache__/_dists.cpython-312.pyc
ADDED
|
Binary file (12.8 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__pycache__/_envs.cpython-312.pyc
ADDED
|
Binary file (8 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_compat.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import importlib.metadata
|
| 4 |
+
import os
|
| 5 |
+
from typing import Any, Protocol, cast
|
| 6 |
+
|
| 7 |
+
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class BadMetadata(ValueError):
|
| 11 |
+
def __init__(self, dist: importlib.metadata.Distribution, *, reason: str) -> None:
|
| 12 |
+
self.dist = dist
|
| 13 |
+
self.reason = reason
|
| 14 |
+
|
| 15 |
+
def __str__(self) -> str:
|
| 16 |
+
return f"Bad metadata in {self.dist} ({self.reason})"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class BasePath(Protocol):
|
| 20 |
+
"""A protocol that various path objects conform.
|
| 21 |
+
|
| 22 |
+
This exists because importlib.metadata uses both ``pathlib.Path`` and
|
| 23 |
+
``zipfile.Path``, and we need a common base for type hints (Union does not
|
| 24 |
+
work well since ``zipfile.Path`` is too new for our linter setup).
|
| 25 |
+
|
| 26 |
+
This does not mean to be exhaustive, but only contains things that present
|
| 27 |
+
in both classes *that we need*.
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
@property
|
| 31 |
+
def name(self) -> str:
|
| 32 |
+
raise NotImplementedError()
|
| 33 |
+
|
| 34 |
+
@property
|
| 35 |
+
def parent(self) -> BasePath:
|
| 36 |
+
raise NotImplementedError()
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def get_info_location(d: importlib.metadata.Distribution) -> BasePath | None:
|
| 40 |
+
"""Find the path to the distribution's metadata directory.
|
| 41 |
+
|
| 42 |
+
HACK: This relies on importlib.metadata's private ``_path`` attribute. Not
|
| 43 |
+
all distributions exist on disk, so importlib.metadata is correct to not
|
| 44 |
+
expose the attribute as public. But pip's code base is old and not as clean,
|
| 45 |
+
so we do this to avoid having to rewrite too many things. Hopefully we can
|
| 46 |
+
eliminate this some day.
|
| 47 |
+
"""
|
| 48 |
+
return getattr(d, "_path", None)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def parse_name_and_version_from_info_directory(
|
| 52 |
+
dist: importlib.metadata.Distribution,
|
| 53 |
+
) -> tuple[str | None, str | None]:
|
| 54 |
+
"""Get a name and version from the metadata directory name.
|
| 55 |
+
|
| 56 |
+
This is much faster than reading distribution metadata.
|
| 57 |
+
"""
|
| 58 |
+
info_location = get_info_location(dist)
|
| 59 |
+
if info_location is None:
|
| 60 |
+
return None, None
|
| 61 |
+
|
| 62 |
+
stem, suffix = os.path.splitext(info_location.name)
|
| 63 |
+
if suffix == ".dist-info":
|
| 64 |
+
name, sep, version = stem.partition("-")
|
| 65 |
+
if sep:
|
| 66 |
+
return name, version
|
| 67 |
+
|
| 68 |
+
if suffix == ".egg-info":
|
| 69 |
+
name = stem.split("-", 1)[0]
|
| 70 |
+
return name, None
|
| 71 |
+
|
| 72 |
+
return None, None
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def get_dist_canonical_name(dist: importlib.metadata.Distribution) -> NormalizedName:
|
| 76 |
+
"""Get the distribution's normalized name.
|
| 77 |
+
|
| 78 |
+
The ``name`` attribute is only available in Python 3.10 or later. We are
|
| 79 |
+
targeting exactly that, but Mypy does not know this.
|
| 80 |
+
"""
|
| 81 |
+
if name := parse_name_and_version_from_info_directory(dist)[0]:
|
| 82 |
+
return canonicalize_name(name)
|
| 83 |
+
|
| 84 |
+
name = cast(Any, dist).name
|
| 85 |
+
if not isinstance(name, str):
|
| 86 |
+
raise BadMetadata(dist, reason="invalid metadata entry 'name'")
|
| 87 |
+
return canonicalize_name(name)
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_dists.py
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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.metadata
|
| 5 |
+
import pathlib
|
| 6 |
+
import zipfile
|
| 7 |
+
from collections.abc import Collection, Iterable, Iterator, Mapping, Sequence
|
| 8 |
+
from os import PathLike
|
| 9 |
+
from typing import (
|
| 10 |
+
cast,
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
from pip._vendor.packaging.requirements import Requirement
|
| 14 |
+
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
|
| 15 |
+
from pip._vendor.packaging.version import Version
|
| 16 |
+
from pip._vendor.packaging.version import parse as parse_version
|
| 17 |
+
|
| 18 |
+
from pip._internal.exceptions import InvalidWheel, UnsupportedWheel
|
| 19 |
+
from pip._internal.metadata.base import (
|
| 20 |
+
BaseDistribution,
|
| 21 |
+
BaseEntryPoint,
|
| 22 |
+
InfoPath,
|
| 23 |
+
Wheel,
|
| 24 |
+
)
|
| 25 |
+
from pip._internal.utils.misc import normalize_path
|
| 26 |
+
from pip._internal.utils.packaging import get_requirement
|
| 27 |
+
from pip._internal.utils.temp_dir import TempDirectory
|
| 28 |
+
from pip._internal.utils.wheel import parse_wheel, read_wheel_metadata_file
|
| 29 |
+
|
| 30 |
+
from ._compat import (
|
| 31 |
+
BadMetadata,
|
| 32 |
+
BasePath,
|
| 33 |
+
get_dist_canonical_name,
|
| 34 |
+
parse_name_and_version_from_info_directory,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class WheelDistribution(importlib.metadata.Distribution):
|
| 39 |
+
"""An ``importlib.metadata.Distribution`` read from a wheel.
|
| 40 |
+
|
| 41 |
+
Although ``importlib.metadata.PathDistribution`` accepts ``zipfile.Path``,
|
| 42 |
+
its implementation is too "lazy" for pip's needs (we can't keep the ZipFile
|
| 43 |
+
handle open for the entire lifetime of the distribution object).
|
| 44 |
+
|
| 45 |
+
This implementation eagerly reads the entire metadata directory into the
|
| 46 |
+
memory instead, and operates from that.
|
| 47 |
+
"""
|
| 48 |
+
|
| 49 |
+
def __init__(
|
| 50 |
+
self,
|
| 51 |
+
files: Mapping[pathlib.PurePosixPath, bytes],
|
| 52 |
+
info_location: pathlib.PurePosixPath,
|
| 53 |
+
) -> None:
|
| 54 |
+
self._files = files
|
| 55 |
+
self.info_location = info_location
|
| 56 |
+
|
| 57 |
+
@classmethod
|
| 58 |
+
def from_zipfile(
|
| 59 |
+
cls,
|
| 60 |
+
zf: zipfile.ZipFile,
|
| 61 |
+
name: str,
|
| 62 |
+
location: str,
|
| 63 |
+
) -> WheelDistribution:
|
| 64 |
+
info_dir, _ = parse_wheel(zf, name)
|
| 65 |
+
paths = (
|
| 66 |
+
(name, pathlib.PurePosixPath(name.split("/", 1)[-1]))
|
| 67 |
+
for name in zf.namelist()
|
| 68 |
+
if name.startswith(f"{info_dir}/")
|
| 69 |
+
)
|
| 70 |
+
files = {
|
| 71 |
+
relpath: read_wheel_metadata_file(zf, fullpath)
|
| 72 |
+
for fullpath, relpath in paths
|
| 73 |
+
}
|
| 74 |
+
info_location = pathlib.PurePosixPath(location, info_dir)
|
| 75 |
+
return cls(files, info_location)
|
| 76 |
+
|
| 77 |
+
def iterdir(self, path: InfoPath) -> Iterator[pathlib.PurePosixPath]:
|
| 78 |
+
# Only allow iterating through the metadata directory.
|
| 79 |
+
if pathlib.PurePosixPath(str(path)) in self._files:
|
| 80 |
+
return iter(self._files)
|
| 81 |
+
raise FileNotFoundError(path)
|
| 82 |
+
|
| 83 |
+
def read_text(self, filename: str) -> str | None:
|
| 84 |
+
try:
|
| 85 |
+
data = self._files[pathlib.PurePosixPath(filename)]
|
| 86 |
+
except KeyError:
|
| 87 |
+
return None
|
| 88 |
+
try:
|
| 89 |
+
text = data.decode("utf-8")
|
| 90 |
+
except UnicodeDecodeError as e:
|
| 91 |
+
wheel = self.info_location.parent
|
| 92 |
+
error = f"Error decoding metadata for {wheel}: {e} in {filename} file"
|
| 93 |
+
raise UnsupportedWheel(error)
|
| 94 |
+
return text
|
| 95 |
+
|
| 96 |
+
def locate_file(self, path: str | PathLike[str]) -> pathlib.Path:
|
| 97 |
+
# This method doesn't make sense for our in-memory wheel, but the API
|
| 98 |
+
# requires us to define it.
|
| 99 |
+
raise NotImplementedError
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
class Distribution(BaseDistribution):
|
| 103 |
+
def __init__(
|
| 104 |
+
self,
|
| 105 |
+
dist: importlib.metadata.Distribution,
|
| 106 |
+
info_location: BasePath | None,
|
| 107 |
+
installed_location: BasePath | None,
|
| 108 |
+
) -> None:
|
| 109 |
+
self._dist = dist
|
| 110 |
+
self._info_location = info_location
|
| 111 |
+
self._installed_location = installed_location
|
| 112 |
+
|
| 113 |
+
@classmethod
|
| 114 |
+
def from_directory(cls, directory: str) -> BaseDistribution:
|
| 115 |
+
info_location = pathlib.Path(directory)
|
| 116 |
+
dist = importlib.metadata.Distribution.at(info_location)
|
| 117 |
+
return cls(dist, info_location, info_location.parent)
|
| 118 |
+
|
| 119 |
+
@classmethod
|
| 120 |
+
def from_metadata_file_contents(
|
| 121 |
+
cls,
|
| 122 |
+
metadata_contents: bytes,
|
| 123 |
+
filename: str,
|
| 124 |
+
project_name: str,
|
| 125 |
+
) -> BaseDistribution:
|
| 126 |
+
# Generate temp dir to contain the metadata file, and write the file contents.
|
| 127 |
+
temp_dir = pathlib.Path(
|
| 128 |
+
TempDirectory(kind="metadata", globally_managed=True).path
|
| 129 |
+
)
|
| 130 |
+
metadata_path = temp_dir / "METADATA"
|
| 131 |
+
metadata_path.write_bytes(metadata_contents)
|
| 132 |
+
# Construct dist pointing to the newly created directory.
|
| 133 |
+
dist = importlib.metadata.Distribution.at(metadata_path.parent)
|
| 134 |
+
return cls(dist, metadata_path.parent, None)
|
| 135 |
+
|
| 136 |
+
@classmethod
|
| 137 |
+
def from_wheel(cls, wheel: Wheel, name: str) -> BaseDistribution:
|
| 138 |
+
try:
|
| 139 |
+
with wheel.as_zipfile() as zf:
|
| 140 |
+
dist = WheelDistribution.from_zipfile(zf, name, wheel.location)
|
| 141 |
+
except zipfile.BadZipFile as e:
|
| 142 |
+
raise InvalidWheel(wheel.location, name) from e
|
| 143 |
+
return cls(dist, dist.info_location, pathlib.PurePosixPath(wheel.location))
|
| 144 |
+
|
| 145 |
+
@property
|
| 146 |
+
def location(self) -> str | None:
|
| 147 |
+
if self._info_location is None:
|
| 148 |
+
return None
|
| 149 |
+
return str(self._info_location.parent)
|
| 150 |
+
|
| 151 |
+
@property
|
| 152 |
+
def info_location(self) -> str | None:
|
| 153 |
+
if self._info_location is None:
|
| 154 |
+
return None
|
| 155 |
+
return str(self._info_location)
|
| 156 |
+
|
| 157 |
+
@property
|
| 158 |
+
def installed_location(self) -> str | None:
|
| 159 |
+
if self._installed_location is None:
|
| 160 |
+
return None
|
| 161 |
+
return normalize_path(str(self._installed_location))
|
| 162 |
+
|
| 163 |
+
@property
|
| 164 |
+
def canonical_name(self) -> NormalizedName:
|
| 165 |
+
return get_dist_canonical_name(self._dist)
|
| 166 |
+
|
| 167 |
+
@property
|
| 168 |
+
def version(self) -> Version:
|
| 169 |
+
try:
|
| 170 |
+
version = (
|
| 171 |
+
parse_name_and_version_from_info_directory(self._dist)[1]
|
| 172 |
+
or self._dist.version
|
| 173 |
+
)
|
| 174 |
+
return parse_version(version)
|
| 175 |
+
except TypeError:
|
| 176 |
+
raise BadMetadata(self._dist, reason="invalid metadata entry `version`")
|
| 177 |
+
|
| 178 |
+
@property
|
| 179 |
+
def raw_version(self) -> str:
|
| 180 |
+
return self._dist.version
|
| 181 |
+
|
| 182 |
+
def is_file(self, path: InfoPath) -> bool:
|
| 183 |
+
return self._dist.read_text(str(path)) is not None
|
| 184 |
+
|
| 185 |
+
def iter_distutils_script_names(self) -> Iterator[str]:
|
| 186 |
+
# A distutils installation is always "flat" (not in e.g. egg form), so
|
| 187 |
+
# if this distribution's info location is NOT a pathlib.Path (but e.g.
|
| 188 |
+
# zipfile.Path), it can never contain any distutils scripts.
|
| 189 |
+
if not isinstance(self._info_location, pathlib.Path):
|
| 190 |
+
return
|
| 191 |
+
for child in self._info_location.joinpath("scripts").iterdir():
|
| 192 |
+
yield child.name
|
| 193 |
+
|
| 194 |
+
def read_text(self, path: InfoPath) -> str:
|
| 195 |
+
content = self._dist.read_text(str(path))
|
| 196 |
+
if content is None:
|
| 197 |
+
raise FileNotFoundError(path)
|
| 198 |
+
return content
|
| 199 |
+
|
| 200 |
+
def iter_entry_points(self) -> Iterable[BaseEntryPoint]:
|
| 201 |
+
# importlib.metadata's EntryPoint structure satisfies BaseEntryPoint.
|
| 202 |
+
return self._dist.entry_points
|
| 203 |
+
|
| 204 |
+
def _metadata_impl(self) -> email.message.Message:
|
| 205 |
+
# From Python 3.10+, importlib.metadata declares PackageMetadata as the
|
| 206 |
+
# return type. This protocol is unfortunately a disaster now and misses
|
| 207 |
+
# a ton of fields that we need, including get() and get_payload(). We
|
| 208 |
+
# rely on the implementation that the object is actually a Message now,
|
| 209 |
+
# until upstream can improve the protocol. (python/cpython#94952)
|
| 210 |
+
return cast(email.message.Message, self._dist.metadata)
|
| 211 |
+
|
| 212 |
+
def iter_provided_extras(self) -> Iterable[NormalizedName]:
|
| 213 |
+
return [
|
| 214 |
+
canonicalize_name(extra)
|
| 215 |
+
for extra in self.metadata.get_all("Provides-Extra", [])
|
| 216 |
+
]
|
| 217 |
+
|
| 218 |
+
def iter_dependencies(self, extras: Collection[str] = ()) -> Iterable[Requirement]:
|
| 219 |
+
contexts: Sequence[dict[str, str]] = [{"extra": e} for e in extras]
|
| 220 |
+
for req_string in self.metadata.get_all("Requires-Dist", []):
|
| 221 |
+
# strip() because email.message.Message.get_all() may return a leading \n
|
| 222 |
+
# in case a long header was wrapped.
|
| 223 |
+
req = get_requirement(req_string.strip())
|
| 224 |
+
if not req.marker:
|
| 225 |
+
yield req
|
| 226 |
+
elif not extras and req.marker.evaluate({"extra": ""}):
|
| 227 |
+
yield req
|
| 228 |
+
elif any(req.marker.evaluate(context) for context in contexts):
|
| 229 |
+
yield req
|
.venv/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_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from collections.abc import Iterator, Sequence
|
| 10 |
+
from typing import Optional
|
| 11 |
+
|
| 12 |
+
from pip._vendor.packaging.utils import (
|
| 13 |
+
InvalidWheelFilename,
|
| 14 |
+
NormalizedName,
|
| 15 |
+
canonicalize_name,
|
| 16 |
+
parse_wheel_filename,
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
from pip._internal.metadata.base import BaseDistribution, BaseEnvironment
|
| 20 |
+
from pip._internal.utils.filetypes import WHEEL_EXTENSION
|
| 21 |
+
|
| 22 |
+
from ._compat import BadMetadata, BasePath, get_dist_canonical_name, get_info_location
|
| 23 |
+
from ._dists import Distribution
|
| 24 |
+
|
| 25 |
+
logger = logging.getLogger(__name__)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def _looks_like_wheel(location: str) -> bool:
|
| 29 |
+
if not location.endswith(WHEEL_EXTENSION):
|
| 30 |
+
return False
|
| 31 |
+
if not os.path.isfile(location):
|
| 32 |
+
return False
|
| 33 |
+
try:
|
| 34 |
+
parse_wheel_filename(os.path.basename(location))
|
| 35 |
+
except InvalidWheelFilename:
|
| 36 |
+
return False
|
| 37 |
+
return zipfile.is_zipfile(location)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class _DistributionFinder:
|
| 41 |
+
"""Finder to locate distributions.
|
| 42 |
+
|
| 43 |
+
The main purpose of this class is to memoize found distributions' names, so
|
| 44 |
+
only one distribution is returned for each package name. At lot of pip code
|
| 45 |
+
assumes this (because it is setuptools's behavior), and not doing the same
|
| 46 |
+
can potentially cause a distribution in lower precedence path to override a
|
| 47 |
+
higher precedence one if the caller is not careful.
|
| 48 |
+
|
| 49 |
+
Eventually we probably want to make it possible to see lower precedence
|
| 50 |
+
installations as well. It's useful feature, after all.
|
| 51 |
+
"""
|
| 52 |
+
|
| 53 |
+
FoundResult = tuple[importlib.metadata.Distribution, Optional[BasePath]]
|
| 54 |
+
|
| 55 |
+
def __init__(self) -> None:
|
| 56 |
+
self._found_names: set[NormalizedName] = set()
|
| 57 |
+
|
| 58 |
+
def _find_impl(self, location: str) -> Iterator[FoundResult]:
|
| 59 |
+
"""Find distributions in a location."""
|
| 60 |
+
# Skip looking inside a wheel. Since a package inside a wheel is not
|
| 61 |
+
# always valid (due to .data directories etc.), its .dist-info entry
|
| 62 |
+
# should not be considered an installed distribution.
|
| 63 |
+
if _looks_like_wheel(location):
|
| 64 |
+
return
|
| 65 |
+
# To know exactly where we find a distribution, we have to feed in the
|
| 66 |
+
# paths one by one, instead of dumping the list to importlib.metadata.
|
| 67 |
+
for dist in importlib.metadata.distributions(path=[location]):
|
| 68 |
+
info_location = get_info_location(dist)
|
| 69 |
+
try:
|
| 70 |
+
name = get_dist_canonical_name(dist)
|
| 71 |
+
except BadMetadata as e:
|
| 72 |
+
logger.warning("Skipping %s due to %s", info_location, e.reason)
|
| 73 |
+
continue
|
| 74 |
+
if name in self._found_names:
|
| 75 |
+
continue
|
| 76 |
+
self._found_names.add(name)
|
| 77 |
+
yield dist, info_location
|
| 78 |
+
|
| 79 |
+
def find(self, location: str) -> Iterator[BaseDistribution]:
|
| 80 |
+
"""Find distributions in a location.
|
| 81 |
+
|
| 82 |
+
The path can be either a directory, or a ZIP archive.
|
| 83 |
+
"""
|
| 84 |
+
for dist, info_location in self._find_impl(location):
|
| 85 |
+
if info_location is None:
|
| 86 |
+
installed_location: BasePath | None = None
|
| 87 |
+
else:
|
| 88 |
+
installed_location = info_location.parent
|
| 89 |
+
yield Distribution(dist, info_location, installed_location)
|
| 90 |
+
|
| 91 |
+
def find_legacy_editables(self, location: str) -> Iterator[BaseDistribution]:
|
| 92 |
+
"""Read location in egg-link files and return distributions in there.
|
| 93 |
+
|
| 94 |
+
The path should be a directory; otherwise this returns nothing. This
|
| 95 |
+
follows how setuptools does this for compatibility. The first non-empty
|
| 96 |
+
line in the egg-link is read as a path (resolved against the egg-link's
|
| 97 |
+
containing directory if relative). Distributions found at that linked
|
| 98 |
+
location are returned.
|
| 99 |
+
"""
|
| 100 |
+
path = pathlib.Path(location)
|
| 101 |
+
if not path.is_dir():
|
| 102 |
+
return
|
| 103 |
+
for child in path.iterdir():
|
| 104 |
+
if child.suffix != ".egg-link":
|
| 105 |
+
continue
|
| 106 |
+
with child.open() as f:
|
| 107 |
+
lines = (line.strip() for line in f)
|
| 108 |
+
target_rel = next((line for line in lines if line), "")
|
| 109 |
+
if not target_rel:
|
| 110 |
+
continue
|
| 111 |
+
target_location = str(path.joinpath(target_rel))
|
| 112 |
+
for dist, info_location in self._find_impl(target_location):
|
| 113 |
+
yield Distribution(dist, info_location, path)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
class Environment(BaseEnvironment):
|
| 117 |
+
def __init__(self, paths: Sequence[str]) -> None:
|
| 118 |
+
self._paths = paths
|
| 119 |
+
|
| 120 |
+
@classmethod
|
| 121 |
+
def default(cls) -> BaseEnvironment:
|
| 122 |
+
return cls(sys.path)
|
| 123 |
+
|
| 124 |
+
@classmethod
|
| 125 |
+
def from_paths(cls, paths: list[str] | None) -> BaseEnvironment:
|
| 126 |
+
if paths is None:
|
| 127 |
+
return cls(sys.path)
|
| 128 |
+
return cls(paths)
|
| 129 |
+
|
| 130 |
+
def _iter_distributions(self) -> Iterator[BaseDistribution]:
|
| 131 |
+
finder = _DistributionFinder()
|
| 132 |
+
for location in self._paths:
|
| 133 |
+
yield from finder.find(location)
|
| 134 |
+
yield from finder.find_legacy_editables(location)
|
| 135 |
+
|
| 136 |
+
def get_distribution(self, name: str) -> BaseDistribution | None:
|
| 137 |
+
canonical_name = canonicalize_name(name)
|
| 138 |
+
matches = (
|
| 139 |
+
distribution
|
| 140 |
+
for distribution in self.iter_all_distributions()
|
| 141 |
+
if distribution.canonical_name == canonical_name
|
| 142 |
+
)
|
| 143 |
+
return next(matches, None)
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (258 Bytes). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/candidate.cpython-312.pyc
ADDED
|
Binary file (1.6 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/direct_url.cpython-312.pyc
ADDED
|
Binary file (10.5 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/format_control.cpython-312.pyc
ADDED
|
Binary file (4.12 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/index.cpython-312.pyc
ADDED
|
Binary file (1.69 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/installation_report.cpython-312.pyc
ADDED
|
Binary file (2.29 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/link.cpython-312.pyc
ADDED
|
Binary file (26.8 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/release_control.cpython-312.pyc
ADDED
|
Binary file (4.18 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/scheme.cpython-312.pyc
ADDED
|
Binary file (1.02 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/search_scope.cpython-312.pyc
ADDED
|
Binary file (4.95 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/selection_prefs.cpython-312.pyc
ADDED
|
Binary file (2.11 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/target_python.cpython-312.pyc
ADDED
|
Binary file (4.85 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/models/__pycache__/wheel.cpython-312.pyc
ADDED
|
Binary file (4.66 kB). View file
|
|
|
.venv/lib/python3.12/site-packages/pip/_internal/network/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (246 Bytes). View file
|
|
|