Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +2 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/cli/index_command.py +171 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/cli/main_parser.py +134 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/cache.cpython-310.pyc +0 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/inspect.cpython-310.pyc +0 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/list.cpython-310.pyc +0 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/completion.py +130 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/debug.py +201 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/download.py +146 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/index.py +139 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/list.py +375 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/wheel.py +182 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/__init__.py +128 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/__pycache__/__init__.cpython-310.pyc +0 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/__pycache__/_json.cpython-310.pyc +0 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/__pycache__/pkg_resources.cpython-310.pyc +0 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/_json.py +86 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/base.py +688 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/__init__.py +6 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/__pycache__/__init__.cpython-310.pyc +0 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/__pycache__/_compat.cpython-310.pyc +0 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/__pycache__/_dists.cpython-310.pyc +0 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/__pycache__/_envs.cpython-310.pyc +0 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/_compat.py +85 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/_dists.py +228 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/_envs.py +189 -0
- mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/pkg_resources.py +301 -0
- moondream/lib/python3.10/site-packages/sympy/combinatorics/__pycache__/perm_groups.cpython-310.pyc +3 -0
- moondream/lib/python3.10/site-packages/sympy/solvers/tests/__pycache__/test_solveset.cpython-310.pyc +3 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_add_relu_meta_dispatch.h +24 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_cudnn_rnn_flatten_weight.h +91 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_foreach_addcmul.h +82 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_log_softmax_backward_data_cpu_dispatch.h +25 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_native_batch_norm_legit_no_training_compositeexplicitautograd_dispatch.h +25 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_native_batch_norm_legit_no_training_ops.h +39 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_nested_get_offsets_native.h +20 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_prelu_kernel_backward_native.h +22 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_scaled_dot_product_efficient_attention_backward_cuda_dispatch.h +23 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_to_sparse_semi_structured.h +30 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_unsafe_index_put_compositeexplicitautograd_dispatch.h +23 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_upsample_bicubic2d_aa_backward_meta_dispatch.h +28 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_upsample_bicubic2d_aa_meta.h +27 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/adaptive_avg_pool3d.h +91 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/batch_norm_elemt_cuda_dispatch.h +25 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/choose_qparams_optimized_compositeimplicitautograd_dispatch.h +23 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/clamp_ops.h +83 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/complex_cuda_dispatch.h +24 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/conv1d_ops.h +39 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/cummax.h +53 -0
- moondream/lib/python3.10/site-packages/torch/include/ATen/ops/deg2rad_ops.h +50 -0
.gitattributes
CHANGED
|
@@ -521,3 +521,5 @@ mantis_evalkit/lib/python3.10/site-packages/kiwisolver/_cext.cpython-310-x86_64-
|
|
| 521 |
moondream/lib/python3.10/site-packages/torch/__pycache__/_meta_registrations.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 522 |
parrot/lib/python3.10/site-packages/nvidia/cuda_cupti/lib/libnvperf_target.so filter=lfs diff=lfs merge=lfs -text
|
| 523 |
mantis_evalkit/lib/python3.10/site-packages/decord.libs/libavfilter-1e2243e2.so.7.40.101 filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 521 |
moondream/lib/python3.10/site-packages/torch/__pycache__/_meta_registrations.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 522 |
parrot/lib/python3.10/site-packages/nvidia/cuda_cupti/lib/libnvperf_target.so filter=lfs diff=lfs merge=lfs -text
|
| 523 |
mantis_evalkit/lib/python3.10/site-packages/decord.libs/libavfilter-1e2243e2.so.7.40.101 filter=lfs diff=lfs merge=lfs -text
|
| 524 |
+
moondream/lib/python3.10/site-packages/sympy/solvers/tests/__pycache__/test_solveset.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 525 |
+
moondream/lib/python3.10/site-packages/sympy/combinatorics/__pycache__/perm_groups.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/cli/index_command.py
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Contains command classes which may interact with an index / the network.
|
| 3 |
+
|
| 4 |
+
Unlike its sister module, req_command, this module still uses lazy imports
|
| 5 |
+
so commands which don't always hit the network (e.g. list w/o --outdated or
|
| 6 |
+
--uptodate) don't need waste time importing PipSession and friends.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import logging
|
| 10 |
+
import os
|
| 11 |
+
import sys
|
| 12 |
+
from optparse import Values
|
| 13 |
+
from typing import TYPE_CHECKING, List, Optional
|
| 14 |
+
|
| 15 |
+
from pip._vendor import certifi
|
| 16 |
+
|
| 17 |
+
from pip._internal.cli.base_command import Command
|
| 18 |
+
from pip._internal.cli.command_context import CommandContextMixIn
|
| 19 |
+
|
| 20 |
+
if TYPE_CHECKING:
|
| 21 |
+
from ssl import SSLContext
|
| 22 |
+
|
| 23 |
+
from pip._internal.network.session import PipSession
|
| 24 |
+
|
| 25 |
+
logger = logging.getLogger(__name__)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def _create_truststore_ssl_context() -> Optional["SSLContext"]:
|
| 29 |
+
if sys.version_info < (3, 10):
|
| 30 |
+
logger.debug("Disabling truststore because Python version isn't 3.10+")
|
| 31 |
+
return None
|
| 32 |
+
|
| 33 |
+
try:
|
| 34 |
+
import ssl
|
| 35 |
+
except ImportError:
|
| 36 |
+
logger.warning("Disabling truststore since ssl support is missing")
|
| 37 |
+
return None
|
| 38 |
+
|
| 39 |
+
try:
|
| 40 |
+
from pip._vendor import truststore
|
| 41 |
+
except ImportError:
|
| 42 |
+
logger.warning("Disabling truststore because platform isn't supported")
|
| 43 |
+
return None
|
| 44 |
+
|
| 45 |
+
ctx = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
| 46 |
+
ctx.load_verify_locations(certifi.where())
|
| 47 |
+
return ctx
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class SessionCommandMixin(CommandContextMixIn):
|
| 51 |
+
"""
|
| 52 |
+
A class mixin for command classes needing _build_session().
|
| 53 |
+
"""
|
| 54 |
+
|
| 55 |
+
def __init__(self) -> None:
|
| 56 |
+
super().__init__()
|
| 57 |
+
self._session: Optional[PipSession] = None
|
| 58 |
+
|
| 59 |
+
@classmethod
|
| 60 |
+
def _get_index_urls(cls, options: Values) -> Optional[List[str]]:
|
| 61 |
+
"""Return a list of index urls from user-provided options."""
|
| 62 |
+
index_urls = []
|
| 63 |
+
if not getattr(options, "no_index", False):
|
| 64 |
+
url = getattr(options, "index_url", None)
|
| 65 |
+
if url:
|
| 66 |
+
index_urls.append(url)
|
| 67 |
+
urls = getattr(options, "extra_index_urls", None)
|
| 68 |
+
if urls:
|
| 69 |
+
index_urls.extend(urls)
|
| 70 |
+
# Return None rather than an empty list
|
| 71 |
+
return index_urls or None
|
| 72 |
+
|
| 73 |
+
def get_default_session(self, options: Values) -> "PipSession":
|
| 74 |
+
"""Get a default-managed session."""
|
| 75 |
+
if self._session is None:
|
| 76 |
+
self._session = self.enter_context(self._build_session(options))
|
| 77 |
+
# there's no type annotation on requests.Session, so it's
|
| 78 |
+
# automatically ContextManager[Any] and self._session becomes Any,
|
| 79 |
+
# then https://github.com/python/mypy/issues/7696 kicks in
|
| 80 |
+
assert self._session is not None
|
| 81 |
+
return self._session
|
| 82 |
+
|
| 83 |
+
def _build_session(
|
| 84 |
+
self,
|
| 85 |
+
options: Values,
|
| 86 |
+
retries: Optional[int] = None,
|
| 87 |
+
timeout: Optional[int] = None,
|
| 88 |
+
) -> "PipSession":
|
| 89 |
+
from pip._internal.network.session import PipSession
|
| 90 |
+
|
| 91 |
+
cache_dir = options.cache_dir
|
| 92 |
+
assert not cache_dir or os.path.isabs(cache_dir)
|
| 93 |
+
|
| 94 |
+
if "legacy-certs" not in options.deprecated_features_enabled:
|
| 95 |
+
ssl_context = _create_truststore_ssl_context()
|
| 96 |
+
else:
|
| 97 |
+
ssl_context = None
|
| 98 |
+
|
| 99 |
+
session = PipSession(
|
| 100 |
+
cache=os.path.join(cache_dir, "http-v2") if cache_dir else None,
|
| 101 |
+
retries=retries if retries is not None else options.retries,
|
| 102 |
+
trusted_hosts=options.trusted_hosts,
|
| 103 |
+
index_urls=self._get_index_urls(options),
|
| 104 |
+
ssl_context=ssl_context,
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
# Handle custom ca-bundles from the user
|
| 108 |
+
if options.cert:
|
| 109 |
+
session.verify = options.cert
|
| 110 |
+
|
| 111 |
+
# Handle SSL client certificate
|
| 112 |
+
if options.client_cert:
|
| 113 |
+
session.cert = options.client_cert
|
| 114 |
+
|
| 115 |
+
# Handle timeouts
|
| 116 |
+
if options.timeout or timeout:
|
| 117 |
+
session.timeout = timeout if timeout is not None else options.timeout
|
| 118 |
+
|
| 119 |
+
# Handle configured proxies
|
| 120 |
+
if options.proxy:
|
| 121 |
+
session.proxies = {
|
| 122 |
+
"http": options.proxy,
|
| 123 |
+
"https": options.proxy,
|
| 124 |
+
}
|
| 125 |
+
session.trust_env = False
|
| 126 |
+
session.pip_proxy = options.proxy
|
| 127 |
+
|
| 128 |
+
# Determine if we can prompt the user for authentication or not
|
| 129 |
+
session.auth.prompting = not options.no_input
|
| 130 |
+
session.auth.keyring_provider = options.keyring_provider
|
| 131 |
+
|
| 132 |
+
return session
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def _pip_self_version_check(session: "PipSession", options: Values) -> None:
|
| 136 |
+
from pip._internal.self_outdated_check import pip_self_version_check as check
|
| 137 |
+
|
| 138 |
+
check(session, options)
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
class IndexGroupCommand(Command, SessionCommandMixin):
|
| 142 |
+
"""
|
| 143 |
+
Abstract base class for commands with the index_group options.
|
| 144 |
+
|
| 145 |
+
This also corresponds to the commands that permit the pip version check.
|
| 146 |
+
"""
|
| 147 |
+
|
| 148 |
+
def handle_pip_version_check(self, options: Values) -> None:
|
| 149 |
+
"""
|
| 150 |
+
Do the pip version check if not disabled.
|
| 151 |
+
|
| 152 |
+
This overrides the default behavior of not doing the check.
|
| 153 |
+
"""
|
| 154 |
+
# Make sure the index_group options are present.
|
| 155 |
+
assert hasattr(options, "no_index")
|
| 156 |
+
|
| 157 |
+
if options.disable_pip_version_check or options.no_index:
|
| 158 |
+
return
|
| 159 |
+
|
| 160 |
+
try:
|
| 161 |
+
# Otherwise, check if we're using the latest version of pip available.
|
| 162 |
+
session = self._build_session(
|
| 163 |
+
options,
|
| 164 |
+
retries=0,
|
| 165 |
+
timeout=min(5, options.timeout),
|
| 166 |
+
)
|
| 167 |
+
with session:
|
| 168 |
+
_pip_self_version_check(session, options)
|
| 169 |
+
except Exception:
|
| 170 |
+
logger.warning("There was an error checking the latest version of pip.")
|
| 171 |
+
logger.debug("See below for error", exc_info=True)
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/cli/main_parser.py
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""A single place for constructing and exposing the main parser
|
| 2 |
+
"""
|
| 3 |
+
|
| 4 |
+
import os
|
| 5 |
+
import subprocess
|
| 6 |
+
import sys
|
| 7 |
+
from typing import List, Optional, Tuple
|
| 8 |
+
|
| 9 |
+
from pip._internal.build_env import get_runnable_pip
|
| 10 |
+
from pip._internal.cli import cmdoptions
|
| 11 |
+
from pip._internal.cli.parser import ConfigOptionParser, UpdatingDefaultsHelpFormatter
|
| 12 |
+
from pip._internal.commands import commands_dict, get_similar_commands
|
| 13 |
+
from pip._internal.exceptions import CommandError
|
| 14 |
+
from pip._internal.utils.misc import get_pip_version, get_prog
|
| 15 |
+
|
| 16 |
+
__all__ = ["create_main_parser", "parse_command"]
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def create_main_parser() -> ConfigOptionParser:
|
| 20 |
+
"""Creates and returns the main parser for pip's CLI"""
|
| 21 |
+
|
| 22 |
+
parser = ConfigOptionParser(
|
| 23 |
+
usage="\n%prog <command> [options]",
|
| 24 |
+
add_help_option=False,
|
| 25 |
+
formatter=UpdatingDefaultsHelpFormatter(),
|
| 26 |
+
name="global",
|
| 27 |
+
prog=get_prog(),
|
| 28 |
+
)
|
| 29 |
+
parser.disable_interspersed_args()
|
| 30 |
+
|
| 31 |
+
parser.version = get_pip_version()
|
| 32 |
+
|
| 33 |
+
# add the general options
|
| 34 |
+
gen_opts = cmdoptions.make_option_group(cmdoptions.general_group, parser)
|
| 35 |
+
parser.add_option_group(gen_opts)
|
| 36 |
+
|
| 37 |
+
# so the help formatter knows
|
| 38 |
+
parser.main = True # type: ignore
|
| 39 |
+
|
| 40 |
+
# create command listing for description
|
| 41 |
+
description = [""] + [
|
| 42 |
+
f"{name:27} {command_info.summary}"
|
| 43 |
+
for name, command_info in commands_dict.items()
|
| 44 |
+
]
|
| 45 |
+
parser.description = "\n".join(description)
|
| 46 |
+
|
| 47 |
+
return parser
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def identify_python_interpreter(python: str) -> Optional[str]:
|
| 51 |
+
# If the named file exists, use it.
|
| 52 |
+
# If it's a directory, assume it's a virtual environment and
|
| 53 |
+
# look for the environment's Python executable.
|
| 54 |
+
if os.path.exists(python):
|
| 55 |
+
if os.path.isdir(python):
|
| 56 |
+
# bin/python for Unix, Scripts/python.exe for Windows
|
| 57 |
+
# Try both in case of odd cases like cygwin.
|
| 58 |
+
for exe in ("bin/python", "Scripts/python.exe"):
|
| 59 |
+
py = os.path.join(python, exe)
|
| 60 |
+
if os.path.exists(py):
|
| 61 |
+
return py
|
| 62 |
+
else:
|
| 63 |
+
return python
|
| 64 |
+
|
| 65 |
+
# Could not find the interpreter specified
|
| 66 |
+
return None
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def parse_command(args: List[str]) -> Tuple[str, List[str]]:
|
| 70 |
+
parser = create_main_parser()
|
| 71 |
+
|
| 72 |
+
# Note: parser calls disable_interspersed_args(), so the result of this
|
| 73 |
+
# call is to split the initial args into the general options before the
|
| 74 |
+
# subcommand and everything else.
|
| 75 |
+
# For example:
|
| 76 |
+
# args: ['--timeout=5', 'install', '--user', 'INITools']
|
| 77 |
+
# general_options: ['--timeout==5']
|
| 78 |
+
# args_else: ['install', '--user', 'INITools']
|
| 79 |
+
general_options, args_else = parser.parse_args(args)
|
| 80 |
+
|
| 81 |
+
# --python
|
| 82 |
+
if general_options.python and "_PIP_RUNNING_IN_SUBPROCESS" not in os.environ:
|
| 83 |
+
# Re-invoke pip using the specified Python interpreter
|
| 84 |
+
interpreter = identify_python_interpreter(general_options.python)
|
| 85 |
+
if interpreter is None:
|
| 86 |
+
raise CommandError(
|
| 87 |
+
f"Could not locate Python interpreter {general_options.python}"
|
| 88 |
+
)
|
| 89 |
+
|
| 90 |
+
pip_cmd = [
|
| 91 |
+
interpreter,
|
| 92 |
+
get_runnable_pip(),
|
| 93 |
+
]
|
| 94 |
+
pip_cmd.extend(args)
|
| 95 |
+
|
| 96 |
+
# Set a flag so the child doesn't re-invoke itself, causing
|
| 97 |
+
# an infinite loop.
|
| 98 |
+
os.environ["_PIP_RUNNING_IN_SUBPROCESS"] = "1"
|
| 99 |
+
returncode = 0
|
| 100 |
+
try:
|
| 101 |
+
proc = subprocess.run(pip_cmd)
|
| 102 |
+
returncode = proc.returncode
|
| 103 |
+
except (subprocess.SubprocessError, OSError) as exc:
|
| 104 |
+
raise CommandError(f"Failed to run pip under {interpreter}: {exc}")
|
| 105 |
+
sys.exit(returncode)
|
| 106 |
+
|
| 107 |
+
# --version
|
| 108 |
+
if general_options.version:
|
| 109 |
+
sys.stdout.write(parser.version)
|
| 110 |
+
sys.stdout.write(os.linesep)
|
| 111 |
+
sys.exit()
|
| 112 |
+
|
| 113 |
+
# pip || pip help -> print_help()
|
| 114 |
+
if not args_else or (args_else[0] == "help" and len(args_else) == 1):
|
| 115 |
+
parser.print_help()
|
| 116 |
+
sys.exit()
|
| 117 |
+
|
| 118 |
+
# the subcommand name
|
| 119 |
+
cmd_name = args_else[0]
|
| 120 |
+
|
| 121 |
+
if cmd_name not in commands_dict:
|
| 122 |
+
guess = get_similar_commands(cmd_name)
|
| 123 |
+
|
| 124 |
+
msg = [f'unknown command "{cmd_name}"']
|
| 125 |
+
if guess:
|
| 126 |
+
msg.append(f'maybe you meant "{guess}"')
|
| 127 |
+
|
| 128 |
+
raise CommandError(" - ".join(msg))
|
| 129 |
+
|
| 130 |
+
# all the args without the subcommand
|
| 131 |
+
cmd_args = args[:]
|
| 132 |
+
cmd_args.remove(cmd_name)
|
| 133 |
+
|
| 134 |
+
return cmd_name, cmd_args
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/cache.cpython-310.pyc
ADDED
|
Binary file (6.53 kB). View file
|
|
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/inspect.cpython-310.pyc
ADDED
|
Binary file (2.96 kB). View file
|
|
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/list.cpython-310.pyc
ADDED
|
Binary file (10.6 kB). View file
|
|
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/completion.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
import textwrap
|
| 3 |
+
from optparse import Values
|
| 4 |
+
from typing import List
|
| 5 |
+
|
| 6 |
+
from pip._internal.cli.base_command import Command
|
| 7 |
+
from pip._internal.cli.status_codes import SUCCESS
|
| 8 |
+
from pip._internal.utils.misc import get_prog
|
| 9 |
+
|
| 10 |
+
BASE_COMPLETION = """
|
| 11 |
+
# pip {shell} completion start{script}# pip {shell} completion end
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
COMPLETION_SCRIPTS = {
|
| 15 |
+
"bash": """
|
| 16 |
+
_pip_completion()
|
| 17 |
+
{{
|
| 18 |
+
COMPREPLY=( $( COMP_WORDS="${{COMP_WORDS[*]}}" \\
|
| 19 |
+
COMP_CWORD=$COMP_CWORD \\
|
| 20 |
+
PIP_AUTO_COMPLETE=1 $1 2>/dev/null ) )
|
| 21 |
+
}}
|
| 22 |
+
complete -o default -F _pip_completion {prog}
|
| 23 |
+
""",
|
| 24 |
+
"zsh": """
|
| 25 |
+
#compdef -P pip[0-9.]#
|
| 26 |
+
__pip() {{
|
| 27 |
+
compadd $( COMP_WORDS="$words[*]" \\
|
| 28 |
+
COMP_CWORD=$((CURRENT-1)) \\
|
| 29 |
+
PIP_AUTO_COMPLETE=1 $words[1] 2>/dev/null )
|
| 30 |
+
}}
|
| 31 |
+
if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
|
| 32 |
+
# autoload from fpath, call function directly
|
| 33 |
+
__pip "$@"
|
| 34 |
+
else
|
| 35 |
+
# eval/source/. command, register function for later
|
| 36 |
+
compdef __pip -P 'pip[0-9.]#'
|
| 37 |
+
fi
|
| 38 |
+
""",
|
| 39 |
+
"fish": """
|
| 40 |
+
function __fish_complete_pip
|
| 41 |
+
set -lx COMP_WORDS (commandline -o) ""
|
| 42 |
+
set -lx COMP_CWORD ( \\
|
| 43 |
+
math (contains -i -- (commandline -t) $COMP_WORDS)-1 \\
|
| 44 |
+
)
|
| 45 |
+
set -lx PIP_AUTO_COMPLETE 1
|
| 46 |
+
string split \\ -- (eval $COMP_WORDS[1])
|
| 47 |
+
end
|
| 48 |
+
complete -fa "(__fish_complete_pip)" -c {prog}
|
| 49 |
+
""",
|
| 50 |
+
"powershell": """
|
| 51 |
+
if ((Test-Path Function:\\TabExpansion) -and -not `
|
| 52 |
+
(Test-Path Function:\\_pip_completeBackup)) {{
|
| 53 |
+
Rename-Item Function:\\TabExpansion _pip_completeBackup
|
| 54 |
+
}}
|
| 55 |
+
function TabExpansion($line, $lastWord) {{
|
| 56 |
+
$lastBlock = [regex]::Split($line, '[|;]')[-1].TrimStart()
|
| 57 |
+
if ($lastBlock.StartsWith("{prog} ")) {{
|
| 58 |
+
$Env:COMP_WORDS=$lastBlock
|
| 59 |
+
$Env:COMP_CWORD=$lastBlock.Split().Length - 1
|
| 60 |
+
$Env:PIP_AUTO_COMPLETE=1
|
| 61 |
+
(& {prog}).Split()
|
| 62 |
+
Remove-Item Env:COMP_WORDS
|
| 63 |
+
Remove-Item Env:COMP_CWORD
|
| 64 |
+
Remove-Item Env:PIP_AUTO_COMPLETE
|
| 65 |
+
}}
|
| 66 |
+
elseif (Test-Path Function:\\_pip_completeBackup) {{
|
| 67 |
+
# Fall back on existing tab expansion
|
| 68 |
+
_pip_completeBackup $line $lastWord
|
| 69 |
+
}}
|
| 70 |
+
}}
|
| 71 |
+
""",
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
class CompletionCommand(Command):
|
| 76 |
+
"""A helper command to be used for command completion."""
|
| 77 |
+
|
| 78 |
+
ignore_require_venv = True
|
| 79 |
+
|
| 80 |
+
def add_options(self) -> None:
|
| 81 |
+
self.cmd_opts.add_option(
|
| 82 |
+
"--bash",
|
| 83 |
+
"-b",
|
| 84 |
+
action="store_const",
|
| 85 |
+
const="bash",
|
| 86 |
+
dest="shell",
|
| 87 |
+
help="Emit completion code for bash",
|
| 88 |
+
)
|
| 89 |
+
self.cmd_opts.add_option(
|
| 90 |
+
"--zsh",
|
| 91 |
+
"-z",
|
| 92 |
+
action="store_const",
|
| 93 |
+
const="zsh",
|
| 94 |
+
dest="shell",
|
| 95 |
+
help="Emit completion code for zsh",
|
| 96 |
+
)
|
| 97 |
+
self.cmd_opts.add_option(
|
| 98 |
+
"--fish",
|
| 99 |
+
"-f",
|
| 100 |
+
action="store_const",
|
| 101 |
+
const="fish",
|
| 102 |
+
dest="shell",
|
| 103 |
+
help="Emit completion code for fish",
|
| 104 |
+
)
|
| 105 |
+
self.cmd_opts.add_option(
|
| 106 |
+
"--powershell",
|
| 107 |
+
"-p",
|
| 108 |
+
action="store_const",
|
| 109 |
+
const="powershell",
|
| 110 |
+
dest="shell",
|
| 111 |
+
help="Emit completion code for powershell",
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
self.parser.insert_option_group(0, self.cmd_opts)
|
| 115 |
+
|
| 116 |
+
def run(self, options: Values, args: List[str]) -> int:
|
| 117 |
+
"""Prints the completion code of the given shell"""
|
| 118 |
+
shells = COMPLETION_SCRIPTS.keys()
|
| 119 |
+
shell_options = ["--" + shell for shell in sorted(shells)]
|
| 120 |
+
if options.shell in shells:
|
| 121 |
+
script = textwrap.dedent(
|
| 122 |
+
COMPLETION_SCRIPTS.get(options.shell, "").format(prog=get_prog())
|
| 123 |
+
)
|
| 124 |
+
print(BASE_COMPLETION.format(script=script, shell=options.shell))
|
| 125 |
+
return SUCCESS
|
| 126 |
+
else:
|
| 127 |
+
sys.stderr.write(
|
| 128 |
+
"ERROR: You must pass {}\n".format(" or ".join(shell_options))
|
| 129 |
+
)
|
| 130 |
+
return SUCCESS
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/debug.py
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import locale
|
| 2 |
+
import logging
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
from optparse import Values
|
| 6 |
+
from types import ModuleType
|
| 7 |
+
from typing import Any, Dict, List, Optional
|
| 8 |
+
|
| 9 |
+
import pip._vendor
|
| 10 |
+
from pip._vendor.certifi import where
|
| 11 |
+
from pip._vendor.packaging.version import parse as parse_version
|
| 12 |
+
|
| 13 |
+
from pip._internal.cli import cmdoptions
|
| 14 |
+
from pip._internal.cli.base_command import Command
|
| 15 |
+
from pip._internal.cli.cmdoptions import make_target_python
|
| 16 |
+
from pip._internal.cli.status_codes import SUCCESS
|
| 17 |
+
from pip._internal.configuration import Configuration
|
| 18 |
+
from pip._internal.metadata import get_environment
|
| 19 |
+
from pip._internal.utils.compat import open_text_resource
|
| 20 |
+
from pip._internal.utils.logging import indent_log
|
| 21 |
+
from pip._internal.utils.misc import get_pip_version
|
| 22 |
+
|
| 23 |
+
logger = logging.getLogger(__name__)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def show_value(name: str, value: Any) -> None:
|
| 27 |
+
logger.info("%s: %s", name, value)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def show_sys_implementation() -> None:
|
| 31 |
+
logger.info("sys.implementation:")
|
| 32 |
+
implementation_name = sys.implementation.name
|
| 33 |
+
with indent_log():
|
| 34 |
+
show_value("name", implementation_name)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def create_vendor_txt_map() -> Dict[str, str]:
|
| 38 |
+
with open_text_resource("pip._vendor", "vendor.txt") as f:
|
| 39 |
+
# Purge non version specifying lines.
|
| 40 |
+
# Also, remove any space prefix or suffixes (including comments).
|
| 41 |
+
lines = [
|
| 42 |
+
line.strip().split(" ", 1)[0] for line in f.readlines() if "==" in line
|
| 43 |
+
]
|
| 44 |
+
|
| 45 |
+
# Transform into "module" -> version dict.
|
| 46 |
+
return dict(line.split("==", 1) for line in lines)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def get_module_from_module_name(module_name: str) -> Optional[ModuleType]:
|
| 50 |
+
# Module name can be uppercase in vendor.txt for some reason...
|
| 51 |
+
module_name = module_name.lower().replace("-", "_")
|
| 52 |
+
# PATCH: setuptools is actually only pkg_resources.
|
| 53 |
+
if module_name == "setuptools":
|
| 54 |
+
module_name = "pkg_resources"
|
| 55 |
+
|
| 56 |
+
try:
|
| 57 |
+
__import__(f"pip._vendor.{module_name}", globals(), locals(), level=0)
|
| 58 |
+
return getattr(pip._vendor, module_name)
|
| 59 |
+
except ImportError:
|
| 60 |
+
# We allow 'truststore' to fail to import due
|
| 61 |
+
# to being unavailable on Python 3.9 and earlier.
|
| 62 |
+
if module_name == "truststore" and sys.version_info < (3, 10):
|
| 63 |
+
return None
|
| 64 |
+
raise
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def get_vendor_version_from_module(module_name: str) -> Optional[str]:
|
| 68 |
+
module = get_module_from_module_name(module_name)
|
| 69 |
+
version = getattr(module, "__version__", None)
|
| 70 |
+
|
| 71 |
+
if module and not version:
|
| 72 |
+
# Try to find version in debundled module info.
|
| 73 |
+
assert module.__file__ is not None
|
| 74 |
+
env = get_environment([os.path.dirname(module.__file__)])
|
| 75 |
+
dist = env.get_distribution(module_name)
|
| 76 |
+
if dist:
|
| 77 |
+
version = str(dist.version)
|
| 78 |
+
|
| 79 |
+
return version
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def show_actual_vendor_versions(vendor_txt_versions: Dict[str, str]) -> None:
|
| 83 |
+
"""Log the actual version and print extra info if there is
|
| 84 |
+
a conflict or if the actual version could not be imported.
|
| 85 |
+
"""
|
| 86 |
+
for module_name, expected_version in vendor_txt_versions.items():
|
| 87 |
+
extra_message = ""
|
| 88 |
+
actual_version = get_vendor_version_from_module(module_name)
|
| 89 |
+
if not actual_version:
|
| 90 |
+
extra_message = (
|
| 91 |
+
" (Unable to locate actual module version, using"
|
| 92 |
+
" vendor.txt specified version)"
|
| 93 |
+
)
|
| 94 |
+
actual_version = expected_version
|
| 95 |
+
elif parse_version(actual_version) != parse_version(expected_version):
|
| 96 |
+
extra_message = (
|
| 97 |
+
" (CONFLICT: vendor.txt suggests version should"
|
| 98 |
+
f" be {expected_version})"
|
| 99 |
+
)
|
| 100 |
+
logger.info("%s==%s%s", module_name, actual_version, extra_message)
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def show_vendor_versions() -> None:
|
| 104 |
+
logger.info("vendored library versions:")
|
| 105 |
+
|
| 106 |
+
vendor_txt_versions = create_vendor_txt_map()
|
| 107 |
+
with indent_log():
|
| 108 |
+
show_actual_vendor_versions(vendor_txt_versions)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def show_tags(options: Values) -> None:
|
| 112 |
+
tag_limit = 10
|
| 113 |
+
|
| 114 |
+
target_python = make_target_python(options)
|
| 115 |
+
tags = target_python.get_sorted_tags()
|
| 116 |
+
|
| 117 |
+
# Display the target options that were explicitly provided.
|
| 118 |
+
formatted_target = target_python.format_given()
|
| 119 |
+
suffix = ""
|
| 120 |
+
if formatted_target:
|
| 121 |
+
suffix = f" (target: {formatted_target})"
|
| 122 |
+
|
| 123 |
+
msg = f"Compatible tags: {len(tags)}{suffix}"
|
| 124 |
+
logger.info(msg)
|
| 125 |
+
|
| 126 |
+
if options.verbose < 1 and len(tags) > tag_limit:
|
| 127 |
+
tags_limited = True
|
| 128 |
+
tags = tags[:tag_limit]
|
| 129 |
+
else:
|
| 130 |
+
tags_limited = False
|
| 131 |
+
|
| 132 |
+
with indent_log():
|
| 133 |
+
for tag in tags:
|
| 134 |
+
logger.info(str(tag))
|
| 135 |
+
|
| 136 |
+
if tags_limited:
|
| 137 |
+
msg = f"...\n[First {tag_limit} tags shown. Pass --verbose to show all.]"
|
| 138 |
+
logger.info(msg)
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
def ca_bundle_info(config: Configuration) -> str:
|
| 142 |
+
levels = {key.split(".", 1)[0] for key, _ in config.items()}
|
| 143 |
+
if not levels:
|
| 144 |
+
return "Not specified"
|
| 145 |
+
|
| 146 |
+
levels_that_override_global = ["install", "wheel", "download"]
|
| 147 |
+
global_overriding_level = [
|
| 148 |
+
level for level in levels if level in levels_that_override_global
|
| 149 |
+
]
|
| 150 |
+
if not global_overriding_level:
|
| 151 |
+
return "global"
|
| 152 |
+
|
| 153 |
+
if "global" in levels:
|
| 154 |
+
levels.remove("global")
|
| 155 |
+
return ", ".join(levels)
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
class DebugCommand(Command):
|
| 159 |
+
"""
|
| 160 |
+
Display debug information.
|
| 161 |
+
"""
|
| 162 |
+
|
| 163 |
+
usage = """
|
| 164 |
+
%prog <options>"""
|
| 165 |
+
ignore_require_venv = True
|
| 166 |
+
|
| 167 |
+
def add_options(self) -> None:
|
| 168 |
+
cmdoptions.add_target_python_options(self.cmd_opts)
|
| 169 |
+
self.parser.insert_option_group(0, self.cmd_opts)
|
| 170 |
+
self.parser.config.load()
|
| 171 |
+
|
| 172 |
+
def run(self, options: Values, args: List[str]) -> int:
|
| 173 |
+
logger.warning(
|
| 174 |
+
"This command is only meant for debugging. "
|
| 175 |
+
"Do not use this with automation for parsing and getting these "
|
| 176 |
+
"details, since the output and options of this command may "
|
| 177 |
+
"change without notice."
|
| 178 |
+
)
|
| 179 |
+
show_value("pip version", get_pip_version())
|
| 180 |
+
show_value("sys.version", sys.version)
|
| 181 |
+
show_value("sys.executable", sys.executable)
|
| 182 |
+
show_value("sys.getdefaultencoding", sys.getdefaultencoding())
|
| 183 |
+
show_value("sys.getfilesystemencoding", sys.getfilesystemencoding())
|
| 184 |
+
show_value(
|
| 185 |
+
"locale.getpreferredencoding",
|
| 186 |
+
locale.getpreferredencoding(),
|
| 187 |
+
)
|
| 188 |
+
show_value("sys.platform", sys.platform)
|
| 189 |
+
show_sys_implementation()
|
| 190 |
+
|
| 191 |
+
show_value("'cert' config value", ca_bundle_info(self.parser.config))
|
| 192 |
+
show_value("REQUESTS_CA_BUNDLE", os.environ.get("REQUESTS_CA_BUNDLE"))
|
| 193 |
+
show_value("CURL_CA_BUNDLE", os.environ.get("CURL_CA_BUNDLE"))
|
| 194 |
+
show_value("pip._vendor.certifi.where()", where())
|
| 195 |
+
show_value("pip._vendor.DEBUNDLED", pip._vendor.DEBUNDLED)
|
| 196 |
+
|
| 197 |
+
show_vendor_versions()
|
| 198 |
+
|
| 199 |
+
show_tags(options)
|
| 200 |
+
|
| 201 |
+
return SUCCESS
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/download.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
from optparse import Values
|
| 4 |
+
from typing import List
|
| 5 |
+
|
| 6 |
+
from pip._internal.cli import cmdoptions
|
| 7 |
+
from pip._internal.cli.cmdoptions import make_target_python
|
| 8 |
+
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
|
| 9 |
+
from pip._internal.cli.status_codes import SUCCESS
|
| 10 |
+
from pip._internal.operations.build.build_tracker import get_build_tracker
|
| 11 |
+
from pip._internal.req.req_install import check_legacy_setup_py_options
|
| 12 |
+
from pip._internal.utils.misc import ensure_dir, normalize_path, write_output
|
| 13 |
+
from pip._internal.utils.temp_dir import TempDirectory
|
| 14 |
+
|
| 15 |
+
logger = logging.getLogger(__name__)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class DownloadCommand(RequirementCommand):
|
| 19 |
+
"""
|
| 20 |
+
Download packages from:
|
| 21 |
+
|
| 22 |
+
- PyPI (and other indexes) using requirement specifiers.
|
| 23 |
+
- VCS project urls.
|
| 24 |
+
- Local project directories.
|
| 25 |
+
- Local or remote source archives.
|
| 26 |
+
|
| 27 |
+
pip also supports downloading from "requirements files", which provide
|
| 28 |
+
an easy way to specify a whole environment to be downloaded.
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
usage = """
|
| 32 |
+
%prog [options] <requirement specifier> [package-index-options] ...
|
| 33 |
+
%prog [options] -r <requirements file> [package-index-options] ...
|
| 34 |
+
%prog [options] <vcs project url> ...
|
| 35 |
+
%prog [options] <local project path> ...
|
| 36 |
+
%prog [options] <archive url/path> ..."""
|
| 37 |
+
|
| 38 |
+
def add_options(self) -> None:
|
| 39 |
+
self.cmd_opts.add_option(cmdoptions.constraints())
|
| 40 |
+
self.cmd_opts.add_option(cmdoptions.requirements())
|
| 41 |
+
self.cmd_opts.add_option(cmdoptions.no_deps())
|
| 42 |
+
self.cmd_opts.add_option(cmdoptions.global_options())
|
| 43 |
+
self.cmd_opts.add_option(cmdoptions.no_binary())
|
| 44 |
+
self.cmd_opts.add_option(cmdoptions.only_binary())
|
| 45 |
+
self.cmd_opts.add_option(cmdoptions.prefer_binary())
|
| 46 |
+
self.cmd_opts.add_option(cmdoptions.src())
|
| 47 |
+
self.cmd_opts.add_option(cmdoptions.pre())
|
| 48 |
+
self.cmd_opts.add_option(cmdoptions.require_hashes())
|
| 49 |
+
self.cmd_opts.add_option(cmdoptions.progress_bar())
|
| 50 |
+
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
|
| 51 |
+
self.cmd_opts.add_option(cmdoptions.use_pep517())
|
| 52 |
+
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
|
| 53 |
+
self.cmd_opts.add_option(cmdoptions.check_build_deps())
|
| 54 |
+
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
|
| 55 |
+
|
| 56 |
+
self.cmd_opts.add_option(
|
| 57 |
+
"-d",
|
| 58 |
+
"--dest",
|
| 59 |
+
"--destination-dir",
|
| 60 |
+
"--destination-directory",
|
| 61 |
+
dest="download_dir",
|
| 62 |
+
metavar="dir",
|
| 63 |
+
default=os.curdir,
|
| 64 |
+
help="Download packages into <dir>.",
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
cmdoptions.add_target_python_options(self.cmd_opts)
|
| 68 |
+
|
| 69 |
+
index_opts = cmdoptions.make_option_group(
|
| 70 |
+
cmdoptions.index_group,
|
| 71 |
+
self.parser,
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
self.parser.insert_option_group(0, index_opts)
|
| 75 |
+
self.parser.insert_option_group(0, self.cmd_opts)
|
| 76 |
+
|
| 77 |
+
@with_cleanup
|
| 78 |
+
def run(self, options: Values, args: List[str]) -> int:
|
| 79 |
+
options.ignore_installed = True
|
| 80 |
+
# editable doesn't really make sense for `pip download`, but the bowels
|
| 81 |
+
# of the RequirementSet code require that property.
|
| 82 |
+
options.editables = []
|
| 83 |
+
|
| 84 |
+
cmdoptions.check_dist_restriction(options)
|
| 85 |
+
|
| 86 |
+
options.download_dir = normalize_path(options.download_dir)
|
| 87 |
+
ensure_dir(options.download_dir)
|
| 88 |
+
|
| 89 |
+
session = self.get_default_session(options)
|
| 90 |
+
|
| 91 |
+
target_python = make_target_python(options)
|
| 92 |
+
finder = self._build_package_finder(
|
| 93 |
+
options=options,
|
| 94 |
+
session=session,
|
| 95 |
+
target_python=target_python,
|
| 96 |
+
ignore_requires_python=options.ignore_requires_python,
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
build_tracker = self.enter_context(get_build_tracker())
|
| 100 |
+
|
| 101 |
+
directory = TempDirectory(
|
| 102 |
+
delete=not options.no_clean,
|
| 103 |
+
kind="download",
|
| 104 |
+
globally_managed=True,
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
reqs = self.get_requirements(args, options, finder, session)
|
| 108 |
+
check_legacy_setup_py_options(options, reqs)
|
| 109 |
+
|
| 110 |
+
preparer = self.make_requirement_preparer(
|
| 111 |
+
temp_build_dir=directory,
|
| 112 |
+
options=options,
|
| 113 |
+
build_tracker=build_tracker,
|
| 114 |
+
session=session,
|
| 115 |
+
finder=finder,
|
| 116 |
+
download_dir=options.download_dir,
|
| 117 |
+
use_user_site=False,
|
| 118 |
+
verbosity=self.verbosity,
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
resolver = self.make_resolver(
|
| 122 |
+
preparer=preparer,
|
| 123 |
+
finder=finder,
|
| 124 |
+
options=options,
|
| 125 |
+
ignore_requires_python=options.ignore_requires_python,
|
| 126 |
+
use_pep517=options.use_pep517,
|
| 127 |
+
py_version_info=options.python_version,
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
self.trace_basic_info(finder)
|
| 131 |
+
|
| 132 |
+
requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
|
| 133 |
+
|
| 134 |
+
downloaded: List[str] = []
|
| 135 |
+
for req in requirement_set.requirements.values():
|
| 136 |
+
if req.satisfied_by is None:
|
| 137 |
+
assert req.name is not None
|
| 138 |
+
preparer.save_linked_requirement(req)
|
| 139 |
+
downloaded.append(req.name)
|
| 140 |
+
|
| 141 |
+
preparer.prepare_linked_requirements_more(requirement_set.requirements.values())
|
| 142 |
+
|
| 143 |
+
if downloaded:
|
| 144 |
+
write_output("Successfully downloaded %s", " ".join(downloaded))
|
| 145 |
+
|
| 146 |
+
return SUCCESS
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/index.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
from optparse import Values
|
| 3 |
+
from typing import Any, Iterable, List, Optional
|
| 4 |
+
|
| 5 |
+
from pip._vendor.packaging.version import Version
|
| 6 |
+
|
| 7 |
+
from pip._internal.cli import cmdoptions
|
| 8 |
+
from pip._internal.cli.req_command import IndexGroupCommand
|
| 9 |
+
from pip._internal.cli.status_codes import ERROR, SUCCESS
|
| 10 |
+
from pip._internal.commands.search import print_dist_installation_info
|
| 11 |
+
from pip._internal.exceptions import CommandError, DistributionNotFound, PipError
|
| 12 |
+
from pip._internal.index.collector import LinkCollector
|
| 13 |
+
from pip._internal.index.package_finder import PackageFinder
|
| 14 |
+
from pip._internal.models.selection_prefs import SelectionPreferences
|
| 15 |
+
from pip._internal.models.target_python import TargetPython
|
| 16 |
+
from pip._internal.network.session import PipSession
|
| 17 |
+
from pip._internal.utils.misc import write_output
|
| 18 |
+
|
| 19 |
+
logger = logging.getLogger(__name__)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class IndexCommand(IndexGroupCommand):
|
| 23 |
+
"""
|
| 24 |
+
Inspect information available from package indexes.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
ignore_require_venv = True
|
| 28 |
+
usage = """
|
| 29 |
+
%prog versions <package>
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
def add_options(self) -> None:
|
| 33 |
+
cmdoptions.add_target_python_options(self.cmd_opts)
|
| 34 |
+
|
| 35 |
+
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
|
| 36 |
+
self.cmd_opts.add_option(cmdoptions.pre())
|
| 37 |
+
self.cmd_opts.add_option(cmdoptions.no_binary())
|
| 38 |
+
self.cmd_opts.add_option(cmdoptions.only_binary())
|
| 39 |
+
|
| 40 |
+
index_opts = cmdoptions.make_option_group(
|
| 41 |
+
cmdoptions.index_group,
|
| 42 |
+
self.parser,
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
self.parser.insert_option_group(0, index_opts)
|
| 46 |
+
self.parser.insert_option_group(0, self.cmd_opts)
|
| 47 |
+
|
| 48 |
+
def run(self, options: Values, args: List[str]) -> int:
|
| 49 |
+
handlers = {
|
| 50 |
+
"versions": self.get_available_package_versions,
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
logger.warning(
|
| 54 |
+
"pip index is currently an experimental command. "
|
| 55 |
+
"It may be removed/changed in a future release "
|
| 56 |
+
"without prior warning."
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
# Determine action
|
| 60 |
+
if not args or args[0] not in handlers:
|
| 61 |
+
logger.error(
|
| 62 |
+
"Need an action (%s) to perform.",
|
| 63 |
+
", ".join(sorted(handlers)),
|
| 64 |
+
)
|
| 65 |
+
return ERROR
|
| 66 |
+
|
| 67 |
+
action = args[0]
|
| 68 |
+
|
| 69 |
+
# Error handling happens here, not in the action-handlers.
|
| 70 |
+
try:
|
| 71 |
+
handlers[action](options, args[1:])
|
| 72 |
+
except PipError as e:
|
| 73 |
+
logger.error(e.args[0])
|
| 74 |
+
return ERROR
|
| 75 |
+
|
| 76 |
+
return SUCCESS
|
| 77 |
+
|
| 78 |
+
def _build_package_finder(
|
| 79 |
+
self,
|
| 80 |
+
options: Values,
|
| 81 |
+
session: PipSession,
|
| 82 |
+
target_python: Optional[TargetPython] = None,
|
| 83 |
+
ignore_requires_python: Optional[bool] = None,
|
| 84 |
+
) -> PackageFinder:
|
| 85 |
+
"""
|
| 86 |
+
Create a package finder appropriate to the index command.
|
| 87 |
+
"""
|
| 88 |
+
link_collector = LinkCollector.create(session, options=options)
|
| 89 |
+
|
| 90 |
+
# Pass allow_yanked=False to ignore yanked versions.
|
| 91 |
+
selection_prefs = SelectionPreferences(
|
| 92 |
+
allow_yanked=False,
|
| 93 |
+
allow_all_prereleases=options.pre,
|
| 94 |
+
ignore_requires_python=ignore_requires_python,
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
return PackageFinder.create(
|
| 98 |
+
link_collector=link_collector,
|
| 99 |
+
selection_prefs=selection_prefs,
|
| 100 |
+
target_python=target_python,
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
def get_available_package_versions(self, options: Values, args: List[Any]) -> None:
|
| 104 |
+
if len(args) != 1:
|
| 105 |
+
raise CommandError("You need to specify exactly one argument")
|
| 106 |
+
|
| 107 |
+
target_python = cmdoptions.make_target_python(options)
|
| 108 |
+
query = args[0]
|
| 109 |
+
|
| 110 |
+
with self._build_session(options) as session:
|
| 111 |
+
finder = self._build_package_finder(
|
| 112 |
+
options=options,
|
| 113 |
+
session=session,
|
| 114 |
+
target_python=target_python,
|
| 115 |
+
ignore_requires_python=options.ignore_requires_python,
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
versions: Iterable[Version] = (
|
| 119 |
+
candidate.version for candidate in finder.find_all_candidates(query)
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
if not options.pre:
|
| 123 |
+
# Remove prereleases
|
| 124 |
+
versions = (
|
| 125 |
+
version for version in versions if not version.is_prerelease
|
| 126 |
+
)
|
| 127 |
+
versions = set(versions)
|
| 128 |
+
|
| 129 |
+
if not versions:
|
| 130 |
+
raise DistributionNotFound(
|
| 131 |
+
f"No matching distribution found for {query}"
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
formatted_versions = [str(ver) for ver in sorted(versions, reverse=True)]
|
| 135 |
+
latest = formatted_versions[0]
|
| 136 |
+
|
| 137 |
+
write_output(f"{query} ({latest})")
|
| 138 |
+
write_output("Available versions: {}".format(", ".join(formatted_versions)))
|
| 139 |
+
print_dist_installation_info(query, latest)
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/list.py
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import logging
|
| 3 |
+
from optparse import Values
|
| 4 |
+
from typing import TYPE_CHECKING, Generator, List, Optional, Sequence, Tuple, cast
|
| 5 |
+
|
| 6 |
+
from pip._vendor.packaging.utils import canonicalize_name
|
| 7 |
+
from pip._vendor.packaging.version import Version
|
| 8 |
+
|
| 9 |
+
from pip._internal.cli import cmdoptions
|
| 10 |
+
from pip._internal.cli.index_command import IndexGroupCommand
|
| 11 |
+
from pip._internal.cli.status_codes import SUCCESS
|
| 12 |
+
from pip._internal.exceptions import CommandError
|
| 13 |
+
from pip._internal.metadata import BaseDistribution, get_environment
|
| 14 |
+
from pip._internal.models.selection_prefs import SelectionPreferences
|
| 15 |
+
from pip._internal.utils.compat import stdlib_pkgs
|
| 16 |
+
from pip._internal.utils.misc import tabulate, write_output
|
| 17 |
+
|
| 18 |
+
if TYPE_CHECKING:
|
| 19 |
+
from pip._internal.index.package_finder import PackageFinder
|
| 20 |
+
from pip._internal.network.session import PipSession
|
| 21 |
+
|
| 22 |
+
class _DistWithLatestInfo(BaseDistribution):
|
| 23 |
+
"""Give the distribution object a couple of extra fields.
|
| 24 |
+
|
| 25 |
+
These will be populated during ``get_outdated()``. This is dirty but
|
| 26 |
+
makes the rest of the code much cleaner.
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
latest_version: Version
|
| 30 |
+
latest_filetype: str
|
| 31 |
+
|
| 32 |
+
_ProcessedDists = Sequence[_DistWithLatestInfo]
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
logger = logging.getLogger(__name__)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class ListCommand(IndexGroupCommand):
|
| 39 |
+
"""
|
| 40 |
+
List installed packages, including editables.
|
| 41 |
+
|
| 42 |
+
Packages are listed in a case-insensitive sorted order.
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
ignore_require_venv = True
|
| 46 |
+
usage = """
|
| 47 |
+
%prog [options]"""
|
| 48 |
+
|
| 49 |
+
def add_options(self) -> None:
|
| 50 |
+
self.cmd_opts.add_option(
|
| 51 |
+
"-o",
|
| 52 |
+
"--outdated",
|
| 53 |
+
action="store_true",
|
| 54 |
+
default=False,
|
| 55 |
+
help="List outdated packages",
|
| 56 |
+
)
|
| 57 |
+
self.cmd_opts.add_option(
|
| 58 |
+
"-u",
|
| 59 |
+
"--uptodate",
|
| 60 |
+
action="store_true",
|
| 61 |
+
default=False,
|
| 62 |
+
help="List uptodate packages",
|
| 63 |
+
)
|
| 64 |
+
self.cmd_opts.add_option(
|
| 65 |
+
"-e",
|
| 66 |
+
"--editable",
|
| 67 |
+
action="store_true",
|
| 68 |
+
default=False,
|
| 69 |
+
help="List editable projects.",
|
| 70 |
+
)
|
| 71 |
+
self.cmd_opts.add_option(
|
| 72 |
+
"-l",
|
| 73 |
+
"--local",
|
| 74 |
+
action="store_true",
|
| 75 |
+
default=False,
|
| 76 |
+
help=(
|
| 77 |
+
"If in a virtualenv that has global access, do not list "
|
| 78 |
+
"globally-installed packages."
|
| 79 |
+
),
|
| 80 |
+
)
|
| 81 |
+
self.cmd_opts.add_option(
|
| 82 |
+
"--user",
|
| 83 |
+
dest="user",
|
| 84 |
+
action="store_true",
|
| 85 |
+
default=False,
|
| 86 |
+
help="Only output packages installed in user-site.",
|
| 87 |
+
)
|
| 88 |
+
self.cmd_opts.add_option(cmdoptions.list_path())
|
| 89 |
+
self.cmd_opts.add_option(
|
| 90 |
+
"--pre",
|
| 91 |
+
action="store_true",
|
| 92 |
+
default=False,
|
| 93 |
+
help=(
|
| 94 |
+
"Include pre-release and development versions. By default, "
|
| 95 |
+
"pip only finds stable versions."
|
| 96 |
+
),
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
self.cmd_opts.add_option(
|
| 100 |
+
"--format",
|
| 101 |
+
action="store",
|
| 102 |
+
dest="list_format",
|
| 103 |
+
default="columns",
|
| 104 |
+
choices=("columns", "freeze", "json"),
|
| 105 |
+
help=(
|
| 106 |
+
"Select the output format among: columns (default), freeze, or json. "
|
| 107 |
+
"The 'freeze' format cannot be used with the --outdated option."
|
| 108 |
+
),
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
self.cmd_opts.add_option(
|
| 112 |
+
"--not-required",
|
| 113 |
+
action="store_true",
|
| 114 |
+
dest="not_required",
|
| 115 |
+
help="List packages that are not dependencies of installed packages.",
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
self.cmd_opts.add_option(
|
| 119 |
+
"--exclude-editable",
|
| 120 |
+
action="store_false",
|
| 121 |
+
dest="include_editable",
|
| 122 |
+
help="Exclude editable package from output.",
|
| 123 |
+
)
|
| 124 |
+
self.cmd_opts.add_option(
|
| 125 |
+
"--include-editable",
|
| 126 |
+
action="store_true",
|
| 127 |
+
dest="include_editable",
|
| 128 |
+
help="Include editable package from output.",
|
| 129 |
+
default=True,
|
| 130 |
+
)
|
| 131 |
+
self.cmd_opts.add_option(cmdoptions.list_exclude())
|
| 132 |
+
index_opts = cmdoptions.make_option_group(cmdoptions.index_group, self.parser)
|
| 133 |
+
|
| 134 |
+
self.parser.insert_option_group(0, index_opts)
|
| 135 |
+
self.parser.insert_option_group(0, self.cmd_opts)
|
| 136 |
+
|
| 137 |
+
def handle_pip_version_check(self, options: Values) -> None:
|
| 138 |
+
if options.outdated or options.uptodate:
|
| 139 |
+
super().handle_pip_version_check(options)
|
| 140 |
+
|
| 141 |
+
def _build_package_finder(
|
| 142 |
+
self, options: Values, session: "PipSession"
|
| 143 |
+
) -> "PackageFinder":
|
| 144 |
+
"""
|
| 145 |
+
Create a package finder appropriate to this list command.
|
| 146 |
+
"""
|
| 147 |
+
# Lazy import the heavy index modules as most list invocations won't need 'em.
|
| 148 |
+
from pip._internal.index.collector import LinkCollector
|
| 149 |
+
from pip._internal.index.package_finder import PackageFinder
|
| 150 |
+
|
| 151 |
+
link_collector = LinkCollector.create(session, options=options)
|
| 152 |
+
|
| 153 |
+
# Pass allow_yanked=False to ignore yanked versions.
|
| 154 |
+
selection_prefs = SelectionPreferences(
|
| 155 |
+
allow_yanked=False,
|
| 156 |
+
allow_all_prereleases=options.pre,
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
return PackageFinder.create(
|
| 160 |
+
link_collector=link_collector,
|
| 161 |
+
selection_prefs=selection_prefs,
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
def run(self, options: Values, args: List[str]) -> int:
|
| 165 |
+
if options.outdated and options.uptodate:
|
| 166 |
+
raise CommandError("Options --outdated and --uptodate cannot be combined.")
|
| 167 |
+
|
| 168 |
+
if options.outdated and options.list_format == "freeze":
|
| 169 |
+
raise CommandError(
|
| 170 |
+
"List format 'freeze' cannot be used with the --outdated option."
|
| 171 |
+
)
|
| 172 |
+
|
| 173 |
+
cmdoptions.check_list_path_option(options)
|
| 174 |
+
|
| 175 |
+
skip = set(stdlib_pkgs)
|
| 176 |
+
if options.excludes:
|
| 177 |
+
skip.update(canonicalize_name(n) for n in options.excludes)
|
| 178 |
+
|
| 179 |
+
packages: _ProcessedDists = [
|
| 180 |
+
cast("_DistWithLatestInfo", d)
|
| 181 |
+
for d in get_environment(options.path).iter_installed_distributions(
|
| 182 |
+
local_only=options.local,
|
| 183 |
+
user_only=options.user,
|
| 184 |
+
editables_only=options.editable,
|
| 185 |
+
include_editables=options.include_editable,
|
| 186 |
+
skip=skip,
|
| 187 |
+
)
|
| 188 |
+
]
|
| 189 |
+
|
| 190 |
+
# get_not_required must be called firstly in order to find and
|
| 191 |
+
# filter out all dependencies correctly. Otherwise a package
|
| 192 |
+
# can't be identified as requirement because some parent packages
|
| 193 |
+
# could be filtered out before.
|
| 194 |
+
if options.not_required:
|
| 195 |
+
packages = self.get_not_required(packages, options)
|
| 196 |
+
|
| 197 |
+
if options.outdated:
|
| 198 |
+
packages = self.get_outdated(packages, options)
|
| 199 |
+
elif options.uptodate:
|
| 200 |
+
packages = self.get_uptodate(packages, options)
|
| 201 |
+
|
| 202 |
+
self.output_package_listing(packages, options)
|
| 203 |
+
return SUCCESS
|
| 204 |
+
|
| 205 |
+
def get_outdated(
|
| 206 |
+
self, packages: "_ProcessedDists", options: Values
|
| 207 |
+
) -> "_ProcessedDists":
|
| 208 |
+
return [
|
| 209 |
+
dist
|
| 210 |
+
for dist in self.iter_packages_latest_infos(packages, options)
|
| 211 |
+
if dist.latest_version > dist.version
|
| 212 |
+
]
|
| 213 |
+
|
| 214 |
+
def get_uptodate(
|
| 215 |
+
self, packages: "_ProcessedDists", options: Values
|
| 216 |
+
) -> "_ProcessedDists":
|
| 217 |
+
return [
|
| 218 |
+
dist
|
| 219 |
+
for dist in self.iter_packages_latest_infos(packages, options)
|
| 220 |
+
if dist.latest_version == dist.version
|
| 221 |
+
]
|
| 222 |
+
|
| 223 |
+
def get_not_required(
|
| 224 |
+
self, packages: "_ProcessedDists", options: Values
|
| 225 |
+
) -> "_ProcessedDists":
|
| 226 |
+
dep_keys = {
|
| 227 |
+
canonicalize_name(dep.name)
|
| 228 |
+
for dist in packages
|
| 229 |
+
for dep in (dist.iter_dependencies() or ())
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
# Create a set to remove duplicate packages, and cast it to a list
|
| 233 |
+
# to keep the return type consistent with get_outdated and
|
| 234 |
+
# get_uptodate
|
| 235 |
+
return list({pkg for pkg in packages if pkg.canonical_name not in dep_keys})
|
| 236 |
+
|
| 237 |
+
def iter_packages_latest_infos(
|
| 238 |
+
self, packages: "_ProcessedDists", options: Values
|
| 239 |
+
) -> Generator["_DistWithLatestInfo", None, None]:
|
| 240 |
+
with self._build_session(options) as session:
|
| 241 |
+
finder = self._build_package_finder(options, session)
|
| 242 |
+
|
| 243 |
+
def latest_info(
|
| 244 |
+
dist: "_DistWithLatestInfo",
|
| 245 |
+
) -> Optional["_DistWithLatestInfo"]:
|
| 246 |
+
all_candidates = finder.find_all_candidates(dist.canonical_name)
|
| 247 |
+
if not options.pre:
|
| 248 |
+
# Remove prereleases
|
| 249 |
+
all_candidates = [
|
| 250 |
+
candidate
|
| 251 |
+
for candidate in all_candidates
|
| 252 |
+
if not candidate.version.is_prerelease
|
| 253 |
+
]
|
| 254 |
+
|
| 255 |
+
evaluator = finder.make_candidate_evaluator(
|
| 256 |
+
project_name=dist.canonical_name,
|
| 257 |
+
)
|
| 258 |
+
best_candidate = evaluator.sort_best_candidate(all_candidates)
|
| 259 |
+
if best_candidate is None:
|
| 260 |
+
return None
|
| 261 |
+
|
| 262 |
+
remote_version = best_candidate.version
|
| 263 |
+
if best_candidate.link.is_wheel:
|
| 264 |
+
typ = "wheel"
|
| 265 |
+
else:
|
| 266 |
+
typ = "sdist"
|
| 267 |
+
dist.latest_version = remote_version
|
| 268 |
+
dist.latest_filetype = typ
|
| 269 |
+
return dist
|
| 270 |
+
|
| 271 |
+
for dist in map(latest_info, packages):
|
| 272 |
+
if dist is not None:
|
| 273 |
+
yield dist
|
| 274 |
+
|
| 275 |
+
def output_package_listing(
|
| 276 |
+
self, packages: "_ProcessedDists", options: Values
|
| 277 |
+
) -> None:
|
| 278 |
+
packages = sorted(
|
| 279 |
+
packages,
|
| 280 |
+
key=lambda dist: dist.canonical_name,
|
| 281 |
+
)
|
| 282 |
+
if options.list_format == "columns" and packages:
|
| 283 |
+
data, header = format_for_columns(packages, options)
|
| 284 |
+
self.output_package_listing_columns(data, header)
|
| 285 |
+
elif options.list_format == "freeze":
|
| 286 |
+
for dist in packages:
|
| 287 |
+
if options.verbose >= 1:
|
| 288 |
+
write_output(
|
| 289 |
+
"%s==%s (%s)", dist.raw_name, dist.version, dist.location
|
| 290 |
+
)
|
| 291 |
+
else:
|
| 292 |
+
write_output("%s==%s", dist.raw_name, dist.version)
|
| 293 |
+
elif options.list_format == "json":
|
| 294 |
+
write_output(format_for_json(packages, options))
|
| 295 |
+
|
| 296 |
+
def output_package_listing_columns(
|
| 297 |
+
self, data: List[List[str]], header: List[str]
|
| 298 |
+
) -> None:
|
| 299 |
+
# insert the header first: we need to know the size of column names
|
| 300 |
+
if len(data) > 0:
|
| 301 |
+
data.insert(0, header)
|
| 302 |
+
|
| 303 |
+
pkg_strings, sizes = tabulate(data)
|
| 304 |
+
|
| 305 |
+
# Create and add a separator.
|
| 306 |
+
if len(data) > 0:
|
| 307 |
+
pkg_strings.insert(1, " ".join("-" * x for x in sizes))
|
| 308 |
+
|
| 309 |
+
for val in pkg_strings:
|
| 310 |
+
write_output(val)
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
def format_for_columns(
|
| 314 |
+
pkgs: "_ProcessedDists", options: Values
|
| 315 |
+
) -> Tuple[List[List[str]], List[str]]:
|
| 316 |
+
"""
|
| 317 |
+
Convert the package data into something usable
|
| 318 |
+
by output_package_listing_columns.
|
| 319 |
+
"""
|
| 320 |
+
header = ["Package", "Version"]
|
| 321 |
+
|
| 322 |
+
running_outdated = options.outdated
|
| 323 |
+
if running_outdated:
|
| 324 |
+
header.extend(["Latest", "Type"])
|
| 325 |
+
|
| 326 |
+
has_editables = any(x.editable for x in pkgs)
|
| 327 |
+
if has_editables:
|
| 328 |
+
header.append("Editable project location")
|
| 329 |
+
|
| 330 |
+
if options.verbose >= 1:
|
| 331 |
+
header.append("Location")
|
| 332 |
+
if options.verbose >= 1:
|
| 333 |
+
header.append("Installer")
|
| 334 |
+
|
| 335 |
+
data = []
|
| 336 |
+
for proj in pkgs:
|
| 337 |
+
# if we're working on the 'outdated' list, separate out the
|
| 338 |
+
# latest_version and type
|
| 339 |
+
row = [proj.raw_name, proj.raw_version]
|
| 340 |
+
|
| 341 |
+
if running_outdated:
|
| 342 |
+
row.append(str(proj.latest_version))
|
| 343 |
+
row.append(proj.latest_filetype)
|
| 344 |
+
|
| 345 |
+
if has_editables:
|
| 346 |
+
row.append(proj.editable_project_location or "")
|
| 347 |
+
|
| 348 |
+
if options.verbose >= 1:
|
| 349 |
+
row.append(proj.location or "")
|
| 350 |
+
if options.verbose >= 1:
|
| 351 |
+
row.append(proj.installer)
|
| 352 |
+
|
| 353 |
+
data.append(row)
|
| 354 |
+
|
| 355 |
+
return data, header
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
def format_for_json(packages: "_ProcessedDists", options: Values) -> str:
|
| 359 |
+
data = []
|
| 360 |
+
for dist in packages:
|
| 361 |
+
info = {
|
| 362 |
+
"name": dist.raw_name,
|
| 363 |
+
"version": str(dist.version),
|
| 364 |
+
}
|
| 365 |
+
if options.verbose >= 1:
|
| 366 |
+
info["location"] = dist.location or ""
|
| 367 |
+
info["installer"] = dist.installer
|
| 368 |
+
if options.outdated:
|
| 369 |
+
info["latest_version"] = str(dist.latest_version)
|
| 370 |
+
info["latest_filetype"] = dist.latest_filetype
|
| 371 |
+
editable_project_location = dist.editable_project_location
|
| 372 |
+
if editable_project_location:
|
| 373 |
+
info["editable_project_location"] = editable_project_location
|
| 374 |
+
data.append(info)
|
| 375 |
+
return json.dumps(data)
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/commands/wheel.py
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
import shutil
|
| 4 |
+
from optparse import Values
|
| 5 |
+
from typing import List
|
| 6 |
+
|
| 7 |
+
from pip._internal.cache import WheelCache
|
| 8 |
+
from pip._internal.cli import cmdoptions
|
| 9 |
+
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
|
| 10 |
+
from pip._internal.cli.status_codes import SUCCESS
|
| 11 |
+
from pip._internal.exceptions import CommandError
|
| 12 |
+
from pip._internal.operations.build.build_tracker import get_build_tracker
|
| 13 |
+
from pip._internal.req.req_install import (
|
| 14 |
+
InstallRequirement,
|
| 15 |
+
check_legacy_setup_py_options,
|
| 16 |
+
)
|
| 17 |
+
from pip._internal.utils.misc import ensure_dir, normalize_path
|
| 18 |
+
from pip._internal.utils.temp_dir import TempDirectory
|
| 19 |
+
from pip._internal.wheel_builder import build, should_build_for_wheel_command
|
| 20 |
+
|
| 21 |
+
logger = logging.getLogger(__name__)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class WheelCommand(RequirementCommand):
|
| 25 |
+
"""
|
| 26 |
+
Build Wheel archives for your requirements and dependencies.
|
| 27 |
+
|
| 28 |
+
Wheel is a built-package format, and offers the advantage of not
|
| 29 |
+
recompiling your software during every install. For more details, see the
|
| 30 |
+
wheel docs: https://wheel.readthedocs.io/en/latest/
|
| 31 |
+
|
| 32 |
+
'pip wheel' uses the build system interface as described here:
|
| 33 |
+
https://pip.pypa.io/en/stable/reference/build-system/
|
| 34 |
+
|
| 35 |
+
"""
|
| 36 |
+
|
| 37 |
+
usage = """
|
| 38 |
+
%prog [options] <requirement specifier> ...
|
| 39 |
+
%prog [options] -r <requirements file> ...
|
| 40 |
+
%prog [options] [-e] <vcs project url> ...
|
| 41 |
+
%prog [options] [-e] <local project path> ...
|
| 42 |
+
%prog [options] <archive url/path> ..."""
|
| 43 |
+
|
| 44 |
+
def add_options(self) -> None:
|
| 45 |
+
self.cmd_opts.add_option(
|
| 46 |
+
"-w",
|
| 47 |
+
"--wheel-dir",
|
| 48 |
+
dest="wheel_dir",
|
| 49 |
+
metavar="dir",
|
| 50 |
+
default=os.curdir,
|
| 51 |
+
help=(
|
| 52 |
+
"Build wheels into <dir>, where the default is the "
|
| 53 |
+
"current working directory."
|
| 54 |
+
),
|
| 55 |
+
)
|
| 56 |
+
self.cmd_opts.add_option(cmdoptions.no_binary())
|
| 57 |
+
self.cmd_opts.add_option(cmdoptions.only_binary())
|
| 58 |
+
self.cmd_opts.add_option(cmdoptions.prefer_binary())
|
| 59 |
+
self.cmd_opts.add_option(cmdoptions.no_build_isolation())
|
| 60 |
+
self.cmd_opts.add_option(cmdoptions.use_pep517())
|
| 61 |
+
self.cmd_opts.add_option(cmdoptions.no_use_pep517())
|
| 62 |
+
self.cmd_opts.add_option(cmdoptions.check_build_deps())
|
| 63 |
+
self.cmd_opts.add_option(cmdoptions.constraints())
|
| 64 |
+
self.cmd_opts.add_option(cmdoptions.editable())
|
| 65 |
+
self.cmd_opts.add_option(cmdoptions.requirements())
|
| 66 |
+
self.cmd_opts.add_option(cmdoptions.src())
|
| 67 |
+
self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
|
| 68 |
+
self.cmd_opts.add_option(cmdoptions.no_deps())
|
| 69 |
+
self.cmd_opts.add_option(cmdoptions.progress_bar())
|
| 70 |
+
|
| 71 |
+
self.cmd_opts.add_option(
|
| 72 |
+
"--no-verify",
|
| 73 |
+
dest="no_verify",
|
| 74 |
+
action="store_true",
|
| 75 |
+
default=False,
|
| 76 |
+
help="Don't verify if built wheel is valid.",
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
self.cmd_opts.add_option(cmdoptions.config_settings())
|
| 80 |
+
self.cmd_opts.add_option(cmdoptions.build_options())
|
| 81 |
+
self.cmd_opts.add_option(cmdoptions.global_options())
|
| 82 |
+
|
| 83 |
+
self.cmd_opts.add_option(
|
| 84 |
+
"--pre",
|
| 85 |
+
action="store_true",
|
| 86 |
+
default=False,
|
| 87 |
+
help=(
|
| 88 |
+
"Include pre-release and development versions. By default, "
|
| 89 |
+
"pip only finds stable versions."
|
| 90 |
+
),
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
self.cmd_opts.add_option(cmdoptions.require_hashes())
|
| 94 |
+
|
| 95 |
+
index_opts = cmdoptions.make_option_group(
|
| 96 |
+
cmdoptions.index_group,
|
| 97 |
+
self.parser,
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
self.parser.insert_option_group(0, index_opts)
|
| 101 |
+
self.parser.insert_option_group(0, self.cmd_opts)
|
| 102 |
+
|
| 103 |
+
@with_cleanup
|
| 104 |
+
def run(self, options: Values, args: List[str]) -> int:
|
| 105 |
+
session = self.get_default_session(options)
|
| 106 |
+
|
| 107 |
+
finder = self._build_package_finder(options, session)
|
| 108 |
+
|
| 109 |
+
options.wheel_dir = normalize_path(options.wheel_dir)
|
| 110 |
+
ensure_dir(options.wheel_dir)
|
| 111 |
+
|
| 112 |
+
build_tracker = self.enter_context(get_build_tracker())
|
| 113 |
+
|
| 114 |
+
directory = TempDirectory(
|
| 115 |
+
delete=not options.no_clean,
|
| 116 |
+
kind="wheel",
|
| 117 |
+
globally_managed=True,
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
reqs = self.get_requirements(args, options, finder, session)
|
| 121 |
+
check_legacy_setup_py_options(options, reqs)
|
| 122 |
+
|
| 123 |
+
wheel_cache = WheelCache(options.cache_dir)
|
| 124 |
+
|
| 125 |
+
preparer = self.make_requirement_preparer(
|
| 126 |
+
temp_build_dir=directory,
|
| 127 |
+
options=options,
|
| 128 |
+
build_tracker=build_tracker,
|
| 129 |
+
session=session,
|
| 130 |
+
finder=finder,
|
| 131 |
+
download_dir=options.wheel_dir,
|
| 132 |
+
use_user_site=False,
|
| 133 |
+
verbosity=self.verbosity,
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
resolver = self.make_resolver(
|
| 137 |
+
preparer=preparer,
|
| 138 |
+
finder=finder,
|
| 139 |
+
options=options,
|
| 140 |
+
wheel_cache=wheel_cache,
|
| 141 |
+
ignore_requires_python=options.ignore_requires_python,
|
| 142 |
+
use_pep517=options.use_pep517,
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
self.trace_basic_info(finder)
|
| 146 |
+
|
| 147 |
+
requirement_set = resolver.resolve(reqs, check_supported_wheels=True)
|
| 148 |
+
|
| 149 |
+
reqs_to_build: List[InstallRequirement] = []
|
| 150 |
+
for req in requirement_set.requirements.values():
|
| 151 |
+
if req.is_wheel:
|
| 152 |
+
preparer.save_linked_requirement(req)
|
| 153 |
+
elif should_build_for_wheel_command(req):
|
| 154 |
+
reqs_to_build.append(req)
|
| 155 |
+
|
| 156 |
+
preparer.prepare_linked_requirements_more(requirement_set.requirements.values())
|
| 157 |
+
|
| 158 |
+
# build wheels
|
| 159 |
+
build_successes, build_failures = build(
|
| 160 |
+
reqs_to_build,
|
| 161 |
+
wheel_cache=wheel_cache,
|
| 162 |
+
verify=(not options.no_verify),
|
| 163 |
+
build_options=options.build_options or [],
|
| 164 |
+
global_options=options.global_options or [],
|
| 165 |
+
)
|
| 166 |
+
for req in build_successes:
|
| 167 |
+
assert req.link and req.link.is_wheel
|
| 168 |
+
assert req.local_file_path
|
| 169 |
+
# copy from cache to target directory
|
| 170 |
+
try:
|
| 171 |
+
shutil.copy(req.local_file_path, options.wheel_dir)
|
| 172 |
+
except OSError as e:
|
| 173 |
+
logger.warning(
|
| 174 |
+
"Building wheel for %s failed: %s",
|
| 175 |
+
req.name,
|
| 176 |
+
e,
|
| 177 |
+
)
|
| 178 |
+
build_failures.append(req)
|
| 179 |
+
if len(build_failures) != 0:
|
| 180 |
+
raise CommandError("Failed to build one or more wheels")
|
| 181 |
+
|
| 182 |
+
return SUCCESS
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/__init__.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import contextlib
|
| 2 |
+
import functools
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
from typing import TYPE_CHECKING, List, Optional, Type, cast
|
| 6 |
+
|
| 7 |
+
from pip._internal.utils.misc import strtobool
|
| 8 |
+
|
| 9 |
+
from .base import BaseDistribution, BaseEnvironment, FilesystemWheel, MemoryWheel, Wheel
|
| 10 |
+
|
| 11 |
+
if TYPE_CHECKING:
|
| 12 |
+
from typing import Literal, Protocol
|
| 13 |
+
else:
|
| 14 |
+
Protocol = object
|
| 15 |
+
|
| 16 |
+
__all__ = [
|
| 17 |
+
"BaseDistribution",
|
| 18 |
+
"BaseEnvironment",
|
| 19 |
+
"FilesystemWheel",
|
| 20 |
+
"MemoryWheel",
|
| 21 |
+
"Wheel",
|
| 22 |
+
"get_default_environment",
|
| 23 |
+
"get_environment",
|
| 24 |
+
"get_wheel_distribution",
|
| 25 |
+
"select_backend",
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _should_use_importlib_metadata() -> bool:
|
| 30 |
+
"""Whether to use the ``importlib.metadata`` or ``pkg_resources`` backend.
|
| 31 |
+
|
| 32 |
+
By default, pip uses ``importlib.metadata`` on Python 3.11+, and
|
| 33 |
+
``pkg_resources`` otherwise. This can be overridden by a couple of ways:
|
| 34 |
+
|
| 35 |
+
* If environment variable ``_PIP_USE_IMPORTLIB_METADATA`` is set, it
|
| 36 |
+
dictates whether ``importlib.metadata`` is used, regardless of Python
|
| 37 |
+
version.
|
| 38 |
+
* On Python 3.11+, Python distributors can patch ``importlib.metadata``
|
| 39 |
+
to add a global constant ``_PIP_USE_IMPORTLIB_METADATA = False``. This
|
| 40 |
+
makes pip use ``pkg_resources`` (unless the user set the aforementioned
|
| 41 |
+
environment variable to *True*).
|
| 42 |
+
"""
|
| 43 |
+
with contextlib.suppress(KeyError, ValueError):
|
| 44 |
+
return bool(strtobool(os.environ["_PIP_USE_IMPORTLIB_METADATA"]))
|
| 45 |
+
if sys.version_info < (3, 11):
|
| 46 |
+
return False
|
| 47 |
+
import importlib.metadata
|
| 48 |
+
|
| 49 |
+
return bool(getattr(importlib.metadata, "_PIP_USE_IMPORTLIB_METADATA", True))
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
class Backend(Protocol):
|
| 53 |
+
NAME: 'Literal["importlib", "pkg_resources"]'
|
| 54 |
+
Distribution: Type[BaseDistribution]
|
| 55 |
+
Environment: Type[BaseEnvironment]
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
@functools.lru_cache(maxsize=None)
|
| 59 |
+
def select_backend() -> Backend:
|
| 60 |
+
if _should_use_importlib_metadata():
|
| 61 |
+
from . import importlib
|
| 62 |
+
|
| 63 |
+
return cast(Backend, importlib)
|
| 64 |
+
from . import pkg_resources
|
| 65 |
+
|
| 66 |
+
return cast(Backend, pkg_resources)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def get_default_environment() -> BaseEnvironment:
|
| 70 |
+
"""Get the default representation for the current environment.
|
| 71 |
+
|
| 72 |
+
This returns an Environment instance from the chosen backend. The default
|
| 73 |
+
Environment instance should be built from ``sys.path`` and may use caching
|
| 74 |
+
to share instance state across calls.
|
| 75 |
+
"""
|
| 76 |
+
return select_backend().Environment.default()
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def get_environment(paths: Optional[List[str]]) -> BaseEnvironment:
|
| 80 |
+
"""Get a representation of the environment specified by ``paths``.
|
| 81 |
+
|
| 82 |
+
This returns an Environment instance from the chosen backend based on the
|
| 83 |
+
given import paths. The backend must build a fresh instance representing
|
| 84 |
+
the state of installed distributions when this function is called.
|
| 85 |
+
"""
|
| 86 |
+
return select_backend().Environment.from_paths(paths)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def get_directory_distribution(directory: str) -> BaseDistribution:
|
| 90 |
+
"""Get the distribution metadata representation in the specified directory.
|
| 91 |
+
|
| 92 |
+
This returns a Distribution instance from the chosen backend based on
|
| 93 |
+
the given on-disk ``.dist-info`` directory.
|
| 94 |
+
"""
|
| 95 |
+
return select_backend().Distribution.from_directory(directory)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def get_wheel_distribution(wheel: Wheel, canonical_name: str) -> BaseDistribution:
|
| 99 |
+
"""Get the representation of the specified wheel's distribution metadata.
|
| 100 |
+
|
| 101 |
+
This returns a Distribution instance from the chosen backend based on
|
| 102 |
+
the given wheel's ``.dist-info`` directory.
|
| 103 |
+
|
| 104 |
+
:param canonical_name: Normalized project name of the given wheel.
|
| 105 |
+
"""
|
| 106 |
+
return select_backend().Distribution.from_wheel(wheel, canonical_name)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def get_metadata_distribution(
|
| 110 |
+
metadata_contents: bytes,
|
| 111 |
+
filename: str,
|
| 112 |
+
canonical_name: str,
|
| 113 |
+
) -> BaseDistribution:
|
| 114 |
+
"""Get the dist representation of the specified METADATA file contents.
|
| 115 |
+
|
| 116 |
+
This returns a Distribution instance from the chosen backend sourced from the data
|
| 117 |
+
in `metadata_contents`.
|
| 118 |
+
|
| 119 |
+
:param metadata_contents: Contents of a METADATA file within a dist, or one served
|
| 120 |
+
via PEP 658.
|
| 121 |
+
:param filename: Filename for the dist this metadata represents.
|
| 122 |
+
:param canonical_name: Normalized project name of the given dist.
|
| 123 |
+
"""
|
| 124 |
+
return select_backend().Distribution.from_metadata_file_contents(
|
| 125 |
+
metadata_contents,
|
| 126 |
+
filename,
|
| 127 |
+
canonical_name,
|
| 128 |
+
)
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (4.79 kB). View file
|
|
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/__pycache__/_json.cpython-310.pyc
ADDED
|
Binary file (2.24 kB). View file
|
|
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/__pycache__/pkg_resources.cpython-310.pyc
ADDED
|
Binary file (11 kB). View file
|
|
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/_json.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Extracted from https://github.com/pfmoore/pkg_metadata
|
| 2 |
+
|
| 3 |
+
from email.header import Header, decode_header, make_header
|
| 4 |
+
from email.message import Message
|
| 5 |
+
from typing import Any, Dict, List, Union, cast
|
| 6 |
+
|
| 7 |
+
METADATA_FIELDS = [
|
| 8 |
+
# Name, Multiple-Use
|
| 9 |
+
("Metadata-Version", False),
|
| 10 |
+
("Name", False),
|
| 11 |
+
("Version", False),
|
| 12 |
+
("Dynamic", True),
|
| 13 |
+
("Platform", True),
|
| 14 |
+
("Supported-Platform", True),
|
| 15 |
+
("Summary", False),
|
| 16 |
+
("Description", False),
|
| 17 |
+
("Description-Content-Type", False),
|
| 18 |
+
("Keywords", False),
|
| 19 |
+
("Home-page", False),
|
| 20 |
+
("Download-URL", False),
|
| 21 |
+
("Author", False),
|
| 22 |
+
("Author-email", False),
|
| 23 |
+
("Maintainer", False),
|
| 24 |
+
("Maintainer-email", False),
|
| 25 |
+
("License", False),
|
| 26 |
+
("License-Expression", False),
|
| 27 |
+
("License-File", True),
|
| 28 |
+
("Classifier", True),
|
| 29 |
+
("Requires-Dist", True),
|
| 30 |
+
("Requires-Python", False),
|
| 31 |
+
("Requires-External", True),
|
| 32 |
+
("Project-URL", True),
|
| 33 |
+
("Provides-Extra", True),
|
| 34 |
+
("Provides-Dist", True),
|
| 35 |
+
("Obsoletes-Dist", True),
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def json_name(field: str) -> str:
|
| 40 |
+
return field.lower().replace("-", "_")
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def msg_to_json(msg: Message) -> Dict[str, Any]:
|
| 44 |
+
"""Convert a Message object into a JSON-compatible dictionary."""
|
| 45 |
+
|
| 46 |
+
def sanitise_header(h: Union[Header, str]) -> str:
|
| 47 |
+
if isinstance(h, Header):
|
| 48 |
+
chunks = []
|
| 49 |
+
for bytes, encoding in decode_header(h):
|
| 50 |
+
if encoding == "unknown-8bit":
|
| 51 |
+
try:
|
| 52 |
+
# See if UTF-8 works
|
| 53 |
+
bytes.decode("utf-8")
|
| 54 |
+
encoding = "utf-8"
|
| 55 |
+
except UnicodeDecodeError:
|
| 56 |
+
# If not, latin1 at least won't fail
|
| 57 |
+
encoding = "latin1"
|
| 58 |
+
chunks.append((bytes, encoding))
|
| 59 |
+
return str(make_header(chunks))
|
| 60 |
+
return str(h)
|
| 61 |
+
|
| 62 |
+
result = {}
|
| 63 |
+
for field, multi in METADATA_FIELDS:
|
| 64 |
+
if field not in msg:
|
| 65 |
+
continue
|
| 66 |
+
key = json_name(field)
|
| 67 |
+
if multi:
|
| 68 |
+
value: Union[str, List[str]] = [
|
| 69 |
+
sanitise_header(v) for v in msg.get_all(field) # type: ignore
|
| 70 |
+
]
|
| 71 |
+
else:
|
| 72 |
+
value = sanitise_header(msg.get(field)) # type: ignore
|
| 73 |
+
if key == "keywords":
|
| 74 |
+
# Accept both comma-separated and space-separated
|
| 75 |
+
# forms, for better compatibility with old data.
|
| 76 |
+
if "," in value:
|
| 77 |
+
value = [v.strip() for v in value.split(",")]
|
| 78 |
+
else:
|
| 79 |
+
value = value.split()
|
| 80 |
+
result[key] = value
|
| 81 |
+
|
| 82 |
+
payload = cast(str, msg.get_payload())
|
| 83 |
+
if payload:
|
| 84 |
+
result["description"] = payload
|
| 85 |
+
|
| 86 |
+
return result
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/base.py
ADDED
|
@@ -0,0 +1,688 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv
|
| 2 |
+
import email.message
|
| 3 |
+
import functools
|
| 4 |
+
import json
|
| 5 |
+
import logging
|
| 6 |
+
import pathlib
|
| 7 |
+
import re
|
| 8 |
+
import zipfile
|
| 9 |
+
from typing import (
|
| 10 |
+
IO,
|
| 11 |
+
Any,
|
| 12 |
+
Collection,
|
| 13 |
+
Container,
|
| 14 |
+
Dict,
|
| 15 |
+
Iterable,
|
| 16 |
+
Iterator,
|
| 17 |
+
List,
|
| 18 |
+
NamedTuple,
|
| 19 |
+
Optional,
|
| 20 |
+
Protocol,
|
| 21 |
+
Tuple,
|
| 22 |
+
Union,
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
from pip._vendor.packaging.requirements import Requirement
|
| 26 |
+
from pip._vendor.packaging.specifiers import InvalidSpecifier, SpecifierSet
|
| 27 |
+
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
|
| 28 |
+
from pip._vendor.packaging.version import Version
|
| 29 |
+
|
| 30 |
+
from pip._internal.exceptions import NoneMetadataError
|
| 31 |
+
from pip._internal.locations import site_packages, user_site
|
| 32 |
+
from pip._internal.models.direct_url import (
|
| 33 |
+
DIRECT_URL_METADATA_NAME,
|
| 34 |
+
DirectUrl,
|
| 35 |
+
DirectUrlValidationError,
|
| 36 |
+
)
|
| 37 |
+
from pip._internal.utils.compat import stdlib_pkgs # TODO: Move definition here.
|
| 38 |
+
from pip._internal.utils.egg_link import egg_link_path_from_sys_path
|
| 39 |
+
from pip._internal.utils.misc import is_local, normalize_path
|
| 40 |
+
from pip._internal.utils.urls import url_to_path
|
| 41 |
+
|
| 42 |
+
from ._json import msg_to_json
|
| 43 |
+
|
| 44 |
+
InfoPath = Union[str, pathlib.PurePath]
|
| 45 |
+
|
| 46 |
+
logger = logging.getLogger(__name__)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
class BaseEntryPoint(Protocol):
|
| 50 |
+
@property
|
| 51 |
+
def name(self) -> str:
|
| 52 |
+
raise NotImplementedError()
|
| 53 |
+
|
| 54 |
+
@property
|
| 55 |
+
def value(self) -> str:
|
| 56 |
+
raise NotImplementedError()
|
| 57 |
+
|
| 58 |
+
@property
|
| 59 |
+
def group(self) -> str:
|
| 60 |
+
raise NotImplementedError()
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def _convert_installed_files_path(
|
| 64 |
+
entry: Tuple[str, ...],
|
| 65 |
+
info: Tuple[str, ...],
|
| 66 |
+
) -> str:
|
| 67 |
+
"""Convert a legacy installed-files.txt path into modern RECORD path.
|
| 68 |
+
|
| 69 |
+
The legacy format stores paths relative to the info directory, while the
|
| 70 |
+
modern format stores paths relative to the package root, e.g. the
|
| 71 |
+
site-packages directory.
|
| 72 |
+
|
| 73 |
+
:param entry: Path parts of the installed-files.txt entry.
|
| 74 |
+
:param info: Path parts of the egg-info directory relative to package root.
|
| 75 |
+
:returns: The converted entry.
|
| 76 |
+
|
| 77 |
+
For best compatibility with symlinks, this does not use ``abspath()`` or
|
| 78 |
+
``Path.resolve()``, but tries to work with path parts:
|
| 79 |
+
|
| 80 |
+
1. While ``entry`` starts with ``..``, remove the equal amounts of parts
|
| 81 |
+
from ``info``; if ``info`` is empty, start appending ``..`` instead.
|
| 82 |
+
2. Join the two directly.
|
| 83 |
+
"""
|
| 84 |
+
while entry and entry[0] == "..":
|
| 85 |
+
if not info or info[-1] == "..":
|
| 86 |
+
info += ("..",)
|
| 87 |
+
else:
|
| 88 |
+
info = info[:-1]
|
| 89 |
+
entry = entry[1:]
|
| 90 |
+
return str(pathlib.Path(*info, *entry))
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
class RequiresEntry(NamedTuple):
|
| 94 |
+
requirement: str
|
| 95 |
+
extra: str
|
| 96 |
+
marker: str
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
class BaseDistribution(Protocol):
|
| 100 |
+
@classmethod
|
| 101 |
+
def from_directory(cls, directory: str) -> "BaseDistribution":
|
| 102 |
+
"""Load the distribution from a metadata directory.
|
| 103 |
+
|
| 104 |
+
:param directory: Path to a metadata directory, e.g. ``.dist-info``.
|
| 105 |
+
"""
|
| 106 |
+
raise NotImplementedError()
|
| 107 |
+
|
| 108 |
+
@classmethod
|
| 109 |
+
def from_metadata_file_contents(
|
| 110 |
+
cls,
|
| 111 |
+
metadata_contents: bytes,
|
| 112 |
+
filename: str,
|
| 113 |
+
project_name: str,
|
| 114 |
+
) -> "BaseDistribution":
|
| 115 |
+
"""Load the distribution from the contents of a METADATA file.
|
| 116 |
+
|
| 117 |
+
This is used to implement PEP 658 by generating a "shallow" dist object that can
|
| 118 |
+
be used for resolution without downloading or building the actual dist yet.
|
| 119 |
+
|
| 120 |
+
:param metadata_contents: The contents of a METADATA file.
|
| 121 |
+
:param filename: File name for the dist with this metadata.
|
| 122 |
+
:param project_name: Name of the project this dist represents.
|
| 123 |
+
"""
|
| 124 |
+
raise NotImplementedError()
|
| 125 |
+
|
| 126 |
+
@classmethod
|
| 127 |
+
def from_wheel(cls, wheel: "Wheel", name: str) -> "BaseDistribution":
|
| 128 |
+
"""Load the distribution from a given wheel.
|
| 129 |
+
|
| 130 |
+
:param wheel: A concrete wheel definition.
|
| 131 |
+
:param name: File name of the wheel.
|
| 132 |
+
|
| 133 |
+
:raises InvalidWheel: Whenever loading of the wheel causes a
|
| 134 |
+
:py:exc:`zipfile.BadZipFile` exception to be thrown.
|
| 135 |
+
:raises UnsupportedWheel: If the wheel is a valid zip, but malformed
|
| 136 |
+
internally.
|
| 137 |
+
"""
|
| 138 |
+
raise NotImplementedError()
|
| 139 |
+
|
| 140 |
+
def __repr__(self) -> str:
|
| 141 |
+
return f"{self.raw_name} {self.raw_version} ({self.location})"
|
| 142 |
+
|
| 143 |
+
def __str__(self) -> str:
|
| 144 |
+
return f"{self.raw_name} {self.raw_version}"
|
| 145 |
+
|
| 146 |
+
@property
|
| 147 |
+
def location(self) -> Optional[str]:
|
| 148 |
+
"""Where the distribution is loaded from.
|
| 149 |
+
|
| 150 |
+
A string value is not necessarily a filesystem path, since distributions
|
| 151 |
+
can be loaded from other sources, e.g. arbitrary zip archives. ``None``
|
| 152 |
+
means the distribution is created in-memory.
|
| 153 |
+
|
| 154 |
+
Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
|
| 155 |
+
this is a symbolic link, we want to preserve the relative path between
|
| 156 |
+
it and files in the distribution.
|
| 157 |
+
"""
|
| 158 |
+
raise NotImplementedError()
|
| 159 |
+
|
| 160 |
+
@property
|
| 161 |
+
def editable_project_location(self) -> Optional[str]:
|
| 162 |
+
"""The project location for editable distributions.
|
| 163 |
+
|
| 164 |
+
This is the directory where pyproject.toml or setup.py is located.
|
| 165 |
+
None if the distribution is not installed in editable mode.
|
| 166 |
+
"""
|
| 167 |
+
# TODO: this property is relatively costly to compute, memoize it ?
|
| 168 |
+
direct_url = self.direct_url
|
| 169 |
+
if direct_url:
|
| 170 |
+
if direct_url.is_local_editable():
|
| 171 |
+
return url_to_path(direct_url.url)
|
| 172 |
+
else:
|
| 173 |
+
# Search for an .egg-link file by walking sys.path, as it was
|
| 174 |
+
# done before by dist_is_editable().
|
| 175 |
+
egg_link_path = egg_link_path_from_sys_path(self.raw_name)
|
| 176 |
+
if egg_link_path:
|
| 177 |
+
# TODO: get project location from second line of egg_link file
|
| 178 |
+
# (https://github.com/pypa/pip/issues/10243)
|
| 179 |
+
return self.location
|
| 180 |
+
return None
|
| 181 |
+
|
| 182 |
+
@property
|
| 183 |
+
def installed_location(self) -> Optional[str]:
|
| 184 |
+
"""The distribution's "installed" location.
|
| 185 |
+
|
| 186 |
+
This should generally be a ``site-packages`` directory. This is
|
| 187 |
+
usually ``dist.location``, except for legacy develop-installed packages,
|
| 188 |
+
where ``dist.location`` is the source code location, and this is where
|
| 189 |
+
the ``.egg-link`` file is.
|
| 190 |
+
|
| 191 |
+
The returned location is normalized (in particular, with symlinks removed).
|
| 192 |
+
"""
|
| 193 |
+
raise NotImplementedError()
|
| 194 |
+
|
| 195 |
+
@property
|
| 196 |
+
def info_location(self) -> Optional[str]:
|
| 197 |
+
"""Location of the .[egg|dist]-info directory or file.
|
| 198 |
+
|
| 199 |
+
Similarly to ``location``, a string value is not necessarily a
|
| 200 |
+
filesystem path. ``None`` means the distribution is created in-memory.
|
| 201 |
+
|
| 202 |
+
For a modern .dist-info installation on disk, this should be something
|
| 203 |
+
like ``{location}/{raw_name}-{version}.dist-info``.
|
| 204 |
+
|
| 205 |
+
Do not canonicalize this value with e.g. ``pathlib.Path.resolve()``. If
|
| 206 |
+
this is a symbolic link, we want to preserve the relative path between
|
| 207 |
+
it and other files in the distribution.
|
| 208 |
+
"""
|
| 209 |
+
raise NotImplementedError()
|
| 210 |
+
|
| 211 |
+
@property
|
| 212 |
+
def installed_by_distutils(self) -> bool:
|
| 213 |
+
"""Whether this distribution is installed with legacy distutils format.
|
| 214 |
+
|
| 215 |
+
A distribution installed with "raw" distutils not patched by setuptools
|
| 216 |
+
uses one single file at ``info_location`` to store metadata. We need to
|
| 217 |
+
treat this specially on uninstallation.
|
| 218 |
+
"""
|
| 219 |
+
info_location = self.info_location
|
| 220 |
+
if not info_location:
|
| 221 |
+
return False
|
| 222 |
+
return pathlib.Path(info_location).is_file()
|
| 223 |
+
|
| 224 |
+
@property
|
| 225 |
+
def installed_as_egg(self) -> bool:
|
| 226 |
+
"""Whether this distribution is installed as an egg.
|
| 227 |
+
|
| 228 |
+
This usually indicates the distribution was installed by (older versions
|
| 229 |
+
of) easy_install.
|
| 230 |
+
"""
|
| 231 |
+
location = self.location
|
| 232 |
+
if not location:
|
| 233 |
+
return False
|
| 234 |
+
return location.endswith(".egg")
|
| 235 |
+
|
| 236 |
+
@property
|
| 237 |
+
def installed_with_setuptools_egg_info(self) -> bool:
|
| 238 |
+
"""Whether this distribution is installed with the ``.egg-info`` format.
|
| 239 |
+
|
| 240 |
+
This usually indicates the distribution was installed with setuptools
|
| 241 |
+
with an old pip version or with ``single-version-externally-managed``.
|
| 242 |
+
|
| 243 |
+
Note that this ensure the metadata store is a directory. distutils can
|
| 244 |
+
also installs an ``.egg-info``, but as a file, not a directory. This
|
| 245 |
+
property is *False* for that case. Also see ``installed_by_distutils``.
|
| 246 |
+
"""
|
| 247 |
+
info_location = self.info_location
|
| 248 |
+
if not info_location:
|
| 249 |
+
return False
|
| 250 |
+
if not info_location.endswith(".egg-info"):
|
| 251 |
+
return False
|
| 252 |
+
return pathlib.Path(info_location).is_dir()
|
| 253 |
+
|
| 254 |
+
@property
|
| 255 |
+
def installed_with_dist_info(self) -> bool:
|
| 256 |
+
"""Whether this distribution is installed with the "modern format".
|
| 257 |
+
|
| 258 |
+
This indicates a "modern" installation, e.g. storing metadata in the
|
| 259 |
+
``.dist-info`` directory. This applies to installations made by
|
| 260 |
+
setuptools (but through pip, not directly), or anything using the
|
| 261 |
+
standardized build backend interface (PEP 517).
|
| 262 |
+
"""
|
| 263 |
+
info_location = self.info_location
|
| 264 |
+
if not info_location:
|
| 265 |
+
return False
|
| 266 |
+
if not info_location.endswith(".dist-info"):
|
| 267 |
+
return False
|
| 268 |
+
return pathlib.Path(info_location).is_dir()
|
| 269 |
+
|
| 270 |
+
@property
|
| 271 |
+
def canonical_name(self) -> NormalizedName:
|
| 272 |
+
raise NotImplementedError()
|
| 273 |
+
|
| 274 |
+
@property
|
| 275 |
+
def version(self) -> Version:
|
| 276 |
+
raise NotImplementedError()
|
| 277 |
+
|
| 278 |
+
@property
|
| 279 |
+
def raw_version(self) -> str:
|
| 280 |
+
raise NotImplementedError()
|
| 281 |
+
|
| 282 |
+
@property
|
| 283 |
+
def setuptools_filename(self) -> str:
|
| 284 |
+
"""Convert a project name to its setuptools-compatible filename.
|
| 285 |
+
|
| 286 |
+
This is a copy of ``pkg_resources.to_filename()`` for compatibility.
|
| 287 |
+
"""
|
| 288 |
+
return self.raw_name.replace("-", "_")
|
| 289 |
+
|
| 290 |
+
@property
|
| 291 |
+
def direct_url(self) -> Optional[DirectUrl]:
|
| 292 |
+
"""Obtain a DirectUrl from this distribution.
|
| 293 |
+
|
| 294 |
+
Returns None if the distribution has no `direct_url.json` metadata,
|
| 295 |
+
or if `direct_url.json` is invalid.
|
| 296 |
+
"""
|
| 297 |
+
try:
|
| 298 |
+
content = self.read_text(DIRECT_URL_METADATA_NAME)
|
| 299 |
+
except FileNotFoundError:
|
| 300 |
+
return None
|
| 301 |
+
try:
|
| 302 |
+
return DirectUrl.from_json(content)
|
| 303 |
+
except (
|
| 304 |
+
UnicodeDecodeError,
|
| 305 |
+
json.JSONDecodeError,
|
| 306 |
+
DirectUrlValidationError,
|
| 307 |
+
) as e:
|
| 308 |
+
logger.warning(
|
| 309 |
+
"Error parsing %s for %s: %s",
|
| 310 |
+
DIRECT_URL_METADATA_NAME,
|
| 311 |
+
self.canonical_name,
|
| 312 |
+
e,
|
| 313 |
+
)
|
| 314 |
+
return None
|
| 315 |
+
|
| 316 |
+
@property
|
| 317 |
+
def installer(self) -> str:
|
| 318 |
+
try:
|
| 319 |
+
installer_text = self.read_text("INSTALLER")
|
| 320 |
+
except (OSError, ValueError, NoneMetadataError):
|
| 321 |
+
return "" # Fail silently if the installer file cannot be read.
|
| 322 |
+
for line in installer_text.splitlines():
|
| 323 |
+
cleaned_line = line.strip()
|
| 324 |
+
if cleaned_line:
|
| 325 |
+
return cleaned_line
|
| 326 |
+
return ""
|
| 327 |
+
|
| 328 |
+
@property
|
| 329 |
+
def requested(self) -> bool:
|
| 330 |
+
return self.is_file("REQUESTED")
|
| 331 |
+
|
| 332 |
+
@property
|
| 333 |
+
def editable(self) -> bool:
|
| 334 |
+
return bool(self.editable_project_location)
|
| 335 |
+
|
| 336 |
+
@property
|
| 337 |
+
def local(self) -> bool:
|
| 338 |
+
"""If distribution is installed in the current virtual environment.
|
| 339 |
+
|
| 340 |
+
Always True if we're not in a virtualenv.
|
| 341 |
+
"""
|
| 342 |
+
if self.installed_location is None:
|
| 343 |
+
return False
|
| 344 |
+
return is_local(self.installed_location)
|
| 345 |
+
|
| 346 |
+
@property
|
| 347 |
+
def in_usersite(self) -> bool:
|
| 348 |
+
if self.installed_location is None or user_site is None:
|
| 349 |
+
return False
|
| 350 |
+
return self.installed_location.startswith(normalize_path(user_site))
|
| 351 |
+
|
| 352 |
+
@property
|
| 353 |
+
def in_site_packages(self) -> bool:
|
| 354 |
+
if self.installed_location is None or site_packages is None:
|
| 355 |
+
return False
|
| 356 |
+
return self.installed_location.startswith(normalize_path(site_packages))
|
| 357 |
+
|
| 358 |
+
def is_file(self, path: InfoPath) -> bool:
|
| 359 |
+
"""Check whether an entry in the info directory is a file."""
|
| 360 |
+
raise NotImplementedError()
|
| 361 |
+
|
| 362 |
+
def iter_distutils_script_names(self) -> Iterator[str]:
|
| 363 |
+
"""Find distutils 'scripts' entries metadata.
|
| 364 |
+
|
| 365 |
+
If 'scripts' is supplied in ``setup.py``, distutils records those in the
|
| 366 |
+
installed distribution's ``scripts`` directory, a file for each script.
|
| 367 |
+
"""
|
| 368 |
+
raise NotImplementedError()
|
| 369 |
+
|
| 370 |
+
def read_text(self, path: InfoPath) -> str:
|
| 371 |
+
"""Read a file in the info directory.
|
| 372 |
+
|
| 373 |
+
:raise FileNotFoundError: If ``path`` does not exist in the directory.
|
| 374 |
+
:raise NoneMetadataError: If ``path`` exists in the info directory, but
|
| 375 |
+
cannot be read.
|
| 376 |
+
"""
|
| 377 |
+
raise NotImplementedError()
|
| 378 |
+
|
| 379 |
+
def iter_entry_points(self) -> Iterable[BaseEntryPoint]:
|
| 380 |
+
raise NotImplementedError()
|
| 381 |
+
|
| 382 |
+
def _metadata_impl(self) -> email.message.Message:
|
| 383 |
+
raise NotImplementedError()
|
| 384 |
+
|
| 385 |
+
@functools.cached_property
|
| 386 |
+
def metadata(self) -> email.message.Message:
|
| 387 |
+
"""Metadata of distribution parsed from e.g. METADATA or PKG-INFO.
|
| 388 |
+
|
| 389 |
+
This should return an empty message if the metadata file is unavailable.
|
| 390 |
+
|
| 391 |
+
:raises NoneMetadataError: If the metadata file is available, but does
|
| 392 |
+
not contain valid metadata.
|
| 393 |
+
"""
|
| 394 |
+
metadata = self._metadata_impl()
|
| 395 |
+
self._add_egg_info_requires(metadata)
|
| 396 |
+
return metadata
|
| 397 |
+
|
| 398 |
+
@property
|
| 399 |
+
def metadata_dict(self) -> Dict[str, Any]:
|
| 400 |
+
"""PEP 566 compliant JSON-serializable representation of METADATA or PKG-INFO.
|
| 401 |
+
|
| 402 |
+
This should return an empty dict if the metadata file is unavailable.
|
| 403 |
+
|
| 404 |
+
:raises NoneMetadataError: If the metadata file is available, but does
|
| 405 |
+
not contain valid metadata.
|
| 406 |
+
"""
|
| 407 |
+
return msg_to_json(self.metadata)
|
| 408 |
+
|
| 409 |
+
@property
|
| 410 |
+
def metadata_version(self) -> Optional[str]:
|
| 411 |
+
"""Value of "Metadata-Version:" in distribution metadata, if available."""
|
| 412 |
+
return self.metadata.get("Metadata-Version")
|
| 413 |
+
|
| 414 |
+
@property
|
| 415 |
+
def raw_name(self) -> str:
|
| 416 |
+
"""Value of "Name:" in distribution metadata."""
|
| 417 |
+
# The metadata should NEVER be missing the Name: key, but if it somehow
|
| 418 |
+
# does, fall back to the known canonical name.
|
| 419 |
+
return self.metadata.get("Name", self.canonical_name)
|
| 420 |
+
|
| 421 |
+
@property
|
| 422 |
+
def requires_python(self) -> SpecifierSet:
|
| 423 |
+
"""Value of "Requires-Python:" in distribution metadata.
|
| 424 |
+
|
| 425 |
+
If the key does not exist or contains an invalid value, an empty
|
| 426 |
+
SpecifierSet should be returned.
|
| 427 |
+
"""
|
| 428 |
+
value = self.metadata.get("Requires-Python")
|
| 429 |
+
if value is None:
|
| 430 |
+
return SpecifierSet()
|
| 431 |
+
try:
|
| 432 |
+
# Convert to str to satisfy the type checker; this can be a Header object.
|
| 433 |
+
spec = SpecifierSet(str(value))
|
| 434 |
+
except InvalidSpecifier as e:
|
| 435 |
+
message = "Package %r has an invalid Requires-Python: %s"
|
| 436 |
+
logger.warning(message, self.raw_name, e)
|
| 437 |
+
return SpecifierSet()
|
| 438 |
+
return spec
|
| 439 |
+
|
| 440 |
+
def iter_dependencies(self, extras: Collection[str] = ()) -> Iterable[Requirement]:
|
| 441 |
+
"""Dependencies of this distribution.
|
| 442 |
+
|
| 443 |
+
For modern .dist-info distributions, this is the collection of
|
| 444 |
+
"Requires-Dist:" entries in distribution metadata.
|
| 445 |
+
"""
|
| 446 |
+
raise NotImplementedError()
|
| 447 |
+
|
| 448 |
+
def iter_raw_dependencies(self) -> Iterable[str]:
|
| 449 |
+
"""Raw Requires-Dist metadata."""
|
| 450 |
+
return self.metadata.get_all("Requires-Dist", [])
|
| 451 |
+
|
| 452 |
+
def iter_provided_extras(self) -> Iterable[NormalizedName]:
|
| 453 |
+
"""Extras provided by this distribution.
|
| 454 |
+
|
| 455 |
+
For modern .dist-info distributions, this is the collection of
|
| 456 |
+
"Provides-Extra:" entries in distribution metadata.
|
| 457 |
+
|
| 458 |
+
The return value of this function is expected to be normalised names,
|
| 459 |
+
per PEP 685, with the returned value being handled appropriately by
|
| 460 |
+
`iter_dependencies`.
|
| 461 |
+
"""
|
| 462 |
+
raise NotImplementedError()
|
| 463 |
+
|
| 464 |
+
def _iter_declared_entries_from_record(self) -> Optional[Iterator[str]]:
|
| 465 |
+
try:
|
| 466 |
+
text = self.read_text("RECORD")
|
| 467 |
+
except FileNotFoundError:
|
| 468 |
+
return None
|
| 469 |
+
# This extra Path-str cast normalizes entries.
|
| 470 |
+
return (str(pathlib.Path(row[0])) for row in csv.reader(text.splitlines()))
|
| 471 |
+
|
| 472 |
+
def _iter_declared_entries_from_legacy(self) -> Optional[Iterator[str]]:
|
| 473 |
+
try:
|
| 474 |
+
text = self.read_text("installed-files.txt")
|
| 475 |
+
except FileNotFoundError:
|
| 476 |
+
return None
|
| 477 |
+
paths = (p for p in text.splitlines(keepends=False) if p)
|
| 478 |
+
root = self.location
|
| 479 |
+
info = self.info_location
|
| 480 |
+
if root is None or info is None:
|
| 481 |
+
return paths
|
| 482 |
+
try:
|
| 483 |
+
info_rel = pathlib.Path(info).relative_to(root)
|
| 484 |
+
except ValueError: # info is not relative to root.
|
| 485 |
+
return paths
|
| 486 |
+
if not info_rel.parts: # info *is* root.
|
| 487 |
+
return paths
|
| 488 |
+
return (
|
| 489 |
+
_convert_installed_files_path(pathlib.Path(p).parts, info_rel.parts)
|
| 490 |
+
for p in paths
|
| 491 |
+
)
|
| 492 |
+
|
| 493 |
+
def iter_declared_entries(self) -> Optional[Iterator[str]]:
|
| 494 |
+
"""Iterate through file entries declared in this distribution.
|
| 495 |
+
|
| 496 |
+
For modern .dist-info distributions, this is the files listed in the
|
| 497 |
+
``RECORD`` metadata file. For legacy setuptools distributions, this
|
| 498 |
+
comes from ``installed-files.txt``, with entries normalized to be
|
| 499 |
+
compatible with the format used by ``RECORD``.
|
| 500 |
+
|
| 501 |
+
:return: An iterator for listed entries, or None if the distribution
|
| 502 |
+
contains neither ``RECORD`` nor ``installed-files.txt``.
|
| 503 |
+
"""
|
| 504 |
+
return (
|
| 505 |
+
self._iter_declared_entries_from_record()
|
| 506 |
+
or self._iter_declared_entries_from_legacy()
|
| 507 |
+
)
|
| 508 |
+
|
| 509 |
+
def _iter_requires_txt_entries(self) -> Iterator[RequiresEntry]:
|
| 510 |
+
"""Parse a ``requires.txt`` in an egg-info directory.
|
| 511 |
+
|
| 512 |
+
This is an INI-ish format where an egg-info stores dependencies. A
|
| 513 |
+
section name describes extra other environment markers, while each entry
|
| 514 |
+
is an arbitrary string (not a key-value pair) representing a dependency
|
| 515 |
+
as a requirement string (no markers).
|
| 516 |
+
|
| 517 |
+
There is a construct in ``importlib.metadata`` called ``Sectioned`` that
|
| 518 |
+
does mostly the same, but the format is currently considered private.
|
| 519 |
+
"""
|
| 520 |
+
try:
|
| 521 |
+
content = self.read_text("requires.txt")
|
| 522 |
+
except FileNotFoundError:
|
| 523 |
+
return
|
| 524 |
+
extra = marker = "" # Section-less entries don't have markers.
|
| 525 |
+
for line in content.splitlines():
|
| 526 |
+
line = line.strip()
|
| 527 |
+
if not line or line.startswith("#"): # Comment; ignored.
|
| 528 |
+
continue
|
| 529 |
+
if line.startswith("[") and line.endswith("]"): # A section header.
|
| 530 |
+
extra, _, marker = line.strip("[]").partition(":")
|
| 531 |
+
continue
|
| 532 |
+
yield RequiresEntry(requirement=line, extra=extra, marker=marker)
|
| 533 |
+
|
| 534 |
+
def _iter_egg_info_extras(self) -> Iterable[str]:
|
| 535 |
+
"""Get extras from the egg-info directory."""
|
| 536 |
+
known_extras = {""}
|
| 537 |
+
for entry in self._iter_requires_txt_entries():
|
| 538 |
+
extra = canonicalize_name(entry.extra)
|
| 539 |
+
if extra in known_extras:
|
| 540 |
+
continue
|
| 541 |
+
known_extras.add(extra)
|
| 542 |
+
yield extra
|
| 543 |
+
|
| 544 |
+
def _iter_egg_info_dependencies(self) -> Iterable[str]:
|
| 545 |
+
"""Get distribution dependencies from the egg-info directory.
|
| 546 |
+
|
| 547 |
+
To ease parsing, this converts a legacy dependency entry into a PEP 508
|
| 548 |
+
requirement string. Like ``_iter_requires_txt_entries()``, there is code
|
| 549 |
+
in ``importlib.metadata`` that does mostly the same, but not do exactly
|
| 550 |
+
what we need.
|
| 551 |
+
|
| 552 |
+
Namely, ``importlib.metadata`` does not normalize the extra name before
|
| 553 |
+
putting it into the requirement string, which causes marker comparison
|
| 554 |
+
to fail because the dist-info format do normalize. This is consistent in
|
| 555 |
+
all currently available PEP 517 backends, although not standardized.
|
| 556 |
+
"""
|
| 557 |
+
for entry in self._iter_requires_txt_entries():
|
| 558 |
+
extra = canonicalize_name(entry.extra)
|
| 559 |
+
if extra and entry.marker:
|
| 560 |
+
marker = f'({entry.marker}) and extra == "{extra}"'
|
| 561 |
+
elif extra:
|
| 562 |
+
marker = f'extra == "{extra}"'
|
| 563 |
+
elif entry.marker:
|
| 564 |
+
marker = entry.marker
|
| 565 |
+
else:
|
| 566 |
+
marker = ""
|
| 567 |
+
if marker:
|
| 568 |
+
yield f"{entry.requirement} ; {marker}"
|
| 569 |
+
else:
|
| 570 |
+
yield entry.requirement
|
| 571 |
+
|
| 572 |
+
def _add_egg_info_requires(self, metadata: email.message.Message) -> None:
|
| 573 |
+
"""Add egg-info requires.txt information to the metadata."""
|
| 574 |
+
if not metadata.get_all("Requires-Dist"):
|
| 575 |
+
for dep in self._iter_egg_info_dependencies():
|
| 576 |
+
metadata["Requires-Dist"] = dep
|
| 577 |
+
if not metadata.get_all("Provides-Extra"):
|
| 578 |
+
for extra in self._iter_egg_info_extras():
|
| 579 |
+
metadata["Provides-Extra"] = extra
|
| 580 |
+
|
| 581 |
+
|
| 582 |
+
class BaseEnvironment:
|
| 583 |
+
"""An environment containing distributions to introspect."""
|
| 584 |
+
|
| 585 |
+
@classmethod
|
| 586 |
+
def default(cls) -> "BaseEnvironment":
|
| 587 |
+
raise NotImplementedError()
|
| 588 |
+
|
| 589 |
+
@classmethod
|
| 590 |
+
def from_paths(cls, paths: Optional[List[str]]) -> "BaseEnvironment":
|
| 591 |
+
raise NotImplementedError()
|
| 592 |
+
|
| 593 |
+
def get_distribution(self, name: str) -> Optional["BaseDistribution"]:
|
| 594 |
+
"""Given a requirement name, return the installed distributions.
|
| 595 |
+
|
| 596 |
+
The name may not be normalized. The implementation must canonicalize
|
| 597 |
+
it for lookup.
|
| 598 |
+
"""
|
| 599 |
+
raise NotImplementedError()
|
| 600 |
+
|
| 601 |
+
def _iter_distributions(self) -> Iterator["BaseDistribution"]:
|
| 602 |
+
"""Iterate through installed distributions.
|
| 603 |
+
|
| 604 |
+
This function should be implemented by subclass, but never called
|
| 605 |
+
directly. Use the public ``iter_distribution()`` instead, which
|
| 606 |
+
implements additional logic to make sure the distributions are valid.
|
| 607 |
+
"""
|
| 608 |
+
raise NotImplementedError()
|
| 609 |
+
|
| 610 |
+
def iter_all_distributions(self) -> Iterator[BaseDistribution]:
|
| 611 |
+
"""Iterate through all installed distributions without any filtering."""
|
| 612 |
+
for dist in self._iter_distributions():
|
| 613 |
+
# Make sure the distribution actually comes from a valid Python
|
| 614 |
+
# packaging distribution. Pip's AdjacentTempDirectory leaves folders
|
| 615 |
+
# e.g. ``~atplotlib.dist-info`` if cleanup was interrupted. The
|
| 616 |
+
# valid project name pattern is taken from PEP 508.
|
| 617 |
+
project_name_valid = re.match(
|
| 618 |
+
r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$",
|
| 619 |
+
dist.canonical_name,
|
| 620 |
+
flags=re.IGNORECASE,
|
| 621 |
+
)
|
| 622 |
+
if not project_name_valid:
|
| 623 |
+
logger.warning(
|
| 624 |
+
"Ignoring invalid distribution %s (%s)",
|
| 625 |
+
dist.canonical_name,
|
| 626 |
+
dist.location,
|
| 627 |
+
)
|
| 628 |
+
continue
|
| 629 |
+
yield dist
|
| 630 |
+
|
| 631 |
+
def iter_installed_distributions(
|
| 632 |
+
self,
|
| 633 |
+
local_only: bool = True,
|
| 634 |
+
skip: Container[str] = stdlib_pkgs,
|
| 635 |
+
include_editables: bool = True,
|
| 636 |
+
editables_only: bool = False,
|
| 637 |
+
user_only: bool = False,
|
| 638 |
+
) -> Iterator[BaseDistribution]:
|
| 639 |
+
"""Return a list of installed distributions.
|
| 640 |
+
|
| 641 |
+
This is based on ``iter_all_distributions()`` with additional filtering
|
| 642 |
+
options. Note that ``iter_installed_distributions()`` without arguments
|
| 643 |
+
is *not* equal to ``iter_all_distributions()``, since some of the
|
| 644 |
+
configurations exclude packages by default.
|
| 645 |
+
|
| 646 |
+
:param local_only: If True (default), only return installations
|
| 647 |
+
local to the current virtualenv, if in a virtualenv.
|
| 648 |
+
:param skip: An iterable of canonicalized project names to ignore;
|
| 649 |
+
defaults to ``stdlib_pkgs``.
|
| 650 |
+
:param include_editables: If False, don't report editables.
|
| 651 |
+
:param editables_only: If True, only report editables.
|
| 652 |
+
:param user_only: If True, only report installations in the user
|
| 653 |
+
site directory.
|
| 654 |
+
"""
|
| 655 |
+
it = self.iter_all_distributions()
|
| 656 |
+
if local_only:
|
| 657 |
+
it = (d for d in it if d.local)
|
| 658 |
+
if not include_editables:
|
| 659 |
+
it = (d for d in it if not d.editable)
|
| 660 |
+
if editables_only:
|
| 661 |
+
it = (d for d in it if d.editable)
|
| 662 |
+
if user_only:
|
| 663 |
+
it = (d for d in it if d.in_usersite)
|
| 664 |
+
return (d for d in it if d.canonical_name not in skip)
|
| 665 |
+
|
| 666 |
+
|
| 667 |
+
class Wheel(Protocol):
|
| 668 |
+
location: str
|
| 669 |
+
|
| 670 |
+
def as_zipfile(self) -> zipfile.ZipFile:
|
| 671 |
+
raise NotImplementedError()
|
| 672 |
+
|
| 673 |
+
|
| 674 |
+
class FilesystemWheel(Wheel):
|
| 675 |
+
def __init__(self, location: str) -> None:
|
| 676 |
+
self.location = location
|
| 677 |
+
|
| 678 |
+
def as_zipfile(self) -> zipfile.ZipFile:
|
| 679 |
+
return zipfile.ZipFile(self.location, allowZip64=True)
|
| 680 |
+
|
| 681 |
+
|
| 682 |
+
class MemoryWheel(Wheel):
|
| 683 |
+
def __init__(self, location: str, stream: IO[bytes]) -> None:
|
| 684 |
+
self.location = location
|
| 685 |
+
self.stream = stream
|
| 686 |
+
|
| 687 |
+
def as_zipfile(self) -> zipfile.ZipFile:
|
| 688 |
+
return zipfile.ZipFile(self.stream, allowZip64=True)
|
mantis_evalkit/lib/python3.10/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"
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (335 Bytes). View file
|
|
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/__pycache__/_compat.cpython-310.pyc
ADDED
|
Binary file (3.48 kB). View file
|
|
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/__pycache__/_dists.cpython-310.pyc
ADDED
|
Binary file (8.84 kB). View file
|
|
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/__pycache__/_envs.cpython-310.pyc
ADDED
|
Binary file (7.71 kB). View file
|
|
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/_compat.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import importlib.metadata
|
| 2 |
+
import os
|
| 3 |
+
from typing import Any, Optional, Protocol, Tuple, cast
|
| 4 |
+
|
| 5 |
+
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class BadMetadata(ValueError):
|
| 9 |
+
def __init__(self, dist: importlib.metadata.Distribution, *, reason: str) -> None:
|
| 10 |
+
self.dist = dist
|
| 11 |
+
self.reason = reason
|
| 12 |
+
|
| 13 |
+
def __str__(self) -> str:
|
| 14 |
+
return f"Bad metadata in {self.dist} ({self.reason})"
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class BasePath(Protocol):
|
| 18 |
+
"""A protocol that various path objects conform.
|
| 19 |
+
|
| 20 |
+
This exists because importlib.metadata uses both ``pathlib.Path`` and
|
| 21 |
+
``zipfile.Path``, and we need a common base for type hints (Union does not
|
| 22 |
+
work well since ``zipfile.Path`` is too new for our linter setup).
|
| 23 |
+
|
| 24 |
+
This does not mean to be exhaustive, but only contains things that present
|
| 25 |
+
in both classes *that we need*.
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
@property
|
| 29 |
+
def name(self) -> str:
|
| 30 |
+
raise NotImplementedError()
|
| 31 |
+
|
| 32 |
+
@property
|
| 33 |
+
def parent(self) -> "BasePath":
|
| 34 |
+
raise NotImplementedError()
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def get_info_location(d: importlib.metadata.Distribution) -> Optional[BasePath]:
|
| 38 |
+
"""Find the path to the distribution's metadata directory.
|
| 39 |
+
|
| 40 |
+
HACK: This relies on importlib.metadata's private ``_path`` attribute. Not
|
| 41 |
+
all distributions exist on disk, so importlib.metadata is correct to not
|
| 42 |
+
expose the attribute as public. But pip's code base is old and not as clean,
|
| 43 |
+
so we do this to avoid having to rewrite too many things. Hopefully we can
|
| 44 |
+
eliminate this some day.
|
| 45 |
+
"""
|
| 46 |
+
return getattr(d, "_path", None)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def parse_name_and_version_from_info_directory(
|
| 50 |
+
dist: importlib.metadata.Distribution,
|
| 51 |
+
) -> Tuple[Optional[str], Optional[str]]:
|
| 52 |
+
"""Get a name and version from the metadata directory name.
|
| 53 |
+
|
| 54 |
+
This is much faster than reading distribution metadata.
|
| 55 |
+
"""
|
| 56 |
+
info_location = get_info_location(dist)
|
| 57 |
+
if info_location is None:
|
| 58 |
+
return None, None
|
| 59 |
+
|
| 60 |
+
stem, suffix = os.path.splitext(info_location.name)
|
| 61 |
+
if suffix == ".dist-info":
|
| 62 |
+
name, sep, version = stem.partition("-")
|
| 63 |
+
if sep:
|
| 64 |
+
return name, version
|
| 65 |
+
|
| 66 |
+
if suffix == ".egg-info":
|
| 67 |
+
name = stem.split("-", 1)[0]
|
| 68 |
+
return name, None
|
| 69 |
+
|
| 70 |
+
return None, None
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def get_dist_canonical_name(dist: importlib.metadata.Distribution) -> NormalizedName:
|
| 74 |
+
"""Get the distribution's normalized name.
|
| 75 |
+
|
| 76 |
+
The ``name`` attribute is only available in Python 3.10 or later. We are
|
| 77 |
+
targeting exactly that, but Mypy does not know this.
|
| 78 |
+
"""
|
| 79 |
+
if name := parse_name_and_version_from_info_directory(dist)[0]:
|
| 80 |
+
return canonicalize_name(name)
|
| 81 |
+
|
| 82 |
+
name = cast(Any, dist).name
|
| 83 |
+
if not isinstance(name, str):
|
| 84 |
+
raise BadMetadata(dist, reason="invalid metadata entry 'name'")
|
| 85 |
+
return canonicalize_name(name)
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/_dists.py
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import email.message
|
| 2 |
+
import importlib.metadata
|
| 3 |
+
import pathlib
|
| 4 |
+
import zipfile
|
| 5 |
+
from os import PathLike
|
| 6 |
+
from typing import (
|
| 7 |
+
Collection,
|
| 8 |
+
Dict,
|
| 9 |
+
Iterable,
|
| 10 |
+
Iterator,
|
| 11 |
+
Mapping,
|
| 12 |
+
Optional,
|
| 13 |
+
Sequence,
|
| 14 |
+
Union,
|
| 15 |
+
cast,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
from pip._vendor.packaging.requirements import Requirement
|
| 19 |
+
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
|
| 20 |
+
from pip._vendor.packaging.version import Version
|
| 21 |
+
from pip._vendor.packaging.version import parse as parse_version
|
| 22 |
+
|
| 23 |
+
from pip._internal.exceptions import InvalidWheel, UnsupportedWheel
|
| 24 |
+
from pip._internal.metadata.base import (
|
| 25 |
+
BaseDistribution,
|
| 26 |
+
BaseEntryPoint,
|
| 27 |
+
InfoPath,
|
| 28 |
+
Wheel,
|
| 29 |
+
)
|
| 30 |
+
from pip._internal.utils.misc import normalize_path
|
| 31 |
+
from pip._internal.utils.packaging import get_requirement
|
| 32 |
+
from pip._internal.utils.temp_dir import TempDirectory
|
| 33 |
+
from pip._internal.utils.wheel import parse_wheel, read_wheel_metadata_file
|
| 34 |
+
|
| 35 |
+
from ._compat import (
|
| 36 |
+
BasePath,
|
| 37 |
+
get_dist_canonical_name,
|
| 38 |
+
parse_name_and_version_from_info_directory,
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class WheelDistribution(importlib.metadata.Distribution):
|
| 43 |
+
"""An ``importlib.metadata.Distribution`` read from a wheel.
|
| 44 |
+
|
| 45 |
+
Although ``importlib.metadata.PathDistribution`` accepts ``zipfile.Path``,
|
| 46 |
+
its implementation is too "lazy" for pip's needs (we can't keep the ZipFile
|
| 47 |
+
handle open for the entire lifetime of the distribution object).
|
| 48 |
+
|
| 49 |
+
This implementation eagerly reads the entire metadata directory into the
|
| 50 |
+
memory instead, and operates from that.
|
| 51 |
+
"""
|
| 52 |
+
|
| 53 |
+
def __init__(
|
| 54 |
+
self,
|
| 55 |
+
files: Mapping[pathlib.PurePosixPath, bytes],
|
| 56 |
+
info_location: pathlib.PurePosixPath,
|
| 57 |
+
) -> None:
|
| 58 |
+
self._files = files
|
| 59 |
+
self.info_location = info_location
|
| 60 |
+
|
| 61 |
+
@classmethod
|
| 62 |
+
def from_zipfile(
|
| 63 |
+
cls,
|
| 64 |
+
zf: zipfile.ZipFile,
|
| 65 |
+
name: str,
|
| 66 |
+
location: str,
|
| 67 |
+
) -> "WheelDistribution":
|
| 68 |
+
info_dir, _ = parse_wheel(zf, name)
|
| 69 |
+
paths = (
|
| 70 |
+
(name, pathlib.PurePosixPath(name.split("/", 1)[-1]))
|
| 71 |
+
for name in zf.namelist()
|
| 72 |
+
if name.startswith(f"{info_dir}/")
|
| 73 |
+
)
|
| 74 |
+
files = {
|
| 75 |
+
relpath: read_wheel_metadata_file(zf, fullpath)
|
| 76 |
+
for fullpath, relpath in paths
|
| 77 |
+
}
|
| 78 |
+
info_location = pathlib.PurePosixPath(location, info_dir)
|
| 79 |
+
return cls(files, info_location)
|
| 80 |
+
|
| 81 |
+
def iterdir(self, path: InfoPath) -> Iterator[pathlib.PurePosixPath]:
|
| 82 |
+
# Only allow iterating through the metadata directory.
|
| 83 |
+
if pathlib.PurePosixPath(str(path)) in self._files:
|
| 84 |
+
return iter(self._files)
|
| 85 |
+
raise FileNotFoundError(path)
|
| 86 |
+
|
| 87 |
+
def read_text(self, filename: str) -> Optional[str]:
|
| 88 |
+
try:
|
| 89 |
+
data = self._files[pathlib.PurePosixPath(filename)]
|
| 90 |
+
except KeyError:
|
| 91 |
+
return None
|
| 92 |
+
try:
|
| 93 |
+
text = data.decode("utf-8")
|
| 94 |
+
except UnicodeDecodeError as e:
|
| 95 |
+
wheel = self.info_location.parent
|
| 96 |
+
error = f"Error decoding metadata for {wheel}: {e} in {filename} file"
|
| 97 |
+
raise UnsupportedWheel(error)
|
| 98 |
+
return text
|
| 99 |
+
|
| 100 |
+
def locate_file(self, path: Union[str, "PathLike[str]"]) -> pathlib.Path:
|
| 101 |
+
# This method doesn't make sense for our in-memory wheel, but the API
|
| 102 |
+
# requires us to define it.
|
| 103 |
+
raise NotImplementedError
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class Distribution(BaseDistribution):
|
| 107 |
+
def __init__(
|
| 108 |
+
self,
|
| 109 |
+
dist: importlib.metadata.Distribution,
|
| 110 |
+
info_location: Optional[BasePath],
|
| 111 |
+
installed_location: Optional[BasePath],
|
| 112 |
+
) -> None:
|
| 113 |
+
self._dist = dist
|
| 114 |
+
self._info_location = info_location
|
| 115 |
+
self._installed_location = installed_location
|
| 116 |
+
|
| 117 |
+
@classmethod
|
| 118 |
+
def from_directory(cls, directory: str) -> BaseDistribution:
|
| 119 |
+
info_location = pathlib.Path(directory)
|
| 120 |
+
dist = importlib.metadata.Distribution.at(info_location)
|
| 121 |
+
return cls(dist, info_location, info_location.parent)
|
| 122 |
+
|
| 123 |
+
@classmethod
|
| 124 |
+
def from_metadata_file_contents(
|
| 125 |
+
cls,
|
| 126 |
+
metadata_contents: bytes,
|
| 127 |
+
filename: str,
|
| 128 |
+
project_name: str,
|
| 129 |
+
) -> BaseDistribution:
|
| 130 |
+
# Generate temp dir to contain the metadata file, and write the file contents.
|
| 131 |
+
temp_dir = pathlib.Path(
|
| 132 |
+
TempDirectory(kind="metadata", globally_managed=True).path
|
| 133 |
+
)
|
| 134 |
+
metadata_path = temp_dir / "METADATA"
|
| 135 |
+
metadata_path.write_bytes(metadata_contents)
|
| 136 |
+
# Construct dist pointing to the newly created directory.
|
| 137 |
+
dist = importlib.metadata.Distribution.at(metadata_path.parent)
|
| 138 |
+
return cls(dist, metadata_path.parent, None)
|
| 139 |
+
|
| 140 |
+
@classmethod
|
| 141 |
+
def from_wheel(cls, wheel: Wheel, name: str) -> BaseDistribution:
|
| 142 |
+
try:
|
| 143 |
+
with wheel.as_zipfile() as zf:
|
| 144 |
+
dist = WheelDistribution.from_zipfile(zf, name, wheel.location)
|
| 145 |
+
except zipfile.BadZipFile as e:
|
| 146 |
+
raise InvalidWheel(wheel.location, name) from e
|
| 147 |
+
return cls(dist, dist.info_location, pathlib.PurePosixPath(wheel.location))
|
| 148 |
+
|
| 149 |
+
@property
|
| 150 |
+
def location(self) -> Optional[str]:
|
| 151 |
+
if self._info_location is None:
|
| 152 |
+
return None
|
| 153 |
+
return str(self._info_location.parent)
|
| 154 |
+
|
| 155 |
+
@property
|
| 156 |
+
def info_location(self) -> Optional[str]:
|
| 157 |
+
if self._info_location is None:
|
| 158 |
+
return None
|
| 159 |
+
return str(self._info_location)
|
| 160 |
+
|
| 161 |
+
@property
|
| 162 |
+
def installed_location(self) -> Optional[str]:
|
| 163 |
+
if self._installed_location is None:
|
| 164 |
+
return None
|
| 165 |
+
return normalize_path(str(self._installed_location))
|
| 166 |
+
|
| 167 |
+
@property
|
| 168 |
+
def canonical_name(self) -> NormalizedName:
|
| 169 |
+
return get_dist_canonical_name(self._dist)
|
| 170 |
+
|
| 171 |
+
@property
|
| 172 |
+
def version(self) -> Version:
|
| 173 |
+
if version := parse_name_and_version_from_info_directory(self._dist)[1]:
|
| 174 |
+
return parse_version(version)
|
| 175 |
+
return parse_version(self._dist.version)
|
| 176 |
+
|
| 177 |
+
@property
|
| 178 |
+
def raw_version(self) -> str:
|
| 179 |
+
return self._dist.version
|
| 180 |
+
|
| 181 |
+
def is_file(self, path: InfoPath) -> bool:
|
| 182 |
+
return self._dist.read_text(str(path)) is not None
|
| 183 |
+
|
| 184 |
+
def iter_distutils_script_names(self) -> Iterator[str]:
|
| 185 |
+
# A distutils installation is always "flat" (not in e.g. egg form), so
|
| 186 |
+
# if this distribution's info location is NOT a pathlib.Path (but e.g.
|
| 187 |
+
# zipfile.Path), it can never contain any distutils scripts.
|
| 188 |
+
if not isinstance(self._info_location, pathlib.Path):
|
| 189 |
+
return
|
| 190 |
+
for child in self._info_location.joinpath("scripts").iterdir():
|
| 191 |
+
yield child.name
|
| 192 |
+
|
| 193 |
+
def read_text(self, path: InfoPath) -> str:
|
| 194 |
+
content = self._dist.read_text(str(path))
|
| 195 |
+
if content is None:
|
| 196 |
+
raise FileNotFoundError(path)
|
| 197 |
+
return content
|
| 198 |
+
|
| 199 |
+
def iter_entry_points(self) -> Iterable[BaseEntryPoint]:
|
| 200 |
+
# importlib.metadata's EntryPoint structure satisfies BaseEntryPoint.
|
| 201 |
+
return self._dist.entry_points
|
| 202 |
+
|
| 203 |
+
def _metadata_impl(self) -> email.message.Message:
|
| 204 |
+
# From Python 3.10+, importlib.metadata declares PackageMetadata as the
|
| 205 |
+
# return type. This protocol is unfortunately a disaster now and misses
|
| 206 |
+
# a ton of fields that we need, including get() and get_payload(). We
|
| 207 |
+
# rely on the implementation that the object is actually a Message now,
|
| 208 |
+
# until upstream can improve the protocol. (python/cpython#94952)
|
| 209 |
+
return cast(email.message.Message, self._dist.metadata)
|
| 210 |
+
|
| 211 |
+
def iter_provided_extras(self) -> Iterable[NormalizedName]:
|
| 212 |
+
return [
|
| 213 |
+
canonicalize_name(extra)
|
| 214 |
+
for extra in self.metadata.get_all("Provides-Extra", [])
|
| 215 |
+
]
|
| 216 |
+
|
| 217 |
+
def iter_dependencies(self, extras: Collection[str] = ()) -> Iterable[Requirement]:
|
| 218 |
+
contexts: Sequence[Dict[str, str]] = [{"extra": e} for e in extras]
|
| 219 |
+
for req_string in self.metadata.get_all("Requires-Dist", []):
|
| 220 |
+
# strip() because email.message.Message.get_all() may return a leading \n
|
| 221 |
+
# in case a long header was wrapped.
|
| 222 |
+
req = get_requirement(req_string.strip())
|
| 223 |
+
if not req.marker:
|
| 224 |
+
yield req
|
| 225 |
+
elif not extras and req.marker.evaluate({"extra": ""}):
|
| 226 |
+
yield req
|
| 227 |
+
elif any(req.marker.evaluate(context) for context in contexts):
|
| 228 |
+
yield req
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/importlib/_envs.py
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import functools
|
| 2 |
+
import importlib.metadata
|
| 3 |
+
import logging
|
| 4 |
+
import os
|
| 5 |
+
import pathlib
|
| 6 |
+
import sys
|
| 7 |
+
import zipfile
|
| 8 |
+
import zipimport
|
| 9 |
+
from typing import Iterator, List, Optional, Sequence, Set, Tuple
|
| 10 |
+
|
| 11 |
+
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
|
| 12 |
+
|
| 13 |
+
from pip._internal.metadata.base import BaseDistribution, BaseEnvironment
|
| 14 |
+
from pip._internal.models.wheel import Wheel
|
| 15 |
+
from pip._internal.utils.deprecation import deprecated
|
| 16 |
+
from pip._internal.utils.filetypes import WHEEL_EXTENSION
|
| 17 |
+
|
| 18 |
+
from ._compat import BadMetadata, BasePath, get_dist_canonical_name, get_info_location
|
| 19 |
+
from ._dists import Distribution
|
| 20 |
+
|
| 21 |
+
logger = logging.getLogger(__name__)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def _looks_like_wheel(location: str) -> bool:
|
| 25 |
+
if not location.endswith(WHEEL_EXTENSION):
|
| 26 |
+
return False
|
| 27 |
+
if not os.path.isfile(location):
|
| 28 |
+
return False
|
| 29 |
+
if not Wheel.wheel_file_re.match(os.path.basename(location)):
|
| 30 |
+
return False
|
| 31 |
+
return zipfile.is_zipfile(location)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class _DistributionFinder:
|
| 35 |
+
"""Finder to locate distributions.
|
| 36 |
+
|
| 37 |
+
The main purpose of this class is to memoize found distributions' names, so
|
| 38 |
+
only one distribution is returned for each package name. At lot of pip code
|
| 39 |
+
assumes this (because it is setuptools's behavior), and not doing the same
|
| 40 |
+
can potentially cause a distribution in lower precedence path to override a
|
| 41 |
+
higher precedence one if the caller is not careful.
|
| 42 |
+
|
| 43 |
+
Eventually we probably want to make it possible to see lower precedence
|
| 44 |
+
installations as well. It's useful feature, after all.
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
FoundResult = Tuple[importlib.metadata.Distribution, Optional[BasePath]]
|
| 48 |
+
|
| 49 |
+
def __init__(self) -> None:
|
| 50 |
+
self._found_names: Set[NormalizedName] = set()
|
| 51 |
+
|
| 52 |
+
def _find_impl(self, location: str) -> Iterator[FoundResult]:
|
| 53 |
+
"""Find distributions in a location."""
|
| 54 |
+
# Skip looking inside a wheel. Since a package inside a wheel is not
|
| 55 |
+
# always valid (due to .data directories etc.), its .dist-info entry
|
| 56 |
+
# should not be considered an installed distribution.
|
| 57 |
+
if _looks_like_wheel(location):
|
| 58 |
+
return
|
| 59 |
+
# To know exactly where we find a distribution, we have to feed in the
|
| 60 |
+
# paths one by one, instead of dumping the list to importlib.metadata.
|
| 61 |
+
for dist in importlib.metadata.distributions(path=[location]):
|
| 62 |
+
info_location = get_info_location(dist)
|
| 63 |
+
try:
|
| 64 |
+
name = get_dist_canonical_name(dist)
|
| 65 |
+
except BadMetadata as e:
|
| 66 |
+
logger.warning("Skipping %s due to %s", info_location, e.reason)
|
| 67 |
+
continue
|
| 68 |
+
if name in self._found_names:
|
| 69 |
+
continue
|
| 70 |
+
self._found_names.add(name)
|
| 71 |
+
yield dist, info_location
|
| 72 |
+
|
| 73 |
+
def find(self, location: str) -> Iterator[BaseDistribution]:
|
| 74 |
+
"""Find distributions in a location.
|
| 75 |
+
|
| 76 |
+
The path can be either a directory, or a ZIP archive.
|
| 77 |
+
"""
|
| 78 |
+
for dist, info_location in self._find_impl(location):
|
| 79 |
+
if info_location is None:
|
| 80 |
+
installed_location: Optional[BasePath] = None
|
| 81 |
+
else:
|
| 82 |
+
installed_location = info_location.parent
|
| 83 |
+
yield Distribution(dist, info_location, installed_location)
|
| 84 |
+
|
| 85 |
+
def find_linked(self, location: str) -> Iterator[BaseDistribution]:
|
| 86 |
+
"""Read location in egg-link files and return distributions in there.
|
| 87 |
+
|
| 88 |
+
The path should be a directory; otherwise this returns nothing. This
|
| 89 |
+
follows how setuptools does this for compatibility. The first non-empty
|
| 90 |
+
line in the egg-link is read as a path (resolved against the egg-link's
|
| 91 |
+
containing directory if relative). Distributions found at that linked
|
| 92 |
+
location are returned.
|
| 93 |
+
"""
|
| 94 |
+
path = pathlib.Path(location)
|
| 95 |
+
if not path.is_dir():
|
| 96 |
+
return
|
| 97 |
+
for child in path.iterdir():
|
| 98 |
+
if child.suffix != ".egg-link":
|
| 99 |
+
continue
|
| 100 |
+
with child.open() as f:
|
| 101 |
+
lines = (line.strip() for line in f)
|
| 102 |
+
target_rel = next((line for line in lines if line), "")
|
| 103 |
+
if not target_rel:
|
| 104 |
+
continue
|
| 105 |
+
target_location = str(path.joinpath(target_rel))
|
| 106 |
+
for dist, info_location in self._find_impl(target_location):
|
| 107 |
+
yield Distribution(dist, info_location, path)
|
| 108 |
+
|
| 109 |
+
def _find_eggs_in_dir(self, location: str) -> Iterator[BaseDistribution]:
|
| 110 |
+
from pip._vendor.pkg_resources import find_distributions
|
| 111 |
+
|
| 112 |
+
from pip._internal.metadata import pkg_resources as legacy
|
| 113 |
+
|
| 114 |
+
with os.scandir(location) as it:
|
| 115 |
+
for entry in it:
|
| 116 |
+
if not entry.name.endswith(".egg"):
|
| 117 |
+
continue
|
| 118 |
+
for dist in find_distributions(entry.path):
|
| 119 |
+
yield legacy.Distribution(dist)
|
| 120 |
+
|
| 121 |
+
def _find_eggs_in_zip(self, location: str) -> Iterator[BaseDistribution]:
|
| 122 |
+
from pip._vendor.pkg_resources import find_eggs_in_zip
|
| 123 |
+
|
| 124 |
+
from pip._internal.metadata import pkg_resources as legacy
|
| 125 |
+
|
| 126 |
+
try:
|
| 127 |
+
importer = zipimport.zipimporter(location)
|
| 128 |
+
except zipimport.ZipImportError:
|
| 129 |
+
return
|
| 130 |
+
for dist in find_eggs_in_zip(importer, location):
|
| 131 |
+
yield legacy.Distribution(dist)
|
| 132 |
+
|
| 133 |
+
def find_eggs(self, location: str) -> Iterator[BaseDistribution]:
|
| 134 |
+
"""Find eggs in a location.
|
| 135 |
+
|
| 136 |
+
This actually uses the old *pkg_resources* backend. We likely want to
|
| 137 |
+
deprecate this so we can eventually remove the *pkg_resources*
|
| 138 |
+
dependency entirely. Before that, this should first emit a deprecation
|
| 139 |
+
warning for some versions when using the fallback since importing
|
| 140 |
+
*pkg_resources* is slow for those who don't need it.
|
| 141 |
+
"""
|
| 142 |
+
if os.path.isdir(location):
|
| 143 |
+
yield from self._find_eggs_in_dir(location)
|
| 144 |
+
if zipfile.is_zipfile(location):
|
| 145 |
+
yield from self._find_eggs_in_zip(location)
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
@functools.lru_cache(maxsize=None) # Warn a distribution exactly once.
|
| 149 |
+
def _emit_egg_deprecation(location: Optional[str]) -> None:
|
| 150 |
+
deprecated(
|
| 151 |
+
reason=f"Loading egg at {location} is deprecated.",
|
| 152 |
+
replacement="to use pip for package installation",
|
| 153 |
+
gone_in="25.1",
|
| 154 |
+
issue=12330,
|
| 155 |
+
)
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
class Environment(BaseEnvironment):
|
| 159 |
+
def __init__(self, paths: Sequence[str]) -> None:
|
| 160 |
+
self._paths = paths
|
| 161 |
+
|
| 162 |
+
@classmethod
|
| 163 |
+
def default(cls) -> BaseEnvironment:
|
| 164 |
+
return cls(sys.path)
|
| 165 |
+
|
| 166 |
+
@classmethod
|
| 167 |
+
def from_paths(cls, paths: Optional[List[str]]) -> BaseEnvironment:
|
| 168 |
+
if paths is None:
|
| 169 |
+
return cls(sys.path)
|
| 170 |
+
return cls(paths)
|
| 171 |
+
|
| 172 |
+
def _iter_distributions(self) -> Iterator[BaseDistribution]:
|
| 173 |
+
finder = _DistributionFinder()
|
| 174 |
+
for location in self._paths:
|
| 175 |
+
yield from finder.find(location)
|
| 176 |
+
for dist in finder.find_eggs(location):
|
| 177 |
+
_emit_egg_deprecation(dist.location)
|
| 178 |
+
yield dist
|
| 179 |
+
# This must go last because that's how pkg_resources tie-breaks.
|
| 180 |
+
yield from finder.find_linked(location)
|
| 181 |
+
|
| 182 |
+
def get_distribution(self, name: str) -> Optional[BaseDistribution]:
|
| 183 |
+
canonical_name = canonicalize_name(name)
|
| 184 |
+
matches = (
|
| 185 |
+
distribution
|
| 186 |
+
for distribution in self.iter_all_distributions()
|
| 187 |
+
if distribution.canonical_name == canonical_name
|
| 188 |
+
)
|
| 189 |
+
return next(matches, None)
|
mantis_evalkit/lib/python3.10/site-packages/pip/_internal/metadata/pkg_resources.py
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import email.message
|
| 2 |
+
import email.parser
|
| 3 |
+
import logging
|
| 4 |
+
import os
|
| 5 |
+
import zipfile
|
| 6 |
+
from typing import (
|
| 7 |
+
Collection,
|
| 8 |
+
Iterable,
|
| 9 |
+
Iterator,
|
| 10 |
+
List,
|
| 11 |
+
Mapping,
|
| 12 |
+
NamedTuple,
|
| 13 |
+
Optional,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
from pip._vendor import pkg_resources
|
| 17 |
+
from pip._vendor.packaging.requirements import Requirement
|
| 18 |
+
from pip._vendor.packaging.utils import NormalizedName, canonicalize_name
|
| 19 |
+
from pip._vendor.packaging.version import Version
|
| 20 |
+
from pip._vendor.packaging.version import parse as parse_version
|
| 21 |
+
|
| 22 |
+
from pip._internal.exceptions import InvalidWheel, NoneMetadataError, UnsupportedWheel
|
| 23 |
+
from pip._internal.utils.egg_link import egg_link_path_from_location
|
| 24 |
+
from pip._internal.utils.misc import display_path, normalize_path
|
| 25 |
+
from pip._internal.utils.wheel import parse_wheel, read_wheel_metadata_file
|
| 26 |
+
|
| 27 |
+
from .base import (
|
| 28 |
+
BaseDistribution,
|
| 29 |
+
BaseEntryPoint,
|
| 30 |
+
BaseEnvironment,
|
| 31 |
+
InfoPath,
|
| 32 |
+
Wheel,
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
__all__ = ["NAME", "Distribution", "Environment"]
|
| 36 |
+
|
| 37 |
+
logger = logging.getLogger(__name__)
|
| 38 |
+
|
| 39 |
+
NAME = "pkg_resources"
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class EntryPoint(NamedTuple):
|
| 43 |
+
name: str
|
| 44 |
+
value: str
|
| 45 |
+
group: str
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class InMemoryMetadata:
|
| 49 |
+
"""IMetadataProvider that reads metadata files from a dictionary.
|
| 50 |
+
|
| 51 |
+
This also maps metadata decoding exceptions to our internal exception type.
|
| 52 |
+
"""
|
| 53 |
+
|
| 54 |
+
def __init__(self, metadata: Mapping[str, bytes], wheel_name: str) -> None:
|
| 55 |
+
self._metadata = metadata
|
| 56 |
+
self._wheel_name = wheel_name
|
| 57 |
+
|
| 58 |
+
def has_metadata(self, name: str) -> bool:
|
| 59 |
+
return name in self._metadata
|
| 60 |
+
|
| 61 |
+
def get_metadata(self, name: str) -> str:
|
| 62 |
+
try:
|
| 63 |
+
return self._metadata[name].decode()
|
| 64 |
+
except UnicodeDecodeError as e:
|
| 65 |
+
# Augment the default error with the origin of the file.
|
| 66 |
+
raise UnsupportedWheel(
|
| 67 |
+
f"Error decoding metadata for {self._wheel_name}: {e} in {name} file"
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
def get_metadata_lines(self, name: str) -> Iterable[str]:
|
| 71 |
+
return pkg_resources.yield_lines(self.get_metadata(name))
|
| 72 |
+
|
| 73 |
+
def metadata_isdir(self, name: str) -> bool:
|
| 74 |
+
return False
|
| 75 |
+
|
| 76 |
+
def metadata_listdir(self, name: str) -> List[str]:
|
| 77 |
+
return []
|
| 78 |
+
|
| 79 |
+
def run_script(self, script_name: str, namespace: str) -> None:
|
| 80 |
+
pass
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
class Distribution(BaseDistribution):
|
| 84 |
+
def __init__(self, dist: pkg_resources.Distribution) -> None:
|
| 85 |
+
self._dist = dist
|
| 86 |
+
# This is populated lazily, to avoid loading metadata for all possible
|
| 87 |
+
# distributions eagerly.
|
| 88 |
+
self.__extra_mapping: Optional[Mapping[NormalizedName, str]] = None
|
| 89 |
+
|
| 90 |
+
@property
|
| 91 |
+
def _extra_mapping(self) -> Mapping[NormalizedName, str]:
|
| 92 |
+
if self.__extra_mapping is None:
|
| 93 |
+
self.__extra_mapping = {
|
| 94 |
+
canonicalize_name(extra): extra for extra in self._dist.extras
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
return self.__extra_mapping
|
| 98 |
+
|
| 99 |
+
@classmethod
|
| 100 |
+
def from_directory(cls, directory: str) -> BaseDistribution:
|
| 101 |
+
dist_dir = directory.rstrip(os.sep)
|
| 102 |
+
|
| 103 |
+
# Build a PathMetadata object, from path to metadata. :wink:
|
| 104 |
+
base_dir, dist_dir_name = os.path.split(dist_dir)
|
| 105 |
+
metadata = pkg_resources.PathMetadata(base_dir, dist_dir)
|
| 106 |
+
|
| 107 |
+
# Determine the correct Distribution object type.
|
| 108 |
+
if dist_dir.endswith(".egg-info"):
|
| 109 |
+
dist_cls = pkg_resources.Distribution
|
| 110 |
+
dist_name = os.path.splitext(dist_dir_name)[0]
|
| 111 |
+
else:
|
| 112 |
+
assert dist_dir.endswith(".dist-info")
|
| 113 |
+
dist_cls = pkg_resources.DistInfoDistribution
|
| 114 |
+
dist_name = os.path.splitext(dist_dir_name)[0].split("-")[0]
|
| 115 |
+
|
| 116 |
+
dist = dist_cls(base_dir, project_name=dist_name, metadata=metadata)
|
| 117 |
+
return cls(dist)
|
| 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 |
+
metadata_dict = {
|
| 127 |
+
"METADATA": metadata_contents,
|
| 128 |
+
}
|
| 129 |
+
dist = pkg_resources.DistInfoDistribution(
|
| 130 |
+
location=filename,
|
| 131 |
+
metadata=InMemoryMetadata(metadata_dict, filename),
|
| 132 |
+
project_name=project_name,
|
| 133 |
+
)
|
| 134 |
+
return cls(dist)
|
| 135 |
+
|
| 136 |
+
@classmethod
|
| 137 |
+
def from_wheel(cls, wheel: Wheel, name: str) -> BaseDistribution:
|
| 138 |
+
try:
|
| 139 |
+
with wheel.as_zipfile() as zf:
|
| 140 |
+
info_dir, _ = parse_wheel(zf, name)
|
| 141 |
+
metadata_dict = {
|
| 142 |
+
path.split("/", 1)[-1]: read_wheel_metadata_file(zf, path)
|
| 143 |
+
for path in zf.namelist()
|
| 144 |
+
if path.startswith(f"{info_dir}/")
|
| 145 |
+
}
|
| 146 |
+
except zipfile.BadZipFile as e:
|
| 147 |
+
raise InvalidWheel(wheel.location, name) from e
|
| 148 |
+
except UnsupportedWheel as e:
|
| 149 |
+
raise UnsupportedWheel(f"{name} has an invalid wheel, {e}")
|
| 150 |
+
dist = pkg_resources.DistInfoDistribution(
|
| 151 |
+
location=wheel.location,
|
| 152 |
+
metadata=InMemoryMetadata(metadata_dict, wheel.location),
|
| 153 |
+
project_name=name,
|
| 154 |
+
)
|
| 155 |
+
return cls(dist)
|
| 156 |
+
|
| 157 |
+
@property
|
| 158 |
+
def location(self) -> Optional[str]:
|
| 159 |
+
return self._dist.location
|
| 160 |
+
|
| 161 |
+
@property
|
| 162 |
+
def installed_location(self) -> Optional[str]:
|
| 163 |
+
egg_link = egg_link_path_from_location(self.raw_name)
|
| 164 |
+
if egg_link:
|
| 165 |
+
location = egg_link
|
| 166 |
+
elif self.location:
|
| 167 |
+
location = self.location
|
| 168 |
+
else:
|
| 169 |
+
return None
|
| 170 |
+
return normalize_path(location)
|
| 171 |
+
|
| 172 |
+
@property
|
| 173 |
+
def info_location(self) -> Optional[str]:
|
| 174 |
+
return self._dist.egg_info
|
| 175 |
+
|
| 176 |
+
@property
|
| 177 |
+
def installed_by_distutils(self) -> bool:
|
| 178 |
+
# A distutils-installed distribution is provided by FileMetadata. This
|
| 179 |
+
# provider has a "path" attribute not present anywhere else. Not the
|
| 180 |
+
# best introspection logic, but pip has been doing this for a long time.
|
| 181 |
+
try:
|
| 182 |
+
return bool(self._dist._provider.path)
|
| 183 |
+
except AttributeError:
|
| 184 |
+
return False
|
| 185 |
+
|
| 186 |
+
@property
|
| 187 |
+
def canonical_name(self) -> NormalizedName:
|
| 188 |
+
return canonicalize_name(self._dist.project_name)
|
| 189 |
+
|
| 190 |
+
@property
|
| 191 |
+
def version(self) -> Version:
|
| 192 |
+
return parse_version(self._dist.version)
|
| 193 |
+
|
| 194 |
+
@property
|
| 195 |
+
def raw_version(self) -> str:
|
| 196 |
+
return self._dist.version
|
| 197 |
+
|
| 198 |
+
def is_file(self, path: InfoPath) -> bool:
|
| 199 |
+
return self._dist.has_metadata(str(path))
|
| 200 |
+
|
| 201 |
+
def iter_distutils_script_names(self) -> Iterator[str]:
|
| 202 |
+
yield from self._dist.metadata_listdir("scripts")
|
| 203 |
+
|
| 204 |
+
def read_text(self, path: InfoPath) -> str:
|
| 205 |
+
name = str(path)
|
| 206 |
+
if not self._dist.has_metadata(name):
|
| 207 |
+
raise FileNotFoundError(name)
|
| 208 |
+
content = self._dist.get_metadata(name)
|
| 209 |
+
if content is None:
|
| 210 |
+
raise NoneMetadataError(self, name)
|
| 211 |
+
return content
|
| 212 |
+
|
| 213 |
+
def iter_entry_points(self) -> Iterable[BaseEntryPoint]:
|
| 214 |
+
for group, entries in self._dist.get_entry_map().items():
|
| 215 |
+
for name, entry_point in entries.items():
|
| 216 |
+
name, _, value = str(entry_point).partition("=")
|
| 217 |
+
yield EntryPoint(name=name.strip(), value=value.strip(), group=group)
|
| 218 |
+
|
| 219 |
+
def _metadata_impl(self) -> email.message.Message:
|
| 220 |
+
"""
|
| 221 |
+
:raises NoneMetadataError: if the distribution reports `has_metadata()`
|
| 222 |
+
True but `get_metadata()` returns None.
|
| 223 |
+
"""
|
| 224 |
+
if isinstance(self._dist, pkg_resources.DistInfoDistribution):
|
| 225 |
+
metadata_name = "METADATA"
|
| 226 |
+
else:
|
| 227 |
+
metadata_name = "PKG-INFO"
|
| 228 |
+
try:
|
| 229 |
+
metadata = self.read_text(metadata_name)
|
| 230 |
+
except FileNotFoundError:
|
| 231 |
+
if self.location:
|
| 232 |
+
displaying_path = display_path(self.location)
|
| 233 |
+
else:
|
| 234 |
+
displaying_path = repr(self.location)
|
| 235 |
+
logger.warning("No metadata found in %s", displaying_path)
|
| 236 |
+
metadata = ""
|
| 237 |
+
feed_parser = email.parser.FeedParser()
|
| 238 |
+
feed_parser.feed(metadata)
|
| 239 |
+
return feed_parser.close()
|
| 240 |
+
|
| 241 |
+
def iter_dependencies(self, extras: Collection[str] = ()) -> Iterable[Requirement]:
|
| 242 |
+
if extras:
|
| 243 |
+
relevant_extras = set(self._extra_mapping) & set(
|
| 244 |
+
map(canonicalize_name, extras)
|
| 245 |
+
)
|
| 246 |
+
extras = [self._extra_mapping[extra] for extra in relevant_extras]
|
| 247 |
+
return self._dist.requires(extras)
|
| 248 |
+
|
| 249 |
+
def iter_provided_extras(self) -> Iterable[NormalizedName]:
|
| 250 |
+
return self._extra_mapping.keys()
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
class Environment(BaseEnvironment):
|
| 254 |
+
def __init__(self, ws: pkg_resources.WorkingSet) -> None:
|
| 255 |
+
self._ws = ws
|
| 256 |
+
|
| 257 |
+
@classmethod
|
| 258 |
+
def default(cls) -> BaseEnvironment:
|
| 259 |
+
return cls(pkg_resources.working_set)
|
| 260 |
+
|
| 261 |
+
@classmethod
|
| 262 |
+
def from_paths(cls, paths: Optional[List[str]]) -> BaseEnvironment:
|
| 263 |
+
return cls(pkg_resources.WorkingSet(paths))
|
| 264 |
+
|
| 265 |
+
def _iter_distributions(self) -> Iterator[BaseDistribution]:
|
| 266 |
+
for dist in self._ws:
|
| 267 |
+
yield Distribution(dist)
|
| 268 |
+
|
| 269 |
+
def _search_distribution(self, name: str) -> Optional[BaseDistribution]:
|
| 270 |
+
"""Find a distribution matching the ``name`` in the environment.
|
| 271 |
+
|
| 272 |
+
This searches from *all* distributions available in the environment, to
|
| 273 |
+
match the behavior of ``pkg_resources.get_distribution()``.
|
| 274 |
+
"""
|
| 275 |
+
canonical_name = canonicalize_name(name)
|
| 276 |
+
for dist in self.iter_all_distributions():
|
| 277 |
+
if dist.canonical_name == canonical_name:
|
| 278 |
+
return dist
|
| 279 |
+
return None
|
| 280 |
+
|
| 281 |
+
def get_distribution(self, name: str) -> Optional[BaseDistribution]:
|
| 282 |
+
# Search the distribution by looking through the working set.
|
| 283 |
+
dist = self._search_distribution(name)
|
| 284 |
+
if dist:
|
| 285 |
+
return dist
|
| 286 |
+
|
| 287 |
+
# If distribution could not be found, call working_set.require to
|
| 288 |
+
# update the working set, and try to find the distribution again.
|
| 289 |
+
# This might happen for e.g. when you install a package twice, once
|
| 290 |
+
# using setup.py develop and again using setup.py install. Now when
|
| 291 |
+
# running pip uninstall twice, the package gets removed from the
|
| 292 |
+
# working set in the first uninstall, so we have to populate the
|
| 293 |
+
# working set again so that pip knows about it and the packages gets
|
| 294 |
+
# picked up and is successfully uninstalled the second time too.
|
| 295 |
+
try:
|
| 296 |
+
# We didn't pass in any version specifiers, so this can never
|
| 297 |
+
# raise pkg_resources.VersionConflict.
|
| 298 |
+
self._ws.require(name)
|
| 299 |
+
except pkg_resources.DistributionNotFound:
|
| 300 |
+
return None
|
| 301 |
+
return self._search_distribution(name)
|
moondream/lib/python3.10/site-packages/sympy/combinatorics/__pycache__/perm_groups.cpython-310.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:47bcbc75deeaf378fa19efee9e3b8eb60decb09007c4c5abff8694dffe80a28f
|
| 3 |
+
size 152908
|
moondream/lib/python3.10/site-packages/sympy/solvers/tests/__pycache__/test_solveset.cpython-310.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:00ad187aa087c25bcb0695035d55e6f1e47c8891bcb9183679ce3f4f0afd66bf
|
| 3 |
+
size 137709
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_add_relu_meta_dispatch.h
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
// @generated by torchgen/gen.py from DispatchKeyFunction.h
|
| 3 |
+
|
| 4 |
+
// NB: The implementing C++ file is RegisterDispatchKey.cpp
|
| 5 |
+
|
| 6 |
+
// The only #includes we need are for custom classes that have defaults in the C++ API
|
| 7 |
+
#include <c10/core/MemoryFormat.h>
|
| 8 |
+
#include <c10/core/Scalar.h>
|
| 9 |
+
#include <ATen/core/Reduction.h>
|
| 10 |
+
|
| 11 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 12 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 13 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 14 |
+
#include <ATen/core/ATen_fwd.h>
|
| 15 |
+
|
| 16 |
+
namespace at {
|
| 17 |
+
|
| 18 |
+
namespace meta {
|
| 19 |
+
|
| 20 |
+
TORCH_API at::Tensor & _add_relu_(at::Tensor & self, const at::Tensor & other, const at::Scalar & alpha=1);
|
| 21 |
+
TORCH_API at::Tensor & _add_relu_(at::Tensor & self, const at::Scalar & other, const at::Scalar & alpha=1);
|
| 22 |
+
|
| 23 |
+
} // namespace meta
|
| 24 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_cudnn_rnn_flatten_weight.h
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from Function.h
|
| 4 |
+
|
| 5 |
+
#include <ATen/Context.h>
|
| 6 |
+
#include <ATen/DeviceGuard.h>
|
| 7 |
+
#include <ATen/TensorUtils.h>
|
| 8 |
+
#include <ATen/TracerMode.h>
|
| 9 |
+
#include <ATen/core/Generator.h>
|
| 10 |
+
#include <ATen/core/Reduction.h>
|
| 11 |
+
#include <ATen/core/Tensor.h>
|
| 12 |
+
#include <c10/core/Scalar.h>
|
| 13 |
+
#include <c10/core/Storage.h>
|
| 14 |
+
#include <c10/core/TensorOptions.h>
|
| 15 |
+
#include <c10/util/Deprecated.h>
|
| 16 |
+
#include <c10/util/Optional.h>
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
#include <ATen/ops/_cudnn_rnn_flatten_weight_ops.h>
|
| 21 |
+
|
| 22 |
+
namespace at {
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
// aten::_cudnn_rnn_flatten_weight(Tensor[] weight_arr, int weight_stride0, SymInt input_size, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, bool bidirectional) -> Tensor
|
| 26 |
+
inline at::Tensor _cudnn_rnn_flatten_weight(at::TensorList weight_arr, int64_t weight_stride0, int64_t input_size, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, bool bidirectional) {
|
| 27 |
+
return at::_ops::_cudnn_rnn_flatten_weight::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional);
|
| 28 |
+
}
|
| 29 |
+
namespace symint {
|
| 30 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, int64_t>::value>>
|
| 31 |
+
at::Tensor _cudnn_rnn_flatten_weight(at::TensorList weight_arr, int64_t weight_stride0, int64_t input_size, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, bool bidirectional) {
|
| 32 |
+
return at::_ops::_cudnn_rnn_flatten_weight::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional);
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
// aten::_cudnn_rnn_flatten_weight(Tensor[] weight_arr, int weight_stride0, SymInt input_size, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, bool bidirectional) -> Tensor
|
| 37 |
+
inline at::Tensor _cudnn_rnn_flatten_weight_symint(at::TensorList weight_arr, int64_t weight_stride0, c10::SymInt input_size, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, bool bidirectional) {
|
| 38 |
+
return at::_ops::_cudnn_rnn_flatten_weight::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional);
|
| 39 |
+
}
|
| 40 |
+
namespace symint {
|
| 41 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, c10::SymInt>::value>>
|
| 42 |
+
at::Tensor _cudnn_rnn_flatten_weight(at::TensorList weight_arr, int64_t weight_stride0, c10::SymInt input_size, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, bool bidirectional) {
|
| 43 |
+
return at::_ops::_cudnn_rnn_flatten_weight::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional);
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
// aten::_cudnn_rnn_flatten_weight.out(Tensor[] weight_arr, int weight_stride0, SymInt input_size, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, bool bidirectional, *, Tensor(a!) out) -> Tensor(a!)
|
| 48 |
+
inline at::Tensor & _cudnn_rnn_flatten_weight_out(at::Tensor & out, at::TensorList weight_arr, int64_t weight_stride0, int64_t input_size, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, bool bidirectional) {
|
| 49 |
+
return at::_ops::_cudnn_rnn_flatten_weight_out::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional, out);
|
| 50 |
+
}
|
| 51 |
+
namespace symint {
|
| 52 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, int64_t>::value>>
|
| 53 |
+
at::Tensor & _cudnn_rnn_flatten_weight_out(at::Tensor & out, at::TensorList weight_arr, int64_t weight_stride0, int64_t input_size, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, bool bidirectional) {
|
| 54 |
+
return at::_ops::_cudnn_rnn_flatten_weight_out::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional, out);
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
// aten::_cudnn_rnn_flatten_weight.out(Tensor[] weight_arr, int weight_stride0, SymInt input_size, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, bool bidirectional, *, Tensor(a!) out) -> Tensor(a!)
|
| 59 |
+
inline at::Tensor & _cudnn_rnn_flatten_weight_outf(at::TensorList weight_arr, int64_t weight_stride0, int64_t input_size, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, bool bidirectional, at::Tensor & out) {
|
| 60 |
+
return at::_ops::_cudnn_rnn_flatten_weight_out::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional, out);
|
| 61 |
+
}
|
| 62 |
+
namespace symint {
|
| 63 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, int64_t>::value>>
|
| 64 |
+
at::Tensor & _cudnn_rnn_flatten_weight_outf(at::TensorList weight_arr, int64_t weight_stride0, int64_t input_size, int64_t mode, int64_t hidden_size, int64_t proj_size, int64_t num_layers, bool batch_first, bool bidirectional, at::Tensor & out) {
|
| 65 |
+
return at::_ops::_cudnn_rnn_flatten_weight_out::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional, out);
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
// aten::_cudnn_rnn_flatten_weight.out(Tensor[] weight_arr, int weight_stride0, SymInt input_size, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, bool bidirectional, *, Tensor(a!) out) -> Tensor(a!)
|
| 70 |
+
inline at::Tensor & _cudnn_rnn_flatten_weight_symint_out(at::Tensor & out, at::TensorList weight_arr, int64_t weight_stride0, c10::SymInt input_size, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, bool bidirectional) {
|
| 71 |
+
return at::_ops::_cudnn_rnn_flatten_weight_out::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional, out);
|
| 72 |
+
}
|
| 73 |
+
namespace symint {
|
| 74 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, c10::SymInt>::value>>
|
| 75 |
+
at::Tensor & _cudnn_rnn_flatten_weight_out(at::Tensor & out, at::TensorList weight_arr, int64_t weight_stride0, c10::SymInt input_size, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, bool bidirectional) {
|
| 76 |
+
return at::_ops::_cudnn_rnn_flatten_weight_out::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional, out);
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
// aten::_cudnn_rnn_flatten_weight.out(Tensor[] weight_arr, int weight_stride0, SymInt input_size, int mode, SymInt hidden_size, SymInt proj_size, int num_layers, bool batch_first, bool bidirectional, *, Tensor(a!) out) -> Tensor(a!)
|
| 81 |
+
inline at::Tensor & _cudnn_rnn_flatten_weight_symint_outf(at::TensorList weight_arr, int64_t weight_stride0, c10::SymInt input_size, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, bool bidirectional, at::Tensor & out) {
|
| 82 |
+
return at::_ops::_cudnn_rnn_flatten_weight_out::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional, out);
|
| 83 |
+
}
|
| 84 |
+
namespace symint {
|
| 85 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, c10::SymInt>::value>>
|
| 86 |
+
at::Tensor & _cudnn_rnn_flatten_weight_outf(at::TensorList weight_arr, int64_t weight_stride0, c10::SymInt input_size, int64_t mode, c10::SymInt hidden_size, c10::SymInt proj_size, int64_t num_layers, bool batch_first, bool bidirectional, at::Tensor & out) {
|
| 87 |
+
return at::_ops::_cudnn_rnn_flatten_weight_out::call(weight_arr, weight_stride0, input_size, mode, hidden_size, proj_size, num_layers, batch_first, bidirectional, out);
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
}
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_foreach_addcmul.h
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from Function.h
|
| 4 |
+
|
| 5 |
+
#include <ATen/Context.h>
|
| 6 |
+
#include <ATen/DeviceGuard.h>
|
| 7 |
+
#include <ATen/TensorUtils.h>
|
| 8 |
+
#include <ATen/TracerMode.h>
|
| 9 |
+
#include <ATen/core/Generator.h>
|
| 10 |
+
#include <ATen/core/Reduction.h>
|
| 11 |
+
#include <ATen/core/Tensor.h>
|
| 12 |
+
#include <c10/core/Scalar.h>
|
| 13 |
+
#include <c10/core/Storage.h>
|
| 14 |
+
#include <c10/core/TensorOptions.h>
|
| 15 |
+
#include <c10/util/Deprecated.h>
|
| 16 |
+
#include <c10/util/Optional.h>
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
#include <ATen/ops/_foreach_addcmul_ops.h>
|
| 21 |
+
|
| 22 |
+
namespace at {
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
// aten::_foreach_addcmul.Scalar(Tensor[] self, Tensor[] tensor1, Tensor[] tensor2, Scalar value=1) -> Tensor[]
|
| 26 |
+
inline ::std::vector<at::Tensor> _foreach_addcmul(at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, const at::Scalar & value=1) {
|
| 27 |
+
return at::_ops::_foreach_addcmul_Scalar::call(self, tensor1, tensor2, value);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
// aten::_foreach_addcmul.ScalarList(Tensor[] self, Tensor[] tensor1, Tensor[] tensor2, Scalar[] scalars) -> Tensor[]
|
| 31 |
+
inline ::std::vector<at::Tensor> _foreach_addcmul(at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, at::ArrayRef<at::Scalar> scalars) {
|
| 32 |
+
return at::_ops::_foreach_addcmul_ScalarList::call(self, tensor1, tensor2, scalars);
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
// aten::_foreach_addcmul.Tensor(Tensor[] self, Tensor[] tensor1, Tensor[] tensor2, Tensor scalars) -> Tensor[]
|
| 36 |
+
inline ::std::vector<at::Tensor> _foreach_addcmul(at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, const at::Tensor & scalars) {
|
| 37 |
+
return at::_ops::_foreach_addcmul_Tensor::call(self, tensor1, tensor2, scalars);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// aten::_foreach_addcmul_.Scalar(Tensor(a!)[] self, Tensor[] tensor1, Tensor[] tensor2, Scalar value=1) -> ()
|
| 41 |
+
inline void _foreach_addcmul_(at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, const at::Scalar & value=1) {
|
| 42 |
+
return at::_ops::_foreach_addcmul__Scalar::call(self, tensor1, tensor2, value);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
// aten::_foreach_addcmul_.ScalarList(Tensor(a!)[] self, Tensor[] tensor1, Tensor[] tensor2, Scalar[] scalars) -> ()
|
| 46 |
+
inline void _foreach_addcmul_(at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, at::ArrayRef<at::Scalar> scalars) {
|
| 47 |
+
return at::_ops::_foreach_addcmul__ScalarList::call(self, tensor1, tensor2, scalars);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
// aten::_foreach_addcmul_.Tensor(Tensor(a!)[] self, Tensor[] tensor1, Tensor[] tensor2, Tensor scalars) -> ()
|
| 51 |
+
inline void _foreach_addcmul_(at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, const at::Tensor & scalars) {
|
| 52 |
+
return at::_ops::_foreach_addcmul__Tensor::call(self, tensor1, tensor2, scalars);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
// aten::_foreach_addcmul.Scalar_out(Tensor[] self, Tensor[] tensor1, Tensor[] tensor2, Scalar value=1, *, Tensor(a!)[] out) -> ()
|
| 56 |
+
inline void _foreach_addcmul_out(at::TensorList out, at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, const at::Scalar & value=1) {
|
| 57 |
+
return at::_ops::_foreach_addcmul_Scalar_out::call(self, tensor1, tensor2, value, out);
|
| 58 |
+
}
|
| 59 |
+
// aten::_foreach_addcmul.Scalar_out(Tensor[] self, Tensor[] tensor1, Tensor[] tensor2, Scalar value=1, *, Tensor(a!)[] out) -> ()
|
| 60 |
+
inline void _foreach_addcmul_outf(at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, const at::Scalar & value, at::TensorList out) {
|
| 61 |
+
return at::_ops::_foreach_addcmul_Scalar_out::call(self, tensor1, tensor2, value, out);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// aten::_foreach_addcmul.ScalarList_out(Tensor[] self, Tensor[] tensor1, Tensor[] tensor2, Scalar[] scalars, *, Tensor(a!)[] out) -> ()
|
| 65 |
+
inline void _foreach_addcmul_out(at::TensorList out, at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, at::ArrayRef<at::Scalar> scalars) {
|
| 66 |
+
return at::_ops::_foreach_addcmul_ScalarList_out::call(self, tensor1, tensor2, scalars, out);
|
| 67 |
+
}
|
| 68 |
+
// aten::_foreach_addcmul.ScalarList_out(Tensor[] self, Tensor[] tensor1, Tensor[] tensor2, Scalar[] scalars, *, Tensor(a!)[] out) -> ()
|
| 69 |
+
inline void _foreach_addcmul_outf(at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, at::ArrayRef<at::Scalar> scalars, at::TensorList out) {
|
| 70 |
+
return at::_ops::_foreach_addcmul_ScalarList_out::call(self, tensor1, tensor2, scalars, out);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
// aten::_foreach_addcmul.Tensor_out(Tensor[] self, Tensor[] tensor1, Tensor[] tensor2, Tensor scalars, *, Tensor(a!)[] out) -> ()
|
| 74 |
+
inline void _foreach_addcmul_out(at::TensorList out, at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, const at::Tensor & scalars) {
|
| 75 |
+
return at::_ops::_foreach_addcmul_Tensor_out::call(self, tensor1, tensor2, scalars, out);
|
| 76 |
+
}
|
| 77 |
+
// aten::_foreach_addcmul.Tensor_out(Tensor[] self, Tensor[] tensor1, Tensor[] tensor2, Tensor scalars, *, Tensor(a!)[] out) -> ()
|
| 78 |
+
inline void _foreach_addcmul_outf(at::TensorList self, at::TensorList tensor1, at::TensorList tensor2, const at::Tensor & scalars, at::TensorList out) {
|
| 79 |
+
return at::_ops::_foreach_addcmul_Tensor_out::call(self, tensor1, tensor2, scalars, out);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
}
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_log_softmax_backward_data_cpu_dispatch.h
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
// @generated by torchgen/gen.py from DispatchKeyFunction.h
|
| 3 |
+
|
| 4 |
+
// NB: The implementing C++ file is RegisterDispatchKey.cpp
|
| 5 |
+
|
| 6 |
+
// The only #includes we need are for custom classes that have defaults in the C++ API
|
| 7 |
+
#include <c10/core/MemoryFormat.h>
|
| 8 |
+
#include <c10/core/Scalar.h>
|
| 9 |
+
#include <ATen/core/Reduction.h>
|
| 10 |
+
|
| 11 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 12 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 13 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 14 |
+
#include <ATen/core/ATen_fwd.h>
|
| 15 |
+
|
| 16 |
+
namespace at {
|
| 17 |
+
|
| 18 |
+
namespace cpu {
|
| 19 |
+
|
| 20 |
+
TORCH_API at::Tensor _log_softmax_backward_data(const at::Tensor & grad_output, const at::Tensor & output, int64_t dim, at::ScalarType input_dtype);
|
| 21 |
+
TORCH_API at::Tensor & _log_softmax_backward_data_out(at::Tensor & out, const at::Tensor & grad_output, const at::Tensor & output, int64_t dim, at::ScalarType input_dtype);
|
| 22 |
+
TORCH_API at::Tensor & _log_softmax_backward_data_outf(const at::Tensor & grad_output, const at::Tensor & output, int64_t dim, at::ScalarType input_dtype, at::Tensor & out);
|
| 23 |
+
|
| 24 |
+
} // namespace cpu
|
| 25 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_native_batch_norm_legit_no_training_compositeexplicitautograd_dispatch.h
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
// @generated by torchgen/gen.py from DispatchKeyFunction.h
|
| 3 |
+
|
| 4 |
+
// NB: The implementing C++ file is RegisterDispatchKey.cpp
|
| 5 |
+
|
| 6 |
+
// The only #includes we need are for custom classes that have defaults in the C++ API
|
| 7 |
+
#include <c10/core/MemoryFormat.h>
|
| 8 |
+
#include <c10/core/Scalar.h>
|
| 9 |
+
#include <ATen/core/Reduction.h>
|
| 10 |
+
|
| 11 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 12 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 13 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 14 |
+
#include <ATen/core/ATen_fwd.h>
|
| 15 |
+
|
| 16 |
+
namespace at {
|
| 17 |
+
|
| 18 |
+
namespace compositeexplicitautograd {
|
| 19 |
+
|
| 20 |
+
TORCH_API ::std::tuple<at::Tensor,at::Tensor,at::Tensor> _native_batch_norm_legit_no_training(const at::Tensor & input, const c10::optional<at::Tensor> & weight, const c10::optional<at::Tensor> & bias, const at::Tensor & running_mean, const at::Tensor & running_var, double momentum, double eps);
|
| 21 |
+
TORCH_API ::std::tuple<at::Tensor &,at::Tensor &,at::Tensor &> _native_batch_norm_legit_no_training_out(at::Tensor & out0, at::Tensor & out1, at::Tensor & out2, const at::Tensor & input, const c10::optional<at::Tensor> & weight, const c10::optional<at::Tensor> & bias, const at::Tensor & running_mean, const at::Tensor & running_var, double momentum, double eps);
|
| 22 |
+
TORCH_API ::std::tuple<at::Tensor &,at::Tensor &,at::Tensor &> _native_batch_norm_legit_no_training_outf(const at::Tensor & input, const c10::optional<at::Tensor> & weight, const c10::optional<at::Tensor> & bias, const at::Tensor & running_mean, const at::Tensor & running_var, double momentum, double eps, at::Tensor & out0, at::Tensor & out1, at::Tensor & out2);
|
| 23 |
+
|
| 24 |
+
} // namespace compositeexplicitautograd
|
| 25 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_native_batch_norm_legit_no_training_ops.h
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from Operator.h
|
| 4 |
+
|
| 5 |
+
#include <tuple>
|
| 6 |
+
#include <vector>
|
| 7 |
+
|
| 8 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 9 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 10 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 11 |
+
#include <ATen/core/ATen_fwd.h>
|
| 12 |
+
|
| 13 |
+
namespace at {
|
| 14 |
+
namespace _ops {
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
struct TORCH_API _native_batch_norm_legit_no_training {
|
| 18 |
+
using schema = ::std::tuple<at::Tensor,at::Tensor,at::Tensor> (const at::Tensor &, const c10::optional<at::Tensor> &, const c10::optional<at::Tensor> &, const at::Tensor &, const at::Tensor &, double, double);
|
| 19 |
+
using ptr_schema = schema*;
|
| 20 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 21 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_native_batch_norm_legit_no_training")
|
| 22 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "")
|
| 23 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_native_batch_norm_legit_no_training(Tensor input, Tensor? weight, Tensor? bias, Tensor running_mean, Tensor running_var, float momentum, float eps) -> (Tensor, Tensor, Tensor)")
|
| 24 |
+
static ::std::tuple<at::Tensor,at::Tensor,at::Tensor> call(const at::Tensor & input, const c10::optional<at::Tensor> & weight, const c10::optional<at::Tensor> & bias, const at::Tensor & running_mean, const at::Tensor & running_var, double momentum, double eps);
|
| 25 |
+
static ::std::tuple<at::Tensor,at::Tensor,at::Tensor> redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & input, const c10::optional<at::Tensor> & weight, const c10::optional<at::Tensor> & bias, const at::Tensor & running_mean, const at::Tensor & running_var, double momentum, double eps);
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
struct TORCH_API _native_batch_norm_legit_no_training_out {
|
| 29 |
+
using schema = ::std::tuple<at::Tensor &,at::Tensor &,at::Tensor &> (const at::Tensor &, const c10::optional<at::Tensor> &, const c10::optional<at::Tensor> &, const at::Tensor &, const at::Tensor &, double, double, at::Tensor &, at::Tensor &, at::Tensor &);
|
| 30 |
+
using ptr_schema = schema*;
|
| 31 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 32 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::_native_batch_norm_legit_no_training")
|
| 33 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "out")
|
| 34 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "_native_batch_norm_legit_no_training.out(Tensor input, Tensor? weight, Tensor? bias, Tensor running_mean, Tensor running_var, float momentum, float eps, *, Tensor(a!) out0, Tensor(b!) out1, Tensor(c!) out2) -> (Tensor(a!), Tensor(b!), Tensor(c!))")
|
| 35 |
+
static ::std::tuple<at::Tensor &,at::Tensor &,at::Tensor &> call(const at::Tensor & input, const c10::optional<at::Tensor> & weight, const c10::optional<at::Tensor> & bias, const at::Tensor & running_mean, const at::Tensor & running_var, double momentum, double eps, at::Tensor & out0, at::Tensor & out1, at::Tensor & out2);
|
| 36 |
+
static ::std::tuple<at::Tensor &,at::Tensor &,at::Tensor &> redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & input, const c10::optional<at::Tensor> & weight, const c10::optional<at::Tensor> & bias, const at::Tensor & running_mean, const at::Tensor & running_var, double momentum, double eps, at::Tensor & out0, at::Tensor & out1, at::Tensor & out2);
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
}} // namespace at::_ops
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_nested_get_offsets_native.h
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from NativeFunction.h
|
| 4 |
+
|
| 5 |
+
#include <c10/core/Scalar.h>
|
| 6 |
+
#include <c10/core/Storage.h>
|
| 7 |
+
#include <c10/core/TensorOptions.h>
|
| 8 |
+
#include <c10/util/Deprecated.h>
|
| 9 |
+
#include <c10/util/Optional.h>
|
| 10 |
+
#include <c10/core/QScheme.h>
|
| 11 |
+
#include <ATen/core/Reduction.h>
|
| 12 |
+
#include <ATen/core/Tensor.h>
|
| 13 |
+
#include <tuple>
|
| 14 |
+
#include <vector>
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
namespace at {
|
| 18 |
+
namespace native {
|
| 19 |
+
} // namespace native
|
| 20 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_prelu_kernel_backward_native.h
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from NativeFunction.h
|
| 4 |
+
|
| 5 |
+
#include <c10/core/Scalar.h>
|
| 6 |
+
#include <c10/core/Storage.h>
|
| 7 |
+
#include <c10/core/TensorOptions.h>
|
| 8 |
+
#include <c10/util/Deprecated.h>
|
| 9 |
+
#include <c10/util/Optional.h>
|
| 10 |
+
#include <c10/core/QScheme.h>
|
| 11 |
+
#include <ATen/core/Reduction.h>
|
| 12 |
+
#include <ATen/core/Tensor.h>
|
| 13 |
+
#include <tuple>
|
| 14 |
+
#include <vector>
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
namespace at {
|
| 18 |
+
namespace native {
|
| 19 |
+
TORCH_API ::std::tuple<at::Tensor,at::Tensor> _prelu_kernel_backward(const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & weight);
|
| 20 |
+
TORCH_API ::std::tuple<at::Tensor,at::Tensor> mkldnn_prelu_backward(const at::Tensor & grad_output, const at::Tensor & self, const at::Tensor & weight);
|
| 21 |
+
} // namespace native
|
| 22 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_scaled_dot_product_efficient_attention_backward_cuda_dispatch.h
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
// @generated by torchgen/gen.py from DispatchKeyFunction.h
|
| 3 |
+
|
| 4 |
+
// NB: The implementing C++ file is RegisterDispatchKey.cpp
|
| 5 |
+
|
| 6 |
+
// The only #includes we need are for custom classes that have defaults in the C++ API
|
| 7 |
+
#include <c10/core/MemoryFormat.h>
|
| 8 |
+
#include <c10/core/Scalar.h>
|
| 9 |
+
#include <ATen/core/Reduction.h>
|
| 10 |
+
|
| 11 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 12 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 13 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 14 |
+
#include <ATen/core/ATen_fwd.h>
|
| 15 |
+
|
| 16 |
+
namespace at {
|
| 17 |
+
|
| 18 |
+
namespace cuda {
|
| 19 |
+
|
| 20 |
+
TORCH_API ::std::tuple<at::Tensor,at::Tensor,at::Tensor,at::Tensor> _scaled_dot_product_efficient_attention_backward(const at::Tensor & grad_out_, const at::Tensor & query, const at::Tensor & key, const at::Tensor & value, const at::Tensor & attn_bias, const at::Tensor & out, const at::Tensor & logsumexp, const at::Tensor & philox_seed, const at::Tensor & philox_offset, double dropout_p, ::std::array<bool,4> grad_input_mask, bool is_causal=false, c10::optional<double> scale=c10::nullopt);
|
| 21 |
+
|
| 22 |
+
} // namespace cuda
|
| 23 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_to_sparse_semi_structured.h
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from Function.h
|
| 4 |
+
|
| 5 |
+
#include <ATen/Context.h>
|
| 6 |
+
#include <ATen/DeviceGuard.h>
|
| 7 |
+
#include <ATen/TensorUtils.h>
|
| 8 |
+
#include <ATen/TracerMode.h>
|
| 9 |
+
#include <ATen/core/Generator.h>
|
| 10 |
+
#include <ATen/core/Reduction.h>
|
| 11 |
+
#include <ATen/core/Tensor.h>
|
| 12 |
+
#include <c10/core/Scalar.h>
|
| 13 |
+
#include <c10/core/Storage.h>
|
| 14 |
+
#include <c10/core/TensorOptions.h>
|
| 15 |
+
#include <c10/util/Deprecated.h>
|
| 16 |
+
#include <c10/util/Optional.h>
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
#include <ATen/ops/_to_sparse_semi_structured_ops.h>
|
| 21 |
+
|
| 22 |
+
namespace at {
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
// aten::_to_sparse_semi_structured(Tensor dense) -> (Tensor, Tensor)
|
| 26 |
+
inline ::std::tuple<at::Tensor,at::Tensor> _to_sparse_semi_structured(const at::Tensor & dense) {
|
| 27 |
+
return at::_ops::_to_sparse_semi_structured::call(dense);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
}
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_unsafe_index_put_compositeexplicitautograd_dispatch.h
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
// @generated by torchgen/gen.py from DispatchKeyFunction.h
|
| 3 |
+
|
| 4 |
+
// NB: The implementing C++ file is RegisterDispatchKey.cpp
|
| 5 |
+
|
| 6 |
+
// The only #includes we need are for custom classes that have defaults in the C++ API
|
| 7 |
+
#include <c10/core/MemoryFormat.h>
|
| 8 |
+
#include <c10/core/Scalar.h>
|
| 9 |
+
#include <ATen/core/Reduction.h>
|
| 10 |
+
|
| 11 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 12 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 13 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 14 |
+
#include <ATen/core/ATen_fwd.h>
|
| 15 |
+
|
| 16 |
+
namespace at {
|
| 17 |
+
|
| 18 |
+
namespace compositeexplicitautograd {
|
| 19 |
+
|
| 20 |
+
TORCH_API at::Tensor _unsafe_index_put(const at::Tensor & self, const c10::List<c10::optional<at::Tensor>> & indices, const at::Tensor & values, bool accumulate=false);
|
| 21 |
+
|
| 22 |
+
} // namespace compositeexplicitautograd
|
| 23 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_upsample_bicubic2d_aa_backward_meta_dispatch.h
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
// @generated by torchgen/gen.py from DispatchKeyFunction.h
|
| 3 |
+
|
| 4 |
+
// NB: The implementing C++ file is RegisterDispatchKey.cpp
|
| 5 |
+
|
| 6 |
+
// The only #includes we need are for custom classes that have defaults in the C++ API
|
| 7 |
+
#include <c10/core/MemoryFormat.h>
|
| 8 |
+
#include <c10/core/Scalar.h>
|
| 9 |
+
#include <ATen/core/Reduction.h>
|
| 10 |
+
|
| 11 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 12 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 13 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 14 |
+
#include <ATen/core/ATen_fwd.h>
|
| 15 |
+
|
| 16 |
+
namespace at {
|
| 17 |
+
|
| 18 |
+
namespace meta {
|
| 19 |
+
|
| 20 |
+
TORCH_API at::Tensor _upsample_bicubic2d_aa_backward(const at::Tensor & grad_output, at::IntArrayRef output_size, at::IntArrayRef input_size, bool align_corners, c10::optional<double> scales_h=c10::nullopt, c10::optional<double> scales_w=c10::nullopt);
|
| 21 |
+
TORCH_API at::Tensor _upsample_bicubic2d_aa_backward_symint(const at::Tensor & grad_output, c10::SymIntArrayRef output_size, c10::SymIntArrayRef input_size, bool align_corners, c10::optional<double> scales_h=c10::nullopt, c10::optional<double> scales_w=c10::nullopt);
|
| 22 |
+
TORCH_API at::Tensor & _upsample_bicubic2d_aa_backward_out(at::Tensor & grad_input, const at::Tensor & grad_output, at::IntArrayRef output_size, at::IntArrayRef input_size, bool align_corners, c10::optional<double> scales_h=c10::nullopt, c10::optional<double> scales_w=c10::nullopt);
|
| 23 |
+
TORCH_API at::Tensor & _upsample_bicubic2d_aa_backward_outf(const at::Tensor & grad_output, at::IntArrayRef output_size, at::IntArrayRef input_size, bool align_corners, c10::optional<double> scales_h, c10::optional<double> scales_w, at::Tensor & grad_input);
|
| 24 |
+
TORCH_API at::Tensor & _upsample_bicubic2d_aa_backward_symint_out(at::Tensor & grad_input, const at::Tensor & grad_output, c10::SymIntArrayRef output_size, c10::SymIntArrayRef input_size, bool align_corners, c10::optional<double> scales_h=c10::nullopt, c10::optional<double> scales_w=c10::nullopt);
|
| 25 |
+
TORCH_API at::Tensor & _upsample_bicubic2d_aa_backward_symint_outf(const at::Tensor & grad_output, c10::SymIntArrayRef output_size, c10::SymIntArrayRef input_size, bool align_corners, c10::optional<double> scales_h, c10::optional<double> scales_w, at::Tensor & grad_input);
|
| 26 |
+
|
| 27 |
+
} // namespace meta
|
| 28 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/_upsample_bicubic2d_aa_meta.h
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from NativeMetaFunction.h
|
| 4 |
+
|
| 5 |
+
#include <c10/core/Scalar.h>
|
| 6 |
+
#include <c10/core/Storage.h>
|
| 7 |
+
#include <c10/core/TensorOptions.h>
|
| 8 |
+
#include <c10/util/Deprecated.h>
|
| 9 |
+
#include <c10/util/Optional.h>
|
| 10 |
+
#include <c10/core/QScheme.h>
|
| 11 |
+
#include <ATen/core/Reduction.h>
|
| 12 |
+
#include <ATen/TensorIterator.h>
|
| 13 |
+
#include <ATen/TensorMeta.h>
|
| 14 |
+
#include <tuple>
|
| 15 |
+
#include <vector>
|
| 16 |
+
|
| 17 |
+
namespace at {
|
| 18 |
+
namespace meta {
|
| 19 |
+
|
| 20 |
+
struct TORCH_API structured__upsample_bicubic2d_aa : public at::impl::MetaBase {
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
void meta(const at::Tensor & self, at::ArrayRef<int64_t> output_size, bool align_corners, c10::optional<double> scales_h, c10::optional<double> scales_w);
|
| 24 |
+
};
|
| 25 |
+
|
| 26 |
+
} // namespace native
|
| 27 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/adaptive_avg_pool3d.h
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from Function.h
|
| 4 |
+
|
| 5 |
+
#include <ATen/Context.h>
|
| 6 |
+
#include <ATen/DeviceGuard.h>
|
| 7 |
+
#include <ATen/TensorUtils.h>
|
| 8 |
+
#include <ATen/TracerMode.h>
|
| 9 |
+
#include <ATen/core/Generator.h>
|
| 10 |
+
#include <ATen/core/Reduction.h>
|
| 11 |
+
#include <ATen/core/Tensor.h>
|
| 12 |
+
#include <c10/core/Scalar.h>
|
| 13 |
+
#include <c10/core/Storage.h>
|
| 14 |
+
#include <c10/core/TensorOptions.h>
|
| 15 |
+
#include <c10/util/Deprecated.h>
|
| 16 |
+
#include <c10/util/Optional.h>
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
#include <ATen/ops/adaptive_avg_pool3d_ops.h>
|
| 21 |
+
|
| 22 |
+
namespace at {
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
// aten::adaptive_avg_pool3d.out(Tensor self, SymInt[3] output_size, *, Tensor(a!) out) -> Tensor(a!)
|
| 26 |
+
inline at::Tensor & adaptive_avg_pool3d_out(at::Tensor & out, const at::Tensor & self, at::IntArrayRef output_size) {
|
| 27 |
+
return at::_ops::adaptive_avg_pool3d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
|
| 28 |
+
}
|
| 29 |
+
namespace symint {
|
| 30 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, int64_t>::value>>
|
| 31 |
+
at::Tensor & adaptive_avg_pool3d_out(at::Tensor & out, const at::Tensor & self, at::IntArrayRef output_size) {
|
| 32 |
+
return at::_ops::adaptive_avg_pool3d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
// aten::adaptive_avg_pool3d.out(Tensor self, SymInt[3] output_size, *, Tensor(a!) out) -> Tensor(a!)
|
| 37 |
+
inline at::Tensor & adaptive_avg_pool3d_outf(const at::Tensor & self, at::IntArrayRef output_size, at::Tensor & out) {
|
| 38 |
+
return at::_ops::adaptive_avg_pool3d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
|
| 39 |
+
}
|
| 40 |
+
namespace symint {
|
| 41 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, int64_t>::value>>
|
| 42 |
+
at::Tensor & adaptive_avg_pool3d_outf(const at::Tensor & self, at::IntArrayRef output_size, at::Tensor & out) {
|
| 43 |
+
return at::_ops::adaptive_avg_pool3d_out::call(self, c10::fromIntArrayRefSlow(output_size), out);
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
// aten::adaptive_avg_pool3d.out(Tensor self, SymInt[3] output_size, *, Tensor(a!) out) -> Tensor(a!)
|
| 48 |
+
inline at::Tensor & adaptive_avg_pool3d_symint_out(at::Tensor & out, const at::Tensor & self, c10::SymIntArrayRef output_size) {
|
| 49 |
+
return at::_ops::adaptive_avg_pool3d_out::call(self, output_size, out);
|
| 50 |
+
}
|
| 51 |
+
namespace symint {
|
| 52 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, c10::SymInt>::value>>
|
| 53 |
+
at::Tensor & adaptive_avg_pool3d_out(at::Tensor & out, const at::Tensor & self, c10::SymIntArrayRef output_size) {
|
| 54 |
+
return at::_ops::adaptive_avg_pool3d_out::call(self, output_size, out);
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
// aten::adaptive_avg_pool3d.out(Tensor self, SymInt[3] output_size, *, Tensor(a!) out) -> Tensor(a!)
|
| 59 |
+
inline at::Tensor & adaptive_avg_pool3d_symint_outf(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out) {
|
| 60 |
+
return at::_ops::adaptive_avg_pool3d_out::call(self, output_size, out);
|
| 61 |
+
}
|
| 62 |
+
namespace symint {
|
| 63 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, c10::SymInt>::value>>
|
| 64 |
+
at::Tensor & adaptive_avg_pool3d_outf(const at::Tensor & self, c10::SymIntArrayRef output_size, at::Tensor & out) {
|
| 65 |
+
return at::_ops::adaptive_avg_pool3d_out::call(self, output_size, out);
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
// aten::adaptive_avg_pool3d(Tensor self, SymInt[3] output_size) -> Tensor
|
| 70 |
+
inline at::Tensor adaptive_avg_pool3d(const at::Tensor & self, at::IntArrayRef output_size) {
|
| 71 |
+
return at::_ops::adaptive_avg_pool3d::call(self, c10::fromIntArrayRefSlow(output_size));
|
| 72 |
+
}
|
| 73 |
+
namespace symint {
|
| 74 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, int64_t>::value>>
|
| 75 |
+
at::Tensor adaptive_avg_pool3d(const at::Tensor & self, at::IntArrayRef output_size) {
|
| 76 |
+
return at::_ops::adaptive_avg_pool3d::call(self, c10::fromIntArrayRefSlow(output_size));
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
// aten::adaptive_avg_pool3d(Tensor self, SymInt[3] output_size) -> Tensor
|
| 81 |
+
inline at::Tensor adaptive_avg_pool3d_symint(const at::Tensor & self, c10::SymIntArrayRef output_size) {
|
| 82 |
+
return at::_ops::adaptive_avg_pool3d::call(self, output_size);
|
| 83 |
+
}
|
| 84 |
+
namespace symint {
|
| 85 |
+
template <typename T, typename = std::enable_if_t<std::is_same<T, c10::SymInt>::value>>
|
| 86 |
+
at::Tensor adaptive_avg_pool3d(const at::Tensor & self, c10::SymIntArrayRef output_size) {
|
| 87 |
+
return at::_ops::adaptive_avg_pool3d::call(self, output_size);
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
}
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/batch_norm_elemt_cuda_dispatch.h
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
// @generated by torchgen/gen.py from DispatchKeyFunction.h
|
| 3 |
+
|
| 4 |
+
// NB: The implementing C++ file is RegisterDispatchKey.cpp
|
| 5 |
+
|
| 6 |
+
// The only #includes we need are for custom classes that have defaults in the C++ API
|
| 7 |
+
#include <c10/core/MemoryFormat.h>
|
| 8 |
+
#include <c10/core/Scalar.h>
|
| 9 |
+
#include <ATen/core/Reduction.h>
|
| 10 |
+
|
| 11 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 12 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 13 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 14 |
+
#include <ATen/core/ATen_fwd.h>
|
| 15 |
+
|
| 16 |
+
namespace at {
|
| 17 |
+
|
| 18 |
+
namespace cuda {
|
| 19 |
+
|
| 20 |
+
TORCH_API at::Tensor batch_norm_elemt(const at::Tensor & input, const c10::optional<at::Tensor> & weight, const c10::optional<at::Tensor> & bias, const at::Tensor & mean, const at::Tensor & invstd, double eps);
|
| 21 |
+
TORCH_API at::Tensor & batch_norm_elemt_out(at::Tensor & out, const at::Tensor & input, const c10::optional<at::Tensor> & weight, const c10::optional<at::Tensor> & bias, const at::Tensor & mean, const at::Tensor & invstd, double eps);
|
| 22 |
+
TORCH_API at::Tensor & batch_norm_elemt_outf(const at::Tensor & input, const c10::optional<at::Tensor> & weight, const c10::optional<at::Tensor> & bias, const at::Tensor & mean, const at::Tensor & invstd, double eps, at::Tensor & out);
|
| 23 |
+
|
| 24 |
+
} // namespace cuda
|
| 25 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/choose_qparams_optimized_compositeimplicitautograd_dispatch.h
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
// @generated by torchgen/gen.py from DispatchKeyFunction.h
|
| 3 |
+
|
| 4 |
+
// NB: The implementing C++ file is RegisterDispatchKey.cpp
|
| 5 |
+
|
| 6 |
+
// The only #includes we need are for custom classes that have defaults in the C++ API
|
| 7 |
+
#include <c10/core/MemoryFormat.h>
|
| 8 |
+
#include <c10/core/Scalar.h>
|
| 9 |
+
#include <ATen/core/Reduction.h>
|
| 10 |
+
|
| 11 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 12 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 13 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 14 |
+
#include <ATen/core/ATen_fwd.h>
|
| 15 |
+
|
| 16 |
+
namespace at {
|
| 17 |
+
|
| 18 |
+
namespace compositeimplicitautograd {
|
| 19 |
+
|
| 20 |
+
TORCH_API ::std::tuple<at::Tensor,at::Tensor> choose_qparams_optimized(const at::Tensor & input, int64_t numel, int64_t n_bins, double ratio, int64_t bit_width);
|
| 21 |
+
|
| 22 |
+
} // namespace compositeimplicitautograd
|
| 23 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/clamp_ops.h
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from Operator.h
|
| 4 |
+
|
| 5 |
+
#include <tuple>
|
| 6 |
+
#include <vector>
|
| 7 |
+
|
| 8 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 9 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 10 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 11 |
+
#include <ATen/core/ATen_fwd.h>
|
| 12 |
+
|
| 13 |
+
namespace at {
|
| 14 |
+
namespace _ops {
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
struct TORCH_API clamp {
|
| 18 |
+
using schema = at::Tensor (const at::Tensor &, const c10::optional<at::Scalar> &, const c10::optional<at::Scalar> &);
|
| 19 |
+
using ptr_schema = schema*;
|
| 20 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 21 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::clamp")
|
| 22 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "")
|
| 23 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "clamp(Tensor self, Scalar? min=None, Scalar? max=None) -> Tensor")
|
| 24 |
+
static at::Tensor call(const at::Tensor & self, const c10::optional<at::Scalar> & min, const c10::optional<at::Scalar> & max);
|
| 25 |
+
static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const c10::optional<at::Scalar> & min, const c10::optional<at::Scalar> & max);
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
struct TORCH_API clamp_Tensor {
|
| 29 |
+
using schema = at::Tensor (const at::Tensor &, const c10::optional<at::Tensor> &, const c10::optional<at::Tensor> &);
|
| 30 |
+
using ptr_schema = schema*;
|
| 31 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 32 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::clamp")
|
| 33 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "Tensor")
|
| 34 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "clamp.Tensor(Tensor self, Tensor? min=None, Tensor? max=None) -> Tensor")
|
| 35 |
+
static at::Tensor call(const at::Tensor & self, const c10::optional<at::Tensor> & min, const c10::optional<at::Tensor> & max);
|
| 36 |
+
static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const c10::optional<at::Tensor> & min, const c10::optional<at::Tensor> & max);
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
struct TORCH_API clamp_ {
|
| 40 |
+
using schema = at::Tensor & (at::Tensor &, const c10::optional<at::Scalar> &, const c10::optional<at::Scalar> &);
|
| 41 |
+
using ptr_schema = schema*;
|
| 42 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 43 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::clamp_")
|
| 44 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "")
|
| 45 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "clamp_(Tensor(a!) self, Scalar? min=None, Scalar? max=None) -> Tensor(a!)")
|
| 46 |
+
static at::Tensor & call(at::Tensor & self, const c10::optional<at::Scalar> & min, const c10::optional<at::Scalar> & max);
|
| 47 |
+
static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, at::Tensor & self, const c10::optional<at::Scalar> & min, const c10::optional<at::Scalar> & max);
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
struct TORCH_API clamp__Tensor {
|
| 51 |
+
using schema = at::Tensor & (at::Tensor &, const c10::optional<at::Tensor> &, const c10::optional<at::Tensor> &);
|
| 52 |
+
using ptr_schema = schema*;
|
| 53 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 54 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::clamp_")
|
| 55 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "Tensor")
|
| 56 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "clamp_.Tensor(Tensor(a!) self, Tensor? min=None, Tensor? max=None) -> Tensor(a!)")
|
| 57 |
+
static at::Tensor & call(at::Tensor & self, const c10::optional<at::Tensor> & min, const c10::optional<at::Tensor> & max);
|
| 58 |
+
static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, at::Tensor & self, const c10::optional<at::Tensor> & min, const c10::optional<at::Tensor> & max);
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
struct TORCH_API clamp_out {
|
| 62 |
+
using schema = at::Tensor & (const at::Tensor &, const c10::optional<at::Scalar> &, const c10::optional<at::Scalar> &, at::Tensor &);
|
| 63 |
+
using ptr_schema = schema*;
|
| 64 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 65 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::clamp")
|
| 66 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "out")
|
| 67 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "clamp.out(Tensor self, Scalar? min=None, Scalar? max=None, *, Tensor(a!) out) -> Tensor(a!)")
|
| 68 |
+
static at::Tensor & call(const at::Tensor & self, const c10::optional<at::Scalar> & min, const c10::optional<at::Scalar> & max, at::Tensor & out);
|
| 69 |
+
static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const c10::optional<at::Scalar> & min, const c10::optional<at::Scalar> & max, at::Tensor & out);
|
| 70 |
+
};
|
| 71 |
+
|
| 72 |
+
struct TORCH_API clamp_Tensor_out {
|
| 73 |
+
using schema = at::Tensor & (const at::Tensor &, const c10::optional<at::Tensor> &, const c10::optional<at::Tensor> &, at::Tensor &);
|
| 74 |
+
using ptr_schema = schema*;
|
| 75 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 76 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::clamp")
|
| 77 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "Tensor_out")
|
| 78 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "clamp.Tensor_out(Tensor self, Tensor? min=None, Tensor? max=None, *, Tensor(a!) out) -> Tensor(a!)")
|
| 79 |
+
static at::Tensor & call(const at::Tensor & self, const c10::optional<at::Tensor> & min, const c10::optional<at::Tensor> & max, at::Tensor & out);
|
| 80 |
+
static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, const c10::optional<at::Tensor> & min, const c10::optional<at::Tensor> & max, at::Tensor & out);
|
| 81 |
+
};
|
| 82 |
+
|
| 83 |
+
}} // namespace at::_ops
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/complex_cuda_dispatch.h
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
// @generated by torchgen/gen.py from DispatchKeyFunction.h
|
| 3 |
+
|
| 4 |
+
// NB: The implementing C++ file is RegisterDispatchKey.cpp
|
| 5 |
+
|
| 6 |
+
// The only #includes we need are for custom classes that have defaults in the C++ API
|
| 7 |
+
#include <c10/core/MemoryFormat.h>
|
| 8 |
+
#include <c10/core/Scalar.h>
|
| 9 |
+
#include <ATen/core/Reduction.h>
|
| 10 |
+
|
| 11 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 12 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 13 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 14 |
+
#include <ATen/core/ATen_fwd.h>
|
| 15 |
+
|
| 16 |
+
namespace at {
|
| 17 |
+
|
| 18 |
+
namespace cuda {
|
| 19 |
+
|
| 20 |
+
TORCH_API at::Tensor & complex_out(at::Tensor & out, const at::Tensor & real, const at::Tensor & imag);
|
| 21 |
+
TORCH_API at::Tensor & complex_outf(const at::Tensor & real, const at::Tensor & imag, at::Tensor & out);
|
| 22 |
+
|
| 23 |
+
} // namespace cuda
|
| 24 |
+
} // namespace at
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/conv1d_ops.h
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from Operator.h
|
| 4 |
+
|
| 5 |
+
#include <tuple>
|
| 6 |
+
#include <vector>
|
| 7 |
+
|
| 8 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 9 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 10 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 11 |
+
#include <ATen/core/ATen_fwd.h>
|
| 12 |
+
|
| 13 |
+
namespace at {
|
| 14 |
+
namespace _ops {
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
struct TORCH_API conv1d {
|
| 18 |
+
using schema = at::Tensor (const at::Tensor &, const at::Tensor &, const c10::optional<at::Tensor> &, c10::SymIntArrayRef, c10::SymIntArrayRef, c10::SymIntArrayRef, c10::SymInt);
|
| 19 |
+
using ptr_schema = schema*;
|
| 20 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 21 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::conv1d")
|
| 22 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "")
|
| 23 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "conv1d(Tensor input, Tensor weight, Tensor? bias=None, SymInt[1] stride=1, SymInt[1] padding=0, SymInt[1] dilation=1, SymInt groups=1) -> Tensor")
|
| 24 |
+
static at::Tensor call(const at::Tensor & input, const at::Tensor & weight, const c10::optional<at::Tensor> & bias, c10::SymIntArrayRef stride, c10::SymIntArrayRef padding, c10::SymIntArrayRef dilation, c10::SymInt groups);
|
| 25 |
+
static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & input, const at::Tensor & weight, const c10::optional<at::Tensor> & bias, c10::SymIntArrayRef stride, c10::SymIntArrayRef padding, c10::SymIntArrayRef dilation, c10::SymInt groups);
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
struct TORCH_API conv1d_padding {
|
| 29 |
+
using schema = at::Tensor (const at::Tensor &, const at::Tensor &, const c10::optional<at::Tensor> &, c10::SymIntArrayRef, c10::string_view, c10::SymIntArrayRef, c10::SymInt);
|
| 30 |
+
using ptr_schema = schema*;
|
| 31 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 32 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::conv1d")
|
| 33 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "padding")
|
| 34 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "conv1d.padding(Tensor input, Tensor weight, Tensor? bias=None, SymInt[1] stride=1, str padding=\"valid\", SymInt[1] dilation=1, SymInt groups=1) -> Tensor")
|
| 35 |
+
static at::Tensor call(const at::Tensor & input, const at::Tensor & weight, const c10::optional<at::Tensor> & bias, c10::SymIntArrayRef stride, c10::string_view padding, c10::SymIntArrayRef dilation, c10::SymInt groups);
|
| 36 |
+
static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & input, const at::Tensor & weight, const c10::optional<at::Tensor> & bias, c10::SymIntArrayRef stride, c10::string_view padding, c10::SymIntArrayRef dilation, c10::SymInt groups);
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
}} // namespace at::_ops
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/cummax.h
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from Function.h
|
| 4 |
+
|
| 5 |
+
#include <ATen/Context.h>
|
| 6 |
+
#include <ATen/DeviceGuard.h>
|
| 7 |
+
#include <ATen/TensorUtils.h>
|
| 8 |
+
#include <ATen/TracerMode.h>
|
| 9 |
+
#include <ATen/core/Generator.h>
|
| 10 |
+
#include <ATen/core/Reduction.h>
|
| 11 |
+
#include <ATen/core/Tensor.h>
|
| 12 |
+
#include <c10/core/Scalar.h>
|
| 13 |
+
#include <c10/core/Storage.h>
|
| 14 |
+
#include <c10/core/TensorOptions.h>
|
| 15 |
+
#include <c10/util/Deprecated.h>
|
| 16 |
+
#include <c10/util/Optional.h>
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
#include <ATen/ops/cummax_ops.h>
|
| 21 |
+
|
| 22 |
+
namespace at {
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
// aten::cummax(Tensor self, int dim) -> (Tensor values, Tensor indices)
|
| 26 |
+
inline ::std::tuple<at::Tensor,at::Tensor> cummax(const at::Tensor & self, int64_t dim) {
|
| 27 |
+
return at::_ops::cummax::call(self, dim);
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
// aten::cummax.out(Tensor self, int dim, *, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices)
|
| 31 |
+
inline ::std::tuple<at::Tensor &,at::Tensor &> cummax_out(at::Tensor & values, at::Tensor & indices, const at::Tensor & self, int64_t dim) {
|
| 32 |
+
return at::_ops::cummax_out::call(self, dim, values, indices);
|
| 33 |
+
}
|
| 34 |
+
// aten::cummax.out(Tensor self, int dim, *, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices)
|
| 35 |
+
inline ::std::tuple<at::Tensor &,at::Tensor &> cummax_outf(const at::Tensor & self, int64_t dim, at::Tensor & values, at::Tensor & indices) {
|
| 36 |
+
return at::_ops::cummax_out::call(self, dim, values, indices);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// aten::cummax.dimname(Tensor self, Dimname dim) -> (Tensor values, Tensor indices)
|
| 40 |
+
inline ::std::tuple<at::Tensor,at::Tensor> cummax(const at::Tensor & self, at::Dimname dim) {
|
| 41 |
+
return at::_ops::cummax_dimname::call(self, dim);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
// aten::cummax.dimname_out(Tensor self, Dimname dim, *, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices)
|
| 45 |
+
inline ::std::tuple<at::Tensor &,at::Tensor &> cummax_out(at::Tensor & values, at::Tensor & indices, const at::Tensor & self, at::Dimname dim) {
|
| 46 |
+
return at::_ops::cummax_dimname_out::call(self, dim, values, indices);
|
| 47 |
+
}
|
| 48 |
+
// aten::cummax.dimname_out(Tensor self, Dimname dim, *, Tensor(a!) values, Tensor(b!) indices) -> (Tensor(a!) values, Tensor(b!) indices)
|
| 49 |
+
inline ::std::tuple<at::Tensor &,at::Tensor &> cummax_outf(const at::Tensor & self, at::Dimname dim, at::Tensor & values, at::Tensor & indices) {
|
| 50 |
+
return at::_ops::cummax_dimname_out::call(self, dim, values, indices);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
}
|
moondream/lib/python3.10/site-packages/torch/include/ATen/ops/deg2rad_ops.h
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#pragma once
|
| 2 |
+
|
| 3 |
+
// @generated by torchgen/gen.py from Operator.h
|
| 4 |
+
|
| 5 |
+
#include <tuple>
|
| 6 |
+
#include <vector>
|
| 7 |
+
|
| 8 |
+
// Forward declarations of any types needed in the operator signatures.
|
| 9 |
+
// We can't directly include these classes because it will cause circular include dependencies.
|
| 10 |
+
// This file is included by TensorBody.h, which defines the Tensor class.
|
| 11 |
+
#include <ATen/core/ATen_fwd.h>
|
| 12 |
+
|
| 13 |
+
namespace at {
|
| 14 |
+
namespace _ops {
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
struct TORCH_API deg2rad {
|
| 18 |
+
using schema = at::Tensor (const at::Tensor &);
|
| 19 |
+
using ptr_schema = schema*;
|
| 20 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 21 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::deg2rad")
|
| 22 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "")
|
| 23 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "deg2rad(Tensor self) -> Tensor")
|
| 24 |
+
static at::Tensor call(const at::Tensor & self);
|
| 25 |
+
static at::Tensor redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self);
|
| 26 |
+
};
|
| 27 |
+
|
| 28 |
+
struct TORCH_API deg2rad_ {
|
| 29 |
+
using schema = at::Tensor & (at::Tensor &);
|
| 30 |
+
using ptr_schema = schema*;
|
| 31 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 32 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::deg2rad_")
|
| 33 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "")
|
| 34 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "deg2rad_(Tensor(a!) self) -> Tensor(a!)")
|
| 35 |
+
static at::Tensor & call(at::Tensor & self);
|
| 36 |
+
static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, at::Tensor & self);
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
struct TORCH_API deg2rad_out {
|
| 40 |
+
using schema = at::Tensor & (const at::Tensor &, at::Tensor &);
|
| 41 |
+
using ptr_schema = schema*;
|
| 42 |
+
// See Note [static constexpr char* members for windows NVCC]
|
| 43 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(name, "aten::deg2rad")
|
| 44 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(overload_name, "out")
|
| 45 |
+
STATIC_CONSTEXPR_STR_INL_EXCEPT_WIN_CUDA(schema_str, "deg2rad.out(Tensor self, *, Tensor(a!) out) -> Tensor(a!)")
|
| 46 |
+
static at::Tensor & call(const at::Tensor & self, at::Tensor & out);
|
| 47 |
+
static at::Tensor & redispatch(c10::DispatchKeySet dispatchKeySet, const at::Tensor & self, at::Tensor & out);
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
}} // namespace at::_ops
|