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 +1 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/packaging.cpython-310.pyc +0 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/unpacking.cpython-310.pyc +0 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/compatibility_tags.py +188 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/datetime.py +11 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/deprecation.py +124 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/direct_url_helpers.py +87 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/egg_link.py +80 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/filetypes.py +27 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/glibc.py +101 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/logging.py +354 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/misc.py +773 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/retry.py +42 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/setuptools_build.py +146 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/subprocess.py +245 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/temp_dir.py +296 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/urls.py +55 -0
- videollama2/lib/python3.10/site-packages/pip/_internal/utils/wheel.py +134 -0
- vllm/lib/python3.10/site-packages/cupy/_core/_routines_statistics.cpython-310-x86_64-linux-gnu.so +3 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/binary_search.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/extrema.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/fill.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/inner_product.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/mismatch.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/partition.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/replace.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/scan.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/scan_by_key.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/scatter.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/transform.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/transform_reduce.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/uninitialized_copy.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/unique.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/advance.h +45 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/binary_search.inl +391 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/copy.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/copy.inl +73 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/copy_if.h +64 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/copy_if.inl +156 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/count.h +54 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/distance.h +47 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/distance.inl +80 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/extrema.inl +258 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/find.h +55 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/for_each.h +66 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/gather.h +79 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/gather.inl +104 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/generate.h +51 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/generate.inl +90 -0
- vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/inner_product.inl +78 -0
.gitattributes
CHANGED
|
@@ -1770,3 +1770,4 @@ vllm/lib/python3.10/site-packages/cupy/_core/_accelerator.cpython-310-x86_64-lin
|
|
| 1770 |
vllm/lib/python3.10/site-packages/cupy/_core/_fusion_kernel.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1771 |
vllm/lib/libcrypto.so filter=lfs diff=lfs merge=lfs -text
|
| 1772 |
vllm/lib/libcrypto.a filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 1770 |
vllm/lib/python3.10/site-packages/cupy/_core/_fusion_kernel.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1771 |
vllm/lib/libcrypto.so filter=lfs diff=lfs merge=lfs -text
|
| 1772 |
vllm/lib/libcrypto.a filter=lfs diff=lfs merge=lfs -text
|
| 1773 |
+
vllm/lib/python3.10/site-packages/cupy/_core/_routines_statistics.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/packaging.cpython-310.pyc
ADDED
|
Binary file (2.08 kB). View file
|
|
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/unpacking.cpython-310.pyc
ADDED
|
Binary file (8.06 kB). View file
|
|
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/compatibility_tags.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate and work with PEP 425 Compatibility Tags.
|
| 2 |
+
"""
|
| 3 |
+
|
| 4 |
+
import re
|
| 5 |
+
from typing import List, Optional, Tuple
|
| 6 |
+
|
| 7 |
+
from pip._vendor.packaging.tags import (
|
| 8 |
+
PythonVersion,
|
| 9 |
+
Tag,
|
| 10 |
+
compatible_tags,
|
| 11 |
+
cpython_tags,
|
| 12 |
+
generic_tags,
|
| 13 |
+
interpreter_name,
|
| 14 |
+
interpreter_version,
|
| 15 |
+
ios_platforms,
|
| 16 |
+
mac_platforms,
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
_apple_arch_pat = re.compile(r"(.+)_(\d+)_(\d+)_(.+)")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def version_info_to_nodot(version_info: Tuple[int, ...]) -> str:
|
| 23 |
+
# Only use up to the first two numbers.
|
| 24 |
+
return "".join(map(str, version_info[:2]))
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _mac_platforms(arch: str) -> List[str]:
|
| 28 |
+
match = _apple_arch_pat.match(arch)
|
| 29 |
+
if match:
|
| 30 |
+
name, major, minor, actual_arch = match.groups()
|
| 31 |
+
mac_version = (int(major), int(minor))
|
| 32 |
+
arches = [
|
| 33 |
+
# Since we have always only checked that the platform starts
|
| 34 |
+
# with "macosx", for backwards-compatibility we extract the
|
| 35 |
+
# actual prefix provided by the user in case they provided
|
| 36 |
+
# something like "macosxcustom_". It may be good to remove
|
| 37 |
+
# this as undocumented or deprecate it in the future.
|
| 38 |
+
"{}_{}".format(name, arch[len("macosx_") :])
|
| 39 |
+
for arch in mac_platforms(mac_version, actual_arch)
|
| 40 |
+
]
|
| 41 |
+
else:
|
| 42 |
+
# arch pattern didn't match (?!)
|
| 43 |
+
arches = [arch]
|
| 44 |
+
return arches
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def _ios_platforms(arch: str) -> List[str]:
|
| 48 |
+
match = _apple_arch_pat.match(arch)
|
| 49 |
+
if match:
|
| 50 |
+
name, major, minor, actual_multiarch = match.groups()
|
| 51 |
+
ios_version = (int(major), int(minor))
|
| 52 |
+
arches = [
|
| 53 |
+
# Since we have always only checked that the platform starts
|
| 54 |
+
# with "ios", for backwards-compatibility we extract the
|
| 55 |
+
# actual prefix provided by the user in case they provided
|
| 56 |
+
# something like "ioscustom_". It may be good to remove
|
| 57 |
+
# this as undocumented or deprecate it in the future.
|
| 58 |
+
"{}_{}".format(name, arch[len("ios_") :])
|
| 59 |
+
for arch in ios_platforms(ios_version, actual_multiarch)
|
| 60 |
+
]
|
| 61 |
+
else:
|
| 62 |
+
# arch pattern didn't match (?!)
|
| 63 |
+
arches = [arch]
|
| 64 |
+
return arches
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def _custom_manylinux_platforms(arch: str) -> List[str]:
|
| 68 |
+
arches = [arch]
|
| 69 |
+
arch_prefix, arch_sep, arch_suffix = arch.partition("_")
|
| 70 |
+
if arch_prefix == "manylinux2014":
|
| 71 |
+
# manylinux1/manylinux2010 wheels run on most manylinux2014 systems
|
| 72 |
+
# with the exception of wheels depending on ncurses. PEP 599 states
|
| 73 |
+
# manylinux1/manylinux2010 wheels should be considered
|
| 74 |
+
# manylinux2014 wheels:
|
| 75 |
+
# https://www.python.org/dev/peps/pep-0599/#backwards-compatibility-with-manylinux2010-wheels
|
| 76 |
+
if arch_suffix in {"i686", "x86_64"}:
|
| 77 |
+
arches.append("manylinux2010" + arch_sep + arch_suffix)
|
| 78 |
+
arches.append("manylinux1" + arch_sep + arch_suffix)
|
| 79 |
+
elif arch_prefix == "manylinux2010":
|
| 80 |
+
# manylinux1 wheels run on most manylinux2010 systems with the
|
| 81 |
+
# exception of wheels depending on ncurses. PEP 571 states
|
| 82 |
+
# manylinux1 wheels should be considered manylinux2010 wheels:
|
| 83 |
+
# https://www.python.org/dev/peps/pep-0571/#backwards-compatibility-with-manylinux1-wheels
|
| 84 |
+
arches.append("manylinux1" + arch_sep + arch_suffix)
|
| 85 |
+
return arches
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def _get_custom_platforms(arch: str) -> List[str]:
|
| 89 |
+
arch_prefix, arch_sep, arch_suffix = arch.partition("_")
|
| 90 |
+
if arch.startswith("macosx"):
|
| 91 |
+
arches = _mac_platforms(arch)
|
| 92 |
+
elif arch.startswith("ios"):
|
| 93 |
+
arches = _ios_platforms(arch)
|
| 94 |
+
elif arch_prefix in ["manylinux2014", "manylinux2010"]:
|
| 95 |
+
arches = _custom_manylinux_platforms(arch)
|
| 96 |
+
else:
|
| 97 |
+
arches = [arch]
|
| 98 |
+
return arches
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
def _expand_allowed_platforms(platforms: Optional[List[str]]) -> Optional[List[str]]:
|
| 102 |
+
if not platforms:
|
| 103 |
+
return None
|
| 104 |
+
|
| 105 |
+
seen = set()
|
| 106 |
+
result = []
|
| 107 |
+
|
| 108 |
+
for p in platforms:
|
| 109 |
+
if p in seen:
|
| 110 |
+
continue
|
| 111 |
+
additions = [c for c in _get_custom_platforms(p) if c not in seen]
|
| 112 |
+
seen.update(additions)
|
| 113 |
+
result.extend(additions)
|
| 114 |
+
|
| 115 |
+
return result
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def _get_python_version(version: str) -> PythonVersion:
|
| 119 |
+
if len(version) > 1:
|
| 120 |
+
return int(version[0]), int(version[1:])
|
| 121 |
+
else:
|
| 122 |
+
return (int(version[0]),)
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def _get_custom_interpreter(
|
| 126 |
+
implementation: Optional[str] = None, version: Optional[str] = None
|
| 127 |
+
) -> str:
|
| 128 |
+
if implementation is None:
|
| 129 |
+
implementation = interpreter_name()
|
| 130 |
+
if version is None:
|
| 131 |
+
version = interpreter_version()
|
| 132 |
+
return f"{implementation}{version}"
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def get_supported(
|
| 136 |
+
version: Optional[str] = None,
|
| 137 |
+
platforms: Optional[List[str]] = None,
|
| 138 |
+
impl: Optional[str] = None,
|
| 139 |
+
abis: Optional[List[str]] = None,
|
| 140 |
+
) -> List[Tag]:
|
| 141 |
+
"""Return a list of supported tags for each version specified in
|
| 142 |
+
`versions`.
|
| 143 |
+
|
| 144 |
+
:param version: a string version, of the form "33" or "32",
|
| 145 |
+
or None. The version will be assumed to support our ABI.
|
| 146 |
+
:param platform: specify a list of platforms you want valid
|
| 147 |
+
tags for, or None. If None, use the local system platform.
|
| 148 |
+
:param impl: specify the exact implementation you want valid
|
| 149 |
+
tags for, or None. If None, use the local interpreter impl.
|
| 150 |
+
:param abis: specify a list of abis you want valid
|
| 151 |
+
tags for, or None. If None, use the local interpreter abi.
|
| 152 |
+
"""
|
| 153 |
+
supported: List[Tag] = []
|
| 154 |
+
|
| 155 |
+
python_version: Optional[PythonVersion] = None
|
| 156 |
+
if version is not None:
|
| 157 |
+
python_version = _get_python_version(version)
|
| 158 |
+
|
| 159 |
+
interpreter = _get_custom_interpreter(impl, version)
|
| 160 |
+
|
| 161 |
+
platforms = _expand_allowed_platforms(platforms)
|
| 162 |
+
|
| 163 |
+
is_cpython = (impl or interpreter_name()) == "cp"
|
| 164 |
+
if is_cpython:
|
| 165 |
+
supported.extend(
|
| 166 |
+
cpython_tags(
|
| 167 |
+
python_version=python_version,
|
| 168 |
+
abis=abis,
|
| 169 |
+
platforms=platforms,
|
| 170 |
+
)
|
| 171 |
+
)
|
| 172 |
+
else:
|
| 173 |
+
supported.extend(
|
| 174 |
+
generic_tags(
|
| 175 |
+
interpreter=interpreter,
|
| 176 |
+
abis=abis,
|
| 177 |
+
platforms=platforms,
|
| 178 |
+
)
|
| 179 |
+
)
|
| 180 |
+
supported.extend(
|
| 181 |
+
compatible_tags(
|
| 182 |
+
python_version=python_version,
|
| 183 |
+
interpreter=interpreter,
|
| 184 |
+
platforms=platforms,
|
| 185 |
+
)
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
return supported
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/datetime.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""For when pip wants to check the date or time.
|
| 2 |
+
"""
|
| 3 |
+
|
| 4 |
+
import datetime
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def today_is_later_than(year: int, month: int, day: int) -> bool:
|
| 8 |
+
today = datetime.date.today()
|
| 9 |
+
given = datetime.date(year, month, day)
|
| 10 |
+
|
| 11 |
+
return today > given
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/deprecation.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
A module that implements tooling to enable easy warnings about deprecations.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import logging
|
| 6 |
+
import warnings
|
| 7 |
+
from typing import Any, Optional, TextIO, Type, Union
|
| 8 |
+
|
| 9 |
+
from pip._vendor.packaging.version import parse
|
| 10 |
+
|
| 11 |
+
from pip import __version__ as current_version # NOTE: tests patch this name.
|
| 12 |
+
|
| 13 |
+
DEPRECATION_MSG_PREFIX = "DEPRECATION: "
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class PipDeprecationWarning(Warning):
|
| 17 |
+
pass
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
_original_showwarning: Any = None
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# Warnings <-> Logging Integration
|
| 24 |
+
def _showwarning(
|
| 25 |
+
message: Union[Warning, str],
|
| 26 |
+
category: Type[Warning],
|
| 27 |
+
filename: str,
|
| 28 |
+
lineno: int,
|
| 29 |
+
file: Optional[TextIO] = None,
|
| 30 |
+
line: Optional[str] = None,
|
| 31 |
+
) -> None:
|
| 32 |
+
if file is not None:
|
| 33 |
+
if _original_showwarning is not None:
|
| 34 |
+
_original_showwarning(message, category, filename, lineno, file, line)
|
| 35 |
+
elif issubclass(category, PipDeprecationWarning):
|
| 36 |
+
# We use a specially named logger which will handle all of the
|
| 37 |
+
# deprecation messages for pip.
|
| 38 |
+
logger = logging.getLogger("pip._internal.deprecations")
|
| 39 |
+
logger.warning(message)
|
| 40 |
+
else:
|
| 41 |
+
_original_showwarning(message, category, filename, lineno, file, line)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def install_warning_logger() -> None:
|
| 45 |
+
# Enable our Deprecation Warnings
|
| 46 |
+
warnings.simplefilter("default", PipDeprecationWarning, append=True)
|
| 47 |
+
|
| 48 |
+
global _original_showwarning
|
| 49 |
+
|
| 50 |
+
if _original_showwarning is None:
|
| 51 |
+
_original_showwarning = warnings.showwarning
|
| 52 |
+
warnings.showwarning = _showwarning
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def deprecated(
|
| 56 |
+
*,
|
| 57 |
+
reason: str,
|
| 58 |
+
replacement: Optional[str],
|
| 59 |
+
gone_in: Optional[str],
|
| 60 |
+
feature_flag: Optional[str] = None,
|
| 61 |
+
issue: Optional[int] = None,
|
| 62 |
+
) -> None:
|
| 63 |
+
"""Helper to deprecate existing functionality.
|
| 64 |
+
|
| 65 |
+
reason:
|
| 66 |
+
Textual reason shown to the user about why this functionality has
|
| 67 |
+
been deprecated. Should be a complete sentence.
|
| 68 |
+
replacement:
|
| 69 |
+
Textual suggestion shown to the user about what alternative
|
| 70 |
+
functionality they can use.
|
| 71 |
+
gone_in:
|
| 72 |
+
The version of pip does this functionality should get removed in.
|
| 73 |
+
Raises an error if pip's current version is greater than or equal to
|
| 74 |
+
this.
|
| 75 |
+
feature_flag:
|
| 76 |
+
Command-line flag of the form --use-feature={feature_flag} for testing
|
| 77 |
+
upcoming functionality.
|
| 78 |
+
issue:
|
| 79 |
+
Issue number on the tracker that would serve as a useful place for
|
| 80 |
+
users to find related discussion and provide feedback.
|
| 81 |
+
"""
|
| 82 |
+
|
| 83 |
+
# Determine whether or not the feature is already gone in this version.
|
| 84 |
+
is_gone = gone_in is not None and parse(current_version) >= parse(gone_in)
|
| 85 |
+
|
| 86 |
+
message_parts = [
|
| 87 |
+
(reason, f"{DEPRECATION_MSG_PREFIX}{{}}"),
|
| 88 |
+
(
|
| 89 |
+
gone_in,
|
| 90 |
+
(
|
| 91 |
+
"pip {} will enforce this behaviour change."
|
| 92 |
+
if not is_gone
|
| 93 |
+
else "Since pip {}, this is no longer supported."
|
| 94 |
+
),
|
| 95 |
+
),
|
| 96 |
+
(
|
| 97 |
+
replacement,
|
| 98 |
+
"A possible replacement is {}.",
|
| 99 |
+
),
|
| 100 |
+
(
|
| 101 |
+
feature_flag,
|
| 102 |
+
(
|
| 103 |
+
"You can use the flag --use-feature={} to test the upcoming behaviour."
|
| 104 |
+
if not is_gone
|
| 105 |
+
else None
|
| 106 |
+
),
|
| 107 |
+
),
|
| 108 |
+
(
|
| 109 |
+
issue,
|
| 110 |
+
"Discussion can be found at https://github.com/pypa/pip/issues/{}",
|
| 111 |
+
),
|
| 112 |
+
]
|
| 113 |
+
|
| 114 |
+
message = " ".join(
|
| 115 |
+
format_str.format(value)
|
| 116 |
+
for value, format_str in message_parts
|
| 117 |
+
if format_str is not None and value is not None
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
# Raise as an error if this behaviour is deprecated.
|
| 121 |
+
if is_gone:
|
| 122 |
+
raise PipDeprecationWarning(message)
|
| 123 |
+
|
| 124 |
+
warnings.warn(message, category=PipDeprecationWarning, stacklevel=2)
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/direct_url_helpers.py
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Optional
|
| 2 |
+
|
| 3 |
+
from pip._internal.models.direct_url import ArchiveInfo, DirectUrl, DirInfo, VcsInfo
|
| 4 |
+
from pip._internal.models.link import Link
|
| 5 |
+
from pip._internal.utils.urls import path_to_url
|
| 6 |
+
from pip._internal.vcs import vcs
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def direct_url_as_pep440_direct_reference(direct_url: DirectUrl, name: str) -> str:
|
| 10 |
+
"""Convert a DirectUrl to a pip requirement string."""
|
| 11 |
+
direct_url.validate() # if invalid, this is a pip bug
|
| 12 |
+
requirement = name + " @ "
|
| 13 |
+
fragments = []
|
| 14 |
+
if isinstance(direct_url.info, VcsInfo):
|
| 15 |
+
requirement += (
|
| 16 |
+
f"{direct_url.info.vcs}+{direct_url.url}@{direct_url.info.commit_id}"
|
| 17 |
+
)
|
| 18 |
+
elif isinstance(direct_url.info, ArchiveInfo):
|
| 19 |
+
requirement += direct_url.url
|
| 20 |
+
if direct_url.info.hash:
|
| 21 |
+
fragments.append(direct_url.info.hash)
|
| 22 |
+
else:
|
| 23 |
+
assert isinstance(direct_url.info, DirInfo)
|
| 24 |
+
requirement += direct_url.url
|
| 25 |
+
if direct_url.subdirectory:
|
| 26 |
+
fragments.append("subdirectory=" + direct_url.subdirectory)
|
| 27 |
+
if fragments:
|
| 28 |
+
requirement += "#" + "&".join(fragments)
|
| 29 |
+
return requirement
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def direct_url_for_editable(source_dir: str) -> DirectUrl:
|
| 33 |
+
return DirectUrl(
|
| 34 |
+
url=path_to_url(source_dir),
|
| 35 |
+
info=DirInfo(editable=True),
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def direct_url_from_link(
|
| 40 |
+
link: Link, source_dir: Optional[str] = None, link_is_in_wheel_cache: bool = False
|
| 41 |
+
) -> DirectUrl:
|
| 42 |
+
if link.is_vcs:
|
| 43 |
+
vcs_backend = vcs.get_backend_for_scheme(link.scheme)
|
| 44 |
+
assert vcs_backend
|
| 45 |
+
url, requested_revision, _ = vcs_backend.get_url_rev_and_auth(
|
| 46 |
+
link.url_without_fragment
|
| 47 |
+
)
|
| 48 |
+
# For VCS links, we need to find out and add commit_id.
|
| 49 |
+
if link_is_in_wheel_cache:
|
| 50 |
+
# If the requested VCS link corresponds to a cached
|
| 51 |
+
# wheel, it means the requested revision was an
|
| 52 |
+
# immutable commit hash, otherwise it would not have
|
| 53 |
+
# been cached. In that case we don't have a source_dir
|
| 54 |
+
# with the VCS checkout.
|
| 55 |
+
assert requested_revision
|
| 56 |
+
commit_id = requested_revision
|
| 57 |
+
else:
|
| 58 |
+
# If the wheel was not in cache, it means we have
|
| 59 |
+
# had to checkout from VCS to build and we have a source_dir
|
| 60 |
+
# which we can inspect to find out the commit id.
|
| 61 |
+
assert source_dir
|
| 62 |
+
commit_id = vcs_backend.get_revision(source_dir)
|
| 63 |
+
return DirectUrl(
|
| 64 |
+
url=url,
|
| 65 |
+
info=VcsInfo(
|
| 66 |
+
vcs=vcs_backend.name,
|
| 67 |
+
commit_id=commit_id,
|
| 68 |
+
requested_revision=requested_revision,
|
| 69 |
+
),
|
| 70 |
+
subdirectory=link.subdirectory_fragment,
|
| 71 |
+
)
|
| 72 |
+
elif link.is_existing_dir():
|
| 73 |
+
return DirectUrl(
|
| 74 |
+
url=link.url_without_fragment,
|
| 75 |
+
info=DirInfo(),
|
| 76 |
+
subdirectory=link.subdirectory_fragment,
|
| 77 |
+
)
|
| 78 |
+
else:
|
| 79 |
+
hash = None
|
| 80 |
+
hash_name = link.hash_name
|
| 81 |
+
if hash_name:
|
| 82 |
+
hash = f"{hash_name}={link.hash}"
|
| 83 |
+
return DirectUrl(
|
| 84 |
+
url=link.url_without_fragment,
|
| 85 |
+
info=ArchiveInfo(hash=hash),
|
| 86 |
+
subdirectory=link.subdirectory_fragment,
|
| 87 |
+
)
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/egg_link.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import re
|
| 3 |
+
import sys
|
| 4 |
+
from typing import List, Optional
|
| 5 |
+
|
| 6 |
+
from pip._internal.locations import site_packages, user_site
|
| 7 |
+
from pip._internal.utils.virtualenv import (
|
| 8 |
+
running_under_virtualenv,
|
| 9 |
+
virtualenv_no_global,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
__all__ = [
|
| 13 |
+
"egg_link_path_from_sys_path",
|
| 14 |
+
"egg_link_path_from_location",
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _egg_link_names(raw_name: str) -> List[str]:
|
| 19 |
+
"""
|
| 20 |
+
Convert a Name metadata value to a .egg-link name, by applying
|
| 21 |
+
the same substitution as pkg_resources's safe_name function.
|
| 22 |
+
Note: we cannot use canonicalize_name because it has a different logic.
|
| 23 |
+
|
| 24 |
+
We also look for the raw name (without normalization) as setuptools 69 changed
|
| 25 |
+
the way it names .egg-link files (https://github.com/pypa/setuptools/issues/4167).
|
| 26 |
+
"""
|
| 27 |
+
return [
|
| 28 |
+
re.sub("[^A-Za-z0-9.]+", "-", raw_name) + ".egg-link",
|
| 29 |
+
f"{raw_name}.egg-link",
|
| 30 |
+
]
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def egg_link_path_from_sys_path(raw_name: str) -> Optional[str]:
|
| 34 |
+
"""
|
| 35 |
+
Look for a .egg-link file for project name, by walking sys.path.
|
| 36 |
+
"""
|
| 37 |
+
egg_link_names = _egg_link_names(raw_name)
|
| 38 |
+
for path_item in sys.path:
|
| 39 |
+
for egg_link_name in egg_link_names:
|
| 40 |
+
egg_link = os.path.join(path_item, egg_link_name)
|
| 41 |
+
if os.path.isfile(egg_link):
|
| 42 |
+
return egg_link
|
| 43 |
+
return None
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
def egg_link_path_from_location(raw_name: str) -> Optional[str]:
|
| 47 |
+
"""
|
| 48 |
+
Return the path for the .egg-link file if it exists, otherwise, None.
|
| 49 |
+
|
| 50 |
+
There's 3 scenarios:
|
| 51 |
+
1) not in a virtualenv
|
| 52 |
+
try to find in site.USER_SITE, then site_packages
|
| 53 |
+
2) in a no-global virtualenv
|
| 54 |
+
try to find in site_packages
|
| 55 |
+
3) in a yes-global virtualenv
|
| 56 |
+
try to find in site_packages, then site.USER_SITE
|
| 57 |
+
(don't look in global location)
|
| 58 |
+
|
| 59 |
+
For #1 and #3, there could be odd cases, where there's an egg-link in 2
|
| 60 |
+
locations.
|
| 61 |
+
|
| 62 |
+
This method will just return the first one found.
|
| 63 |
+
"""
|
| 64 |
+
sites: List[str] = []
|
| 65 |
+
if running_under_virtualenv():
|
| 66 |
+
sites.append(site_packages)
|
| 67 |
+
if not virtualenv_no_global() and user_site:
|
| 68 |
+
sites.append(user_site)
|
| 69 |
+
else:
|
| 70 |
+
if user_site:
|
| 71 |
+
sites.append(user_site)
|
| 72 |
+
sites.append(site_packages)
|
| 73 |
+
|
| 74 |
+
egg_link_names = _egg_link_names(raw_name)
|
| 75 |
+
for site in sites:
|
| 76 |
+
for egg_link_name in egg_link_names:
|
| 77 |
+
egglink = os.path.join(site, egg_link_name)
|
| 78 |
+
if os.path.isfile(egglink):
|
| 79 |
+
return egglink
|
| 80 |
+
return None
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/filetypes.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Filetype information.
|
| 2 |
+
"""
|
| 3 |
+
|
| 4 |
+
from typing import Tuple
|
| 5 |
+
|
| 6 |
+
from pip._internal.utils.misc import splitext
|
| 7 |
+
|
| 8 |
+
WHEEL_EXTENSION = ".whl"
|
| 9 |
+
BZ2_EXTENSIONS: Tuple[str, ...] = (".tar.bz2", ".tbz")
|
| 10 |
+
XZ_EXTENSIONS: Tuple[str, ...] = (
|
| 11 |
+
".tar.xz",
|
| 12 |
+
".txz",
|
| 13 |
+
".tlz",
|
| 14 |
+
".tar.lz",
|
| 15 |
+
".tar.lzma",
|
| 16 |
+
)
|
| 17 |
+
ZIP_EXTENSIONS: Tuple[str, ...] = (".zip", WHEEL_EXTENSION)
|
| 18 |
+
TAR_EXTENSIONS: Tuple[str, ...] = (".tar.gz", ".tgz", ".tar")
|
| 19 |
+
ARCHIVE_EXTENSIONS = ZIP_EXTENSIONS + BZ2_EXTENSIONS + TAR_EXTENSIONS + XZ_EXTENSIONS
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def is_archive_file(name: str) -> bool:
|
| 23 |
+
"""Return True if `name` is a considered as an archive file."""
|
| 24 |
+
ext = splitext(name)[1].lower()
|
| 25 |
+
if ext in ARCHIVE_EXTENSIONS:
|
| 26 |
+
return True
|
| 27 |
+
return False
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/glibc.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
from typing import Optional, Tuple
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def glibc_version_string() -> Optional[str]:
|
| 7 |
+
"Returns glibc version string, or None if not using glibc."
|
| 8 |
+
return glibc_version_string_confstr() or glibc_version_string_ctypes()
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def glibc_version_string_confstr() -> Optional[str]:
|
| 12 |
+
"Primary implementation of glibc_version_string using os.confstr."
|
| 13 |
+
# os.confstr is quite a bit faster than ctypes.DLL. It's also less likely
|
| 14 |
+
# to be broken or missing. This strategy is used in the standard library
|
| 15 |
+
# platform module:
|
| 16 |
+
# https://github.com/python/cpython/blob/fcf1d003bf4f0100c9d0921ff3d70e1127ca1b71/Lib/platform.py#L175-L183
|
| 17 |
+
if sys.platform == "win32":
|
| 18 |
+
return None
|
| 19 |
+
try:
|
| 20 |
+
gnu_libc_version = os.confstr("CS_GNU_LIBC_VERSION")
|
| 21 |
+
if gnu_libc_version is None:
|
| 22 |
+
return None
|
| 23 |
+
# os.confstr("CS_GNU_LIBC_VERSION") returns a string like "glibc 2.17":
|
| 24 |
+
_, version = gnu_libc_version.split()
|
| 25 |
+
except (AttributeError, OSError, ValueError):
|
| 26 |
+
# os.confstr() or CS_GNU_LIBC_VERSION not available (or a bad value)...
|
| 27 |
+
return None
|
| 28 |
+
return version
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def glibc_version_string_ctypes() -> Optional[str]:
|
| 32 |
+
"Fallback implementation of glibc_version_string using ctypes."
|
| 33 |
+
|
| 34 |
+
try:
|
| 35 |
+
import ctypes
|
| 36 |
+
except ImportError:
|
| 37 |
+
return None
|
| 38 |
+
|
| 39 |
+
# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
|
| 40 |
+
# manpage says, "If filename is NULL, then the returned handle is for the
|
| 41 |
+
# main program". This way we can let the linker do the work to figure out
|
| 42 |
+
# which libc our process is actually using.
|
| 43 |
+
#
|
| 44 |
+
# We must also handle the special case where the executable is not a
|
| 45 |
+
# dynamically linked executable. This can occur when using musl libc,
|
| 46 |
+
# for example. In this situation, dlopen() will error, leading to an
|
| 47 |
+
# OSError. Interestingly, at least in the case of musl, there is no
|
| 48 |
+
# errno set on the OSError. The single string argument used to construct
|
| 49 |
+
# OSError comes from libc itself and is therefore not portable to
|
| 50 |
+
# hard code here. In any case, failure to call dlopen() means we
|
| 51 |
+
# can't proceed, so we bail on our attempt.
|
| 52 |
+
try:
|
| 53 |
+
process_namespace = ctypes.CDLL(None)
|
| 54 |
+
except OSError:
|
| 55 |
+
return None
|
| 56 |
+
|
| 57 |
+
try:
|
| 58 |
+
gnu_get_libc_version = process_namespace.gnu_get_libc_version
|
| 59 |
+
except AttributeError:
|
| 60 |
+
# Symbol doesn't exist -> therefore, we are not linked to
|
| 61 |
+
# glibc.
|
| 62 |
+
return None
|
| 63 |
+
|
| 64 |
+
# Call gnu_get_libc_version, which returns a string like "2.5"
|
| 65 |
+
gnu_get_libc_version.restype = ctypes.c_char_p
|
| 66 |
+
version_str: str = gnu_get_libc_version()
|
| 67 |
+
# py2 / py3 compatibility:
|
| 68 |
+
if not isinstance(version_str, str):
|
| 69 |
+
version_str = version_str.decode("ascii")
|
| 70 |
+
|
| 71 |
+
return version_str
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
# platform.libc_ver regularly returns completely nonsensical glibc
|
| 75 |
+
# versions. E.g. on my computer, platform says:
|
| 76 |
+
#
|
| 77 |
+
# ~$ python2.7 -c 'import platform; print(platform.libc_ver())'
|
| 78 |
+
# ('glibc', '2.7')
|
| 79 |
+
# ~$ python3.5 -c 'import platform; print(platform.libc_ver())'
|
| 80 |
+
# ('glibc', '2.9')
|
| 81 |
+
#
|
| 82 |
+
# But the truth is:
|
| 83 |
+
#
|
| 84 |
+
# ~$ ldd --version
|
| 85 |
+
# ldd (Debian GLIBC 2.22-11) 2.22
|
| 86 |
+
#
|
| 87 |
+
# This is unfortunate, because it means that the linehaul data on libc
|
| 88 |
+
# versions that was generated by pip 8.1.2 and earlier is useless and
|
| 89 |
+
# misleading. Solution: instead of using platform, use our code that actually
|
| 90 |
+
# works.
|
| 91 |
+
def libc_ver() -> Tuple[str, str]:
|
| 92 |
+
"""Try to determine the glibc version
|
| 93 |
+
|
| 94 |
+
Returns a tuple of strings (lib, version) which default to empty strings
|
| 95 |
+
in case the lookup fails.
|
| 96 |
+
"""
|
| 97 |
+
glibc_version = glibc_version_string()
|
| 98 |
+
if glibc_version is None:
|
| 99 |
+
return ("", "")
|
| 100 |
+
else:
|
| 101 |
+
return ("glibc", glibc_version)
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/logging.py
ADDED
|
@@ -0,0 +1,354 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import contextlib
|
| 2 |
+
import errno
|
| 3 |
+
import logging
|
| 4 |
+
import logging.handlers
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
import threading
|
| 8 |
+
from dataclasses import dataclass
|
| 9 |
+
from io import TextIOWrapper
|
| 10 |
+
from logging import Filter
|
| 11 |
+
from typing import Any, ClassVar, Generator, List, Optional, TextIO, Type
|
| 12 |
+
|
| 13 |
+
from pip._vendor.rich.console import (
|
| 14 |
+
Console,
|
| 15 |
+
ConsoleOptions,
|
| 16 |
+
ConsoleRenderable,
|
| 17 |
+
RenderableType,
|
| 18 |
+
RenderResult,
|
| 19 |
+
RichCast,
|
| 20 |
+
)
|
| 21 |
+
from pip._vendor.rich.highlighter import NullHighlighter
|
| 22 |
+
from pip._vendor.rich.logging import RichHandler
|
| 23 |
+
from pip._vendor.rich.segment import Segment
|
| 24 |
+
from pip._vendor.rich.style import Style
|
| 25 |
+
|
| 26 |
+
from pip._internal.utils._log import VERBOSE, getLogger
|
| 27 |
+
from pip._internal.utils.compat import WINDOWS
|
| 28 |
+
from pip._internal.utils.deprecation import DEPRECATION_MSG_PREFIX
|
| 29 |
+
from pip._internal.utils.misc import ensure_dir
|
| 30 |
+
|
| 31 |
+
_log_state = threading.local()
|
| 32 |
+
subprocess_logger = getLogger("pip.subprocessor")
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class BrokenStdoutLoggingError(Exception):
|
| 36 |
+
"""
|
| 37 |
+
Raised if BrokenPipeError occurs for the stdout stream while logging.
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def _is_broken_pipe_error(exc_class: Type[BaseException], exc: BaseException) -> bool:
|
| 42 |
+
if exc_class is BrokenPipeError:
|
| 43 |
+
return True
|
| 44 |
+
|
| 45 |
+
# On Windows, a broken pipe can show up as EINVAL rather than EPIPE:
|
| 46 |
+
# https://bugs.python.org/issue19612
|
| 47 |
+
# https://bugs.python.org/issue30418
|
| 48 |
+
if not WINDOWS:
|
| 49 |
+
return False
|
| 50 |
+
|
| 51 |
+
return isinstance(exc, OSError) and exc.errno in (errno.EINVAL, errno.EPIPE)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
@contextlib.contextmanager
|
| 55 |
+
def indent_log(num: int = 2) -> Generator[None, None, None]:
|
| 56 |
+
"""
|
| 57 |
+
A context manager which will cause the log output to be indented for any
|
| 58 |
+
log messages emitted inside it.
|
| 59 |
+
"""
|
| 60 |
+
# For thread-safety
|
| 61 |
+
_log_state.indentation = get_indentation()
|
| 62 |
+
_log_state.indentation += num
|
| 63 |
+
try:
|
| 64 |
+
yield
|
| 65 |
+
finally:
|
| 66 |
+
_log_state.indentation -= num
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def get_indentation() -> int:
|
| 70 |
+
return getattr(_log_state, "indentation", 0)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
class IndentingFormatter(logging.Formatter):
|
| 74 |
+
default_time_format = "%Y-%m-%dT%H:%M:%S"
|
| 75 |
+
|
| 76 |
+
def __init__(
|
| 77 |
+
self,
|
| 78 |
+
*args: Any,
|
| 79 |
+
add_timestamp: bool = False,
|
| 80 |
+
**kwargs: Any,
|
| 81 |
+
) -> None:
|
| 82 |
+
"""
|
| 83 |
+
A logging.Formatter that obeys the indent_log() context manager.
|
| 84 |
+
|
| 85 |
+
:param add_timestamp: A bool indicating output lines should be prefixed
|
| 86 |
+
with their record's timestamp.
|
| 87 |
+
"""
|
| 88 |
+
self.add_timestamp = add_timestamp
|
| 89 |
+
super().__init__(*args, **kwargs)
|
| 90 |
+
|
| 91 |
+
def get_message_start(self, formatted: str, levelno: int) -> str:
|
| 92 |
+
"""
|
| 93 |
+
Return the start of the formatted log message (not counting the
|
| 94 |
+
prefix to add to each line).
|
| 95 |
+
"""
|
| 96 |
+
if levelno < logging.WARNING:
|
| 97 |
+
return ""
|
| 98 |
+
if formatted.startswith(DEPRECATION_MSG_PREFIX):
|
| 99 |
+
# Then the message already has a prefix. We don't want it to
|
| 100 |
+
# look like "WARNING: DEPRECATION: ...."
|
| 101 |
+
return ""
|
| 102 |
+
if levelno < logging.ERROR:
|
| 103 |
+
return "WARNING: "
|
| 104 |
+
|
| 105 |
+
return "ERROR: "
|
| 106 |
+
|
| 107 |
+
def format(self, record: logging.LogRecord) -> str:
|
| 108 |
+
"""
|
| 109 |
+
Calls the standard formatter, but will indent all of the log message
|
| 110 |
+
lines by our current indentation level.
|
| 111 |
+
"""
|
| 112 |
+
formatted = super().format(record)
|
| 113 |
+
message_start = self.get_message_start(formatted, record.levelno)
|
| 114 |
+
formatted = message_start + formatted
|
| 115 |
+
|
| 116 |
+
prefix = ""
|
| 117 |
+
if self.add_timestamp:
|
| 118 |
+
prefix = f"{self.formatTime(record)} "
|
| 119 |
+
prefix += " " * get_indentation()
|
| 120 |
+
formatted = "".join([prefix + line for line in formatted.splitlines(True)])
|
| 121 |
+
return formatted
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
@dataclass
|
| 125 |
+
class IndentedRenderable:
|
| 126 |
+
renderable: RenderableType
|
| 127 |
+
indent: int
|
| 128 |
+
|
| 129 |
+
def __rich_console__(
|
| 130 |
+
self, console: Console, options: ConsoleOptions
|
| 131 |
+
) -> RenderResult:
|
| 132 |
+
segments = console.render(self.renderable, options)
|
| 133 |
+
lines = Segment.split_lines(segments)
|
| 134 |
+
for line in lines:
|
| 135 |
+
yield Segment(" " * self.indent)
|
| 136 |
+
yield from line
|
| 137 |
+
yield Segment("\n")
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
class PipConsole(Console):
|
| 141 |
+
def on_broken_pipe(self) -> None:
|
| 142 |
+
# Reraise the original exception, rich 13.8.0+ exits by default
|
| 143 |
+
# instead, preventing our handler from firing.
|
| 144 |
+
raise BrokenPipeError() from None
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
class RichPipStreamHandler(RichHandler):
|
| 148 |
+
KEYWORDS: ClassVar[Optional[List[str]]] = []
|
| 149 |
+
|
| 150 |
+
def __init__(self, stream: Optional[TextIO], no_color: bool) -> None:
|
| 151 |
+
super().__init__(
|
| 152 |
+
console=PipConsole(file=stream, no_color=no_color, soft_wrap=True),
|
| 153 |
+
show_time=False,
|
| 154 |
+
show_level=False,
|
| 155 |
+
show_path=False,
|
| 156 |
+
highlighter=NullHighlighter(),
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
# Our custom override on Rich's logger, to make things work as we need them to.
|
| 160 |
+
def emit(self, record: logging.LogRecord) -> None:
|
| 161 |
+
style: Optional[Style] = None
|
| 162 |
+
|
| 163 |
+
# If we are given a diagnostic error to present, present it with indentation.
|
| 164 |
+
if getattr(record, "rich", False):
|
| 165 |
+
assert isinstance(record.args, tuple)
|
| 166 |
+
(rich_renderable,) = record.args
|
| 167 |
+
assert isinstance(
|
| 168 |
+
rich_renderable, (ConsoleRenderable, RichCast, str)
|
| 169 |
+
), f"{rich_renderable} is not rich-console-renderable"
|
| 170 |
+
|
| 171 |
+
renderable: RenderableType = IndentedRenderable(
|
| 172 |
+
rich_renderable, indent=get_indentation()
|
| 173 |
+
)
|
| 174 |
+
else:
|
| 175 |
+
message = self.format(record)
|
| 176 |
+
renderable = self.render_message(record, message)
|
| 177 |
+
if record.levelno is not None:
|
| 178 |
+
if record.levelno >= logging.ERROR:
|
| 179 |
+
style = Style(color="red")
|
| 180 |
+
elif record.levelno >= logging.WARNING:
|
| 181 |
+
style = Style(color="yellow")
|
| 182 |
+
|
| 183 |
+
try:
|
| 184 |
+
self.console.print(renderable, overflow="ignore", crop=False, style=style)
|
| 185 |
+
except Exception:
|
| 186 |
+
self.handleError(record)
|
| 187 |
+
|
| 188 |
+
def handleError(self, record: logging.LogRecord) -> None:
|
| 189 |
+
"""Called when logging is unable to log some output."""
|
| 190 |
+
|
| 191 |
+
exc_class, exc = sys.exc_info()[:2]
|
| 192 |
+
# If a broken pipe occurred while calling write() or flush() on the
|
| 193 |
+
# stdout stream in logging's Handler.emit(), then raise our special
|
| 194 |
+
# exception so we can handle it in main() instead of logging the
|
| 195 |
+
# broken pipe error and continuing.
|
| 196 |
+
if (
|
| 197 |
+
exc_class
|
| 198 |
+
and exc
|
| 199 |
+
and self.console.file is sys.stdout
|
| 200 |
+
and _is_broken_pipe_error(exc_class, exc)
|
| 201 |
+
):
|
| 202 |
+
raise BrokenStdoutLoggingError()
|
| 203 |
+
|
| 204 |
+
return super().handleError(record)
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
class BetterRotatingFileHandler(logging.handlers.RotatingFileHandler):
|
| 208 |
+
def _open(self) -> TextIOWrapper:
|
| 209 |
+
ensure_dir(os.path.dirname(self.baseFilename))
|
| 210 |
+
return super()._open()
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
class MaxLevelFilter(Filter):
|
| 214 |
+
def __init__(self, level: int) -> None:
|
| 215 |
+
self.level = level
|
| 216 |
+
|
| 217 |
+
def filter(self, record: logging.LogRecord) -> bool:
|
| 218 |
+
return record.levelno < self.level
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
class ExcludeLoggerFilter(Filter):
|
| 222 |
+
"""
|
| 223 |
+
A logging Filter that excludes records from a logger (or its children).
|
| 224 |
+
"""
|
| 225 |
+
|
| 226 |
+
def filter(self, record: logging.LogRecord) -> bool:
|
| 227 |
+
# The base Filter class allows only records from a logger (or its
|
| 228 |
+
# children).
|
| 229 |
+
return not super().filter(record)
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
def setup_logging(verbosity: int, no_color: bool, user_log_file: Optional[str]) -> int:
|
| 233 |
+
"""Configures and sets up all of the logging
|
| 234 |
+
|
| 235 |
+
Returns the requested logging level, as its integer value.
|
| 236 |
+
"""
|
| 237 |
+
|
| 238 |
+
# Determine the level to be logging at.
|
| 239 |
+
if verbosity >= 2:
|
| 240 |
+
level_number = logging.DEBUG
|
| 241 |
+
elif verbosity == 1:
|
| 242 |
+
level_number = VERBOSE
|
| 243 |
+
elif verbosity == -1:
|
| 244 |
+
level_number = logging.WARNING
|
| 245 |
+
elif verbosity == -2:
|
| 246 |
+
level_number = logging.ERROR
|
| 247 |
+
elif verbosity <= -3:
|
| 248 |
+
level_number = logging.CRITICAL
|
| 249 |
+
else:
|
| 250 |
+
level_number = logging.INFO
|
| 251 |
+
|
| 252 |
+
level = logging.getLevelName(level_number)
|
| 253 |
+
|
| 254 |
+
# The "root" logger should match the "console" level *unless* we also need
|
| 255 |
+
# to log to a user log file.
|
| 256 |
+
include_user_log = user_log_file is not None
|
| 257 |
+
if include_user_log:
|
| 258 |
+
additional_log_file = user_log_file
|
| 259 |
+
root_level = "DEBUG"
|
| 260 |
+
else:
|
| 261 |
+
additional_log_file = "/dev/null"
|
| 262 |
+
root_level = level
|
| 263 |
+
|
| 264 |
+
# Disable any logging besides WARNING unless we have DEBUG level logging
|
| 265 |
+
# enabled for vendored libraries.
|
| 266 |
+
vendored_log_level = "WARNING" if level in ["INFO", "ERROR"] else "DEBUG"
|
| 267 |
+
|
| 268 |
+
# Shorthands for clarity
|
| 269 |
+
log_streams = {
|
| 270 |
+
"stdout": "ext://sys.stdout",
|
| 271 |
+
"stderr": "ext://sys.stderr",
|
| 272 |
+
}
|
| 273 |
+
handler_classes = {
|
| 274 |
+
"stream": "pip._internal.utils.logging.RichPipStreamHandler",
|
| 275 |
+
"file": "pip._internal.utils.logging.BetterRotatingFileHandler",
|
| 276 |
+
}
|
| 277 |
+
handlers = ["console", "console_errors", "console_subprocess"] + (
|
| 278 |
+
["user_log"] if include_user_log else []
|
| 279 |
+
)
|
| 280 |
+
|
| 281 |
+
logging.config.dictConfig(
|
| 282 |
+
{
|
| 283 |
+
"version": 1,
|
| 284 |
+
"disable_existing_loggers": False,
|
| 285 |
+
"filters": {
|
| 286 |
+
"exclude_warnings": {
|
| 287 |
+
"()": "pip._internal.utils.logging.MaxLevelFilter",
|
| 288 |
+
"level": logging.WARNING,
|
| 289 |
+
},
|
| 290 |
+
"restrict_to_subprocess": {
|
| 291 |
+
"()": "logging.Filter",
|
| 292 |
+
"name": subprocess_logger.name,
|
| 293 |
+
},
|
| 294 |
+
"exclude_subprocess": {
|
| 295 |
+
"()": "pip._internal.utils.logging.ExcludeLoggerFilter",
|
| 296 |
+
"name": subprocess_logger.name,
|
| 297 |
+
},
|
| 298 |
+
},
|
| 299 |
+
"formatters": {
|
| 300 |
+
"indent": {
|
| 301 |
+
"()": IndentingFormatter,
|
| 302 |
+
"format": "%(message)s",
|
| 303 |
+
},
|
| 304 |
+
"indent_with_timestamp": {
|
| 305 |
+
"()": IndentingFormatter,
|
| 306 |
+
"format": "%(message)s",
|
| 307 |
+
"add_timestamp": True,
|
| 308 |
+
},
|
| 309 |
+
},
|
| 310 |
+
"handlers": {
|
| 311 |
+
"console": {
|
| 312 |
+
"level": level,
|
| 313 |
+
"class": handler_classes["stream"],
|
| 314 |
+
"no_color": no_color,
|
| 315 |
+
"stream": log_streams["stdout"],
|
| 316 |
+
"filters": ["exclude_subprocess", "exclude_warnings"],
|
| 317 |
+
"formatter": "indent",
|
| 318 |
+
},
|
| 319 |
+
"console_errors": {
|
| 320 |
+
"level": "WARNING",
|
| 321 |
+
"class": handler_classes["stream"],
|
| 322 |
+
"no_color": no_color,
|
| 323 |
+
"stream": log_streams["stderr"],
|
| 324 |
+
"filters": ["exclude_subprocess"],
|
| 325 |
+
"formatter": "indent",
|
| 326 |
+
},
|
| 327 |
+
# A handler responsible for logging to the console messages
|
| 328 |
+
# from the "subprocessor" logger.
|
| 329 |
+
"console_subprocess": {
|
| 330 |
+
"level": level,
|
| 331 |
+
"class": handler_classes["stream"],
|
| 332 |
+
"stream": log_streams["stderr"],
|
| 333 |
+
"no_color": no_color,
|
| 334 |
+
"filters": ["restrict_to_subprocess"],
|
| 335 |
+
"formatter": "indent",
|
| 336 |
+
},
|
| 337 |
+
"user_log": {
|
| 338 |
+
"level": "DEBUG",
|
| 339 |
+
"class": handler_classes["file"],
|
| 340 |
+
"filename": additional_log_file,
|
| 341 |
+
"encoding": "utf-8",
|
| 342 |
+
"delay": True,
|
| 343 |
+
"formatter": "indent_with_timestamp",
|
| 344 |
+
},
|
| 345 |
+
},
|
| 346 |
+
"root": {
|
| 347 |
+
"level": root_level,
|
| 348 |
+
"handlers": handlers,
|
| 349 |
+
},
|
| 350 |
+
"loggers": {"pip._vendor": {"level": vendored_log_level}},
|
| 351 |
+
}
|
| 352 |
+
)
|
| 353 |
+
|
| 354 |
+
return level_number
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/misc.py
ADDED
|
@@ -0,0 +1,773 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import errno
|
| 2 |
+
import getpass
|
| 3 |
+
import hashlib
|
| 4 |
+
import logging
|
| 5 |
+
import os
|
| 6 |
+
import posixpath
|
| 7 |
+
import shutil
|
| 8 |
+
import stat
|
| 9 |
+
import sys
|
| 10 |
+
import sysconfig
|
| 11 |
+
import urllib.parse
|
| 12 |
+
from dataclasses import dataclass
|
| 13 |
+
from functools import partial
|
| 14 |
+
from io import StringIO
|
| 15 |
+
from itertools import filterfalse, tee, zip_longest
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
from types import FunctionType, TracebackType
|
| 18 |
+
from typing import (
|
| 19 |
+
Any,
|
| 20 |
+
BinaryIO,
|
| 21 |
+
Callable,
|
| 22 |
+
Generator,
|
| 23 |
+
Iterable,
|
| 24 |
+
Iterator,
|
| 25 |
+
List,
|
| 26 |
+
Mapping,
|
| 27 |
+
Optional,
|
| 28 |
+
Sequence,
|
| 29 |
+
TextIO,
|
| 30 |
+
Tuple,
|
| 31 |
+
Type,
|
| 32 |
+
TypeVar,
|
| 33 |
+
Union,
|
| 34 |
+
cast,
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
from pip._vendor.packaging.requirements import Requirement
|
| 38 |
+
from pip._vendor.pyproject_hooks import BuildBackendHookCaller
|
| 39 |
+
|
| 40 |
+
from pip import __version__
|
| 41 |
+
from pip._internal.exceptions import CommandError, ExternallyManagedEnvironment
|
| 42 |
+
from pip._internal.locations import get_major_minor_version
|
| 43 |
+
from pip._internal.utils.compat import WINDOWS
|
| 44 |
+
from pip._internal.utils.retry import retry
|
| 45 |
+
from pip._internal.utils.virtualenv import running_under_virtualenv
|
| 46 |
+
|
| 47 |
+
__all__ = [
|
| 48 |
+
"rmtree",
|
| 49 |
+
"display_path",
|
| 50 |
+
"backup_dir",
|
| 51 |
+
"ask",
|
| 52 |
+
"splitext",
|
| 53 |
+
"format_size",
|
| 54 |
+
"is_installable_dir",
|
| 55 |
+
"normalize_path",
|
| 56 |
+
"renames",
|
| 57 |
+
"get_prog",
|
| 58 |
+
"ensure_dir",
|
| 59 |
+
"remove_auth_from_url",
|
| 60 |
+
"check_externally_managed",
|
| 61 |
+
"ConfiguredBuildBackendHookCaller",
|
| 62 |
+
]
|
| 63 |
+
|
| 64 |
+
logger = logging.getLogger(__name__)
|
| 65 |
+
|
| 66 |
+
T = TypeVar("T")
|
| 67 |
+
ExcInfo = Tuple[Type[BaseException], BaseException, TracebackType]
|
| 68 |
+
VersionInfo = Tuple[int, int, int]
|
| 69 |
+
NetlocTuple = Tuple[str, Tuple[Optional[str], Optional[str]]]
|
| 70 |
+
OnExc = Callable[[FunctionType, Path, BaseException], Any]
|
| 71 |
+
OnErr = Callable[[FunctionType, Path, ExcInfo], Any]
|
| 72 |
+
|
| 73 |
+
FILE_CHUNK_SIZE = 1024 * 1024
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def get_pip_version() -> str:
|
| 77 |
+
pip_pkg_dir = os.path.join(os.path.dirname(__file__), "..", "..")
|
| 78 |
+
pip_pkg_dir = os.path.abspath(pip_pkg_dir)
|
| 79 |
+
|
| 80 |
+
return f"pip {__version__} from {pip_pkg_dir} (python {get_major_minor_version()})"
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def normalize_version_info(py_version_info: Tuple[int, ...]) -> Tuple[int, int, int]:
|
| 84 |
+
"""
|
| 85 |
+
Convert a tuple of ints representing a Python version to one of length
|
| 86 |
+
three.
|
| 87 |
+
|
| 88 |
+
:param py_version_info: a tuple of ints representing a Python version,
|
| 89 |
+
or None to specify no version. The tuple can have any length.
|
| 90 |
+
|
| 91 |
+
:return: a tuple of length three if `py_version_info` is non-None.
|
| 92 |
+
Otherwise, return `py_version_info` unchanged (i.e. None).
|
| 93 |
+
"""
|
| 94 |
+
if len(py_version_info) < 3:
|
| 95 |
+
py_version_info += (3 - len(py_version_info)) * (0,)
|
| 96 |
+
elif len(py_version_info) > 3:
|
| 97 |
+
py_version_info = py_version_info[:3]
|
| 98 |
+
|
| 99 |
+
return cast("VersionInfo", py_version_info)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def ensure_dir(path: str) -> None:
|
| 103 |
+
"""os.path.makedirs without EEXIST."""
|
| 104 |
+
try:
|
| 105 |
+
os.makedirs(path)
|
| 106 |
+
except OSError as e:
|
| 107 |
+
# Windows can raise spurious ENOTEMPTY errors. See #6426.
|
| 108 |
+
if e.errno != errno.EEXIST and e.errno != errno.ENOTEMPTY:
|
| 109 |
+
raise
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def get_prog() -> str:
|
| 113 |
+
try:
|
| 114 |
+
prog = os.path.basename(sys.argv[0])
|
| 115 |
+
if prog in ("__main__.py", "-c"):
|
| 116 |
+
return f"{sys.executable} -m pip"
|
| 117 |
+
else:
|
| 118 |
+
return prog
|
| 119 |
+
except (AttributeError, TypeError, IndexError):
|
| 120 |
+
pass
|
| 121 |
+
return "pip"
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
# Retry every half second for up to 3 seconds
|
| 125 |
+
@retry(stop_after_delay=3, wait=0.5)
|
| 126 |
+
def rmtree(
|
| 127 |
+
dir: str, ignore_errors: bool = False, onexc: Optional[OnExc] = None
|
| 128 |
+
) -> None:
|
| 129 |
+
if ignore_errors:
|
| 130 |
+
onexc = _onerror_ignore
|
| 131 |
+
if onexc is None:
|
| 132 |
+
onexc = _onerror_reraise
|
| 133 |
+
handler: OnErr = partial(rmtree_errorhandler, onexc=onexc)
|
| 134 |
+
if sys.version_info >= (3, 12):
|
| 135 |
+
# See https://docs.python.org/3.12/whatsnew/3.12.html#shutil.
|
| 136 |
+
shutil.rmtree(dir, onexc=handler) # type: ignore
|
| 137 |
+
else:
|
| 138 |
+
shutil.rmtree(dir, onerror=handler) # type: ignore
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
def _onerror_ignore(*_args: Any) -> None:
|
| 142 |
+
pass
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def _onerror_reraise(*_args: Any) -> None:
|
| 146 |
+
raise # noqa: PLE0704 - Bare exception used to reraise existing exception
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def rmtree_errorhandler(
|
| 150 |
+
func: FunctionType,
|
| 151 |
+
path: Path,
|
| 152 |
+
exc_info: Union[ExcInfo, BaseException],
|
| 153 |
+
*,
|
| 154 |
+
onexc: OnExc = _onerror_reraise,
|
| 155 |
+
) -> None:
|
| 156 |
+
"""
|
| 157 |
+
`rmtree` error handler to 'force' a file remove (i.e. like `rm -f`).
|
| 158 |
+
|
| 159 |
+
* If a file is readonly then it's write flag is set and operation is
|
| 160 |
+
retried.
|
| 161 |
+
|
| 162 |
+
* `onerror` is the original callback from `rmtree(... onerror=onerror)`
|
| 163 |
+
that is chained at the end if the "rm -f" still fails.
|
| 164 |
+
"""
|
| 165 |
+
try:
|
| 166 |
+
st_mode = os.stat(path).st_mode
|
| 167 |
+
except OSError:
|
| 168 |
+
# it's equivalent to os.path.exists
|
| 169 |
+
return
|
| 170 |
+
|
| 171 |
+
if not st_mode & stat.S_IWRITE:
|
| 172 |
+
# convert to read/write
|
| 173 |
+
try:
|
| 174 |
+
os.chmod(path, st_mode | stat.S_IWRITE)
|
| 175 |
+
except OSError:
|
| 176 |
+
pass
|
| 177 |
+
else:
|
| 178 |
+
# use the original function to repeat the operation
|
| 179 |
+
try:
|
| 180 |
+
func(path)
|
| 181 |
+
return
|
| 182 |
+
except OSError:
|
| 183 |
+
pass
|
| 184 |
+
|
| 185 |
+
if not isinstance(exc_info, BaseException):
|
| 186 |
+
_, exc_info, _ = exc_info
|
| 187 |
+
onexc(func, path, exc_info)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def display_path(path: str) -> str:
|
| 191 |
+
"""Gives the display value for a given path, making it relative to cwd
|
| 192 |
+
if possible."""
|
| 193 |
+
path = os.path.normcase(os.path.abspath(path))
|
| 194 |
+
if path.startswith(os.getcwd() + os.path.sep):
|
| 195 |
+
path = "." + path[len(os.getcwd()) :]
|
| 196 |
+
return path
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
def backup_dir(dir: str, ext: str = ".bak") -> str:
|
| 200 |
+
"""Figure out the name of a directory to back up the given dir to
|
| 201 |
+
(adding .bak, .bak2, etc)"""
|
| 202 |
+
n = 1
|
| 203 |
+
extension = ext
|
| 204 |
+
while os.path.exists(dir + extension):
|
| 205 |
+
n += 1
|
| 206 |
+
extension = ext + str(n)
|
| 207 |
+
return dir + extension
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def ask_path_exists(message: str, options: Iterable[str]) -> str:
|
| 211 |
+
for action in os.environ.get("PIP_EXISTS_ACTION", "").split():
|
| 212 |
+
if action in options:
|
| 213 |
+
return action
|
| 214 |
+
return ask(message, options)
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
def _check_no_input(message: str) -> None:
|
| 218 |
+
"""Raise an error if no input is allowed."""
|
| 219 |
+
if os.environ.get("PIP_NO_INPUT"):
|
| 220 |
+
raise Exception(
|
| 221 |
+
f"No input was expected ($PIP_NO_INPUT set); question: {message}"
|
| 222 |
+
)
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def ask(message: str, options: Iterable[str]) -> str:
|
| 226 |
+
"""Ask the message interactively, with the given possible responses"""
|
| 227 |
+
while 1:
|
| 228 |
+
_check_no_input(message)
|
| 229 |
+
response = input(message)
|
| 230 |
+
response = response.strip().lower()
|
| 231 |
+
if response not in options:
|
| 232 |
+
print(
|
| 233 |
+
"Your response ({!r}) was not one of the expected responses: "
|
| 234 |
+
"{}".format(response, ", ".join(options))
|
| 235 |
+
)
|
| 236 |
+
else:
|
| 237 |
+
return response
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
def ask_input(message: str) -> str:
|
| 241 |
+
"""Ask for input interactively."""
|
| 242 |
+
_check_no_input(message)
|
| 243 |
+
return input(message)
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
def ask_password(message: str) -> str:
|
| 247 |
+
"""Ask for a password interactively."""
|
| 248 |
+
_check_no_input(message)
|
| 249 |
+
return getpass.getpass(message)
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
def strtobool(val: str) -> int:
|
| 253 |
+
"""Convert a string representation of truth to true (1) or false (0).
|
| 254 |
+
|
| 255 |
+
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
|
| 256 |
+
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
|
| 257 |
+
'val' is anything else.
|
| 258 |
+
"""
|
| 259 |
+
val = val.lower()
|
| 260 |
+
if val in ("y", "yes", "t", "true", "on", "1"):
|
| 261 |
+
return 1
|
| 262 |
+
elif val in ("n", "no", "f", "false", "off", "0"):
|
| 263 |
+
return 0
|
| 264 |
+
else:
|
| 265 |
+
raise ValueError(f"invalid truth value {val!r}")
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
def format_size(bytes: float) -> str:
|
| 269 |
+
if bytes > 1000 * 1000:
|
| 270 |
+
return f"{bytes / 1000.0 / 1000:.1f} MB"
|
| 271 |
+
elif bytes > 10 * 1000:
|
| 272 |
+
return f"{int(bytes / 1000)} kB"
|
| 273 |
+
elif bytes > 1000:
|
| 274 |
+
return f"{bytes / 1000.0:.1f} kB"
|
| 275 |
+
else:
|
| 276 |
+
return f"{int(bytes)} bytes"
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def tabulate(rows: Iterable[Iterable[Any]]) -> Tuple[List[str], List[int]]:
|
| 280 |
+
"""Return a list of formatted rows and a list of column sizes.
|
| 281 |
+
|
| 282 |
+
For example::
|
| 283 |
+
|
| 284 |
+
>>> tabulate([['foobar', 2000], [0xdeadbeef]])
|
| 285 |
+
(['foobar 2000', '3735928559'], [10, 4])
|
| 286 |
+
"""
|
| 287 |
+
rows = [tuple(map(str, row)) for row in rows]
|
| 288 |
+
sizes = [max(map(len, col)) for col in zip_longest(*rows, fillvalue="")]
|
| 289 |
+
table = [" ".join(map(str.ljust, row, sizes)).rstrip() for row in rows]
|
| 290 |
+
return table, sizes
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
def is_installable_dir(path: str) -> bool:
|
| 294 |
+
"""Is path is a directory containing pyproject.toml or setup.py?
|
| 295 |
+
|
| 296 |
+
If pyproject.toml exists, this is a PEP 517 project. Otherwise we look for
|
| 297 |
+
a legacy setuptools layout by identifying setup.py. We don't check for the
|
| 298 |
+
setup.cfg because using it without setup.py is only available for PEP 517
|
| 299 |
+
projects, which are already covered by the pyproject.toml check.
|
| 300 |
+
"""
|
| 301 |
+
if not os.path.isdir(path):
|
| 302 |
+
return False
|
| 303 |
+
if os.path.isfile(os.path.join(path, "pyproject.toml")):
|
| 304 |
+
return True
|
| 305 |
+
if os.path.isfile(os.path.join(path, "setup.py")):
|
| 306 |
+
return True
|
| 307 |
+
return False
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
def read_chunks(
|
| 311 |
+
file: BinaryIO, size: int = FILE_CHUNK_SIZE
|
| 312 |
+
) -> Generator[bytes, None, None]:
|
| 313 |
+
"""Yield pieces of data from a file-like object until EOF."""
|
| 314 |
+
while True:
|
| 315 |
+
chunk = file.read(size)
|
| 316 |
+
if not chunk:
|
| 317 |
+
break
|
| 318 |
+
yield chunk
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
def normalize_path(path: str, resolve_symlinks: bool = True) -> str:
|
| 322 |
+
"""
|
| 323 |
+
Convert a path to its canonical, case-normalized, absolute version.
|
| 324 |
+
|
| 325 |
+
"""
|
| 326 |
+
path = os.path.expanduser(path)
|
| 327 |
+
if resolve_symlinks:
|
| 328 |
+
path = os.path.realpath(path)
|
| 329 |
+
else:
|
| 330 |
+
path = os.path.abspath(path)
|
| 331 |
+
return os.path.normcase(path)
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
def splitext(path: str) -> Tuple[str, str]:
|
| 335 |
+
"""Like os.path.splitext, but take off .tar too"""
|
| 336 |
+
base, ext = posixpath.splitext(path)
|
| 337 |
+
if base.lower().endswith(".tar"):
|
| 338 |
+
ext = base[-4:] + ext
|
| 339 |
+
base = base[:-4]
|
| 340 |
+
return base, ext
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
def renames(old: str, new: str) -> None:
|
| 344 |
+
"""Like os.renames(), but handles renaming across devices."""
|
| 345 |
+
# Implementation borrowed from os.renames().
|
| 346 |
+
head, tail = os.path.split(new)
|
| 347 |
+
if head and tail and not os.path.exists(head):
|
| 348 |
+
os.makedirs(head)
|
| 349 |
+
|
| 350 |
+
shutil.move(old, new)
|
| 351 |
+
|
| 352 |
+
head, tail = os.path.split(old)
|
| 353 |
+
if head and tail:
|
| 354 |
+
try:
|
| 355 |
+
os.removedirs(head)
|
| 356 |
+
except OSError:
|
| 357 |
+
pass
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
def is_local(path: str) -> bool:
|
| 361 |
+
"""
|
| 362 |
+
Return True if path is within sys.prefix, if we're running in a virtualenv.
|
| 363 |
+
|
| 364 |
+
If we're not in a virtualenv, all paths are considered "local."
|
| 365 |
+
|
| 366 |
+
Caution: this function assumes the head of path has been normalized
|
| 367 |
+
with normalize_path.
|
| 368 |
+
"""
|
| 369 |
+
if not running_under_virtualenv():
|
| 370 |
+
return True
|
| 371 |
+
return path.startswith(normalize_path(sys.prefix))
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
def write_output(msg: Any, *args: Any) -> None:
|
| 375 |
+
logger.info(msg, *args)
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
class StreamWrapper(StringIO):
|
| 379 |
+
orig_stream: TextIO
|
| 380 |
+
|
| 381 |
+
@classmethod
|
| 382 |
+
def from_stream(cls, orig_stream: TextIO) -> "StreamWrapper":
|
| 383 |
+
ret = cls()
|
| 384 |
+
ret.orig_stream = orig_stream
|
| 385 |
+
return ret
|
| 386 |
+
|
| 387 |
+
# compileall.compile_dir() needs stdout.encoding to print to stdout
|
| 388 |
+
# type ignore is because TextIOBase.encoding is writeable
|
| 389 |
+
@property
|
| 390 |
+
def encoding(self) -> str: # type: ignore
|
| 391 |
+
return self.orig_stream.encoding
|
| 392 |
+
|
| 393 |
+
|
| 394 |
+
# Simulates an enum
|
| 395 |
+
def enum(*sequential: Any, **named: Any) -> Type[Any]:
|
| 396 |
+
enums = dict(zip(sequential, range(len(sequential))), **named)
|
| 397 |
+
reverse = {value: key for key, value in enums.items()}
|
| 398 |
+
enums["reverse_mapping"] = reverse
|
| 399 |
+
return type("Enum", (), enums)
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
def build_netloc(host: str, port: Optional[int]) -> str:
|
| 403 |
+
"""
|
| 404 |
+
Build a netloc from a host-port pair
|
| 405 |
+
"""
|
| 406 |
+
if port is None:
|
| 407 |
+
return host
|
| 408 |
+
if ":" in host:
|
| 409 |
+
# Only wrap host with square brackets when it is IPv6
|
| 410 |
+
host = f"[{host}]"
|
| 411 |
+
return f"{host}:{port}"
|
| 412 |
+
|
| 413 |
+
|
| 414 |
+
def build_url_from_netloc(netloc: str, scheme: str = "https") -> str:
|
| 415 |
+
"""
|
| 416 |
+
Build a full URL from a netloc.
|
| 417 |
+
"""
|
| 418 |
+
if netloc.count(":") >= 2 and "@" not in netloc and "[" not in netloc:
|
| 419 |
+
# It must be a bare IPv6 address, so wrap it with brackets.
|
| 420 |
+
netloc = f"[{netloc}]"
|
| 421 |
+
return f"{scheme}://{netloc}"
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
def parse_netloc(netloc: str) -> Tuple[Optional[str], Optional[int]]:
|
| 425 |
+
"""
|
| 426 |
+
Return the host-port pair from a netloc.
|
| 427 |
+
"""
|
| 428 |
+
url = build_url_from_netloc(netloc)
|
| 429 |
+
parsed = urllib.parse.urlparse(url)
|
| 430 |
+
return parsed.hostname, parsed.port
|
| 431 |
+
|
| 432 |
+
|
| 433 |
+
def split_auth_from_netloc(netloc: str) -> NetlocTuple:
|
| 434 |
+
"""
|
| 435 |
+
Parse out and remove the auth information from a netloc.
|
| 436 |
+
|
| 437 |
+
Returns: (netloc, (username, password)).
|
| 438 |
+
"""
|
| 439 |
+
if "@" not in netloc:
|
| 440 |
+
return netloc, (None, None)
|
| 441 |
+
|
| 442 |
+
# Split from the right because that's how urllib.parse.urlsplit()
|
| 443 |
+
# behaves if more than one @ is present (which can be checked using
|
| 444 |
+
# the password attribute of urlsplit()'s return value).
|
| 445 |
+
auth, netloc = netloc.rsplit("@", 1)
|
| 446 |
+
pw: Optional[str] = None
|
| 447 |
+
if ":" in auth:
|
| 448 |
+
# Split from the left because that's how urllib.parse.urlsplit()
|
| 449 |
+
# behaves if more than one : is present (which again can be checked
|
| 450 |
+
# using the password attribute of the return value)
|
| 451 |
+
user, pw = auth.split(":", 1)
|
| 452 |
+
else:
|
| 453 |
+
user, pw = auth, None
|
| 454 |
+
|
| 455 |
+
user = urllib.parse.unquote(user)
|
| 456 |
+
if pw is not None:
|
| 457 |
+
pw = urllib.parse.unquote(pw)
|
| 458 |
+
|
| 459 |
+
return netloc, (user, pw)
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
def redact_netloc(netloc: str) -> str:
|
| 463 |
+
"""
|
| 464 |
+
Replace the sensitive data in a netloc with "****", if it exists.
|
| 465 |
+
|
| 466 |
+
For example:
|
| 467 |
+
- "user:pass@example.com" returns "user:****@example.com"
|
| 468 |
+
- "accesstoken@example.com" returns "****@example.com"
|
| 469 |
+
"""
|
| 470 |
+
netloc, (user, password) = split_auth_from_netloc(netloc)
|
| 471 |
+
if user is None:
|
| 472 |
+
return netloc
|
| 473 |
+
if password is None:
|
| 474 |
+
user = "****"
|
| 475 |
+
password = ""
|
| 476 |
+
else:
|
| 477 |
+
user = urllib.parse.quote(user)
|
| 478 |
+
password = ":****"
|
| 479 |
+
return f"{user}{password}@{netloc}"
|
| 480 |
+
|
| 481 |
+
|
| 482 |
+
def _transform_url(
|
| 483 |
+
url: str, transform_netloc: Callable[[str], Tuple[Any, ...]]
|
| 484 |
+
) -> Tuple[str, NetlocTuple]:
|
| 485 |
+
"""Transform and replace netloc in a url.
|
| 486 |
+
|
| 487 |
+
transform_netloc is a function taking the netloc and returning a
|
| 488 |
+
tuple. The first element of this tuple is the new netloc. The
|
| 489 |
+
entire tuple is returned.
|
| 490 |
+
|
| 491 |
+
Returns a tuple containing the transformed url as item 0 and the
|
| 492 |
+
original tuple returned by transform_netloc as item 1.
|
| 493 |
+
"""
|
| 494 |
+
purl = urllib.parse.urlsplit(url)
|
| 495 |
+
netloc_tuple = transform_netloc(purl.netloc)
|
| 496 |
+
# stripped url
|
| 497 |
+
url_pieces = (purl.scheme, netloc_tuple[0], purl.path, purl.query, purl.fragment)
|
| 498 |
+
surl = urllib.parse.urlunsplit(url_pieces)
|
| 499 |
+
return surl, cast("NetlocTuple", netloc_tuple)
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
def _get_netloc(netloc: str) -> NetlocTuple:
|
| 503 |
+
return split_auth_from_netloc(netloc)
|
| 504 |
+
|
| 505 |
+
|
| 506 |
+
def _redact_netloc(netloc: str) -> Tuple[str]:
|
| 507 |
+
return (redact_netloc(netloc),)
|
| 508 |
+
|
| 509 |
+
|
| 510 |
+
def split_auth_netloc_from_url(
|
| 511 |
+
url: str,
|
| 512 |
+
) -> Tuple[str, str, Tuple[Optional[str], Optional[str]]]:
|
| 513 |
+
"""
|
| 514 |
+
Parse a url into separate netloc, auth, and url with no auth.
|
| 515 |
+
|
| 516 |
+
Returns: (url_without_auth, netloc, (username, password))
|
| 517 |
+
"""
|
| 518 |
+
url_without_auth, (netloc, auth) = _transform_url(url, _get_netloc)
|
| 519 |
+
return url_without_auth, netloc, auth
|
| 520 |
+
|
| 521 |
+
|
| 522 |
+
def remove_auth_from_url(url: str) -> str:
|
| 523 |
+
"""Return a copy of url with 'username:password@' removed."""
|
| 524 |
+
# username/pass params are passed to subversion through flags
|
| 525 |
+
# and are not recognized in the url.
|
| 526 |
+
return _transform_url(url, _get_netloc)[0]
|
| 527 |
+
|
| 528 |
+
|
| 529 |
+
def redact_auth_from_url(url: str) -> str:
|
| 530 |
+
"""Replace the password in a given url with ****."""
|
| 531 |
+
return _transform_url(url, _redact_netloc)[0]
|
| 532 |
+
|
| 533 |
+
|
| 534 |
+
def redact_auth_from_requirement(req: Requirement) -> str:
|
| 535 |
+
"""Replace the password in a given requirement url with ****."""
|
| 536 |
+
if not req.url:
|
| 537 |
+
return str(req)
|
| 538 |
+
return str(req).replace(req.url, redact_auth_from_url(req.url))
|
| 539 |
+
|
| 540 |
+
|
| 541 |
+
@dataclass(frozen=True)
|
| 542 |
+
class HiddenText:
|
| 543 |
+
secret: str
|
| 544 |
+
redacted: str
|
| 545 |
+
|
| 546 |
+
def __repr__(self) -> str:
|
| 547 |
+
return f"<HiddenText {str(self)!r}>"
|
| 548 |
+
|
| 549 |
+
def __str__(self) -> str:
|
| 550 |
+
return self.redacted
|
| 551 |
+
|
| 552 |
+
# This is useful for testing.
|
| 553 |
+
def __eq__(self, other: Any) -> bool:
|
| 554 |
+
if type(self) is not type(other):
|
| 555 |
+
return False
|
| 556 |
+
|
| 557 |
+
# The string being used for redaction doesn't also have to match,
|
| 558 |
+
# just the raw, original string.
|
| 559 |
+
return self.secret == other.secret
|
| 560 |
+
|
| 561 |
+
|
| 562 |
+
def hide_value(value: str) -> HiddenText:
|
| 563 |
+
return HiddenText(value, redacted="****")
|
| 564 |
+
|
| 565 |
+
|
| 566 |
+
def hide_url(url: str) -> HiddenText:
|
| 567 |
+
redacted = redact_auth_from_url(url)
|
| 568 |
+
return HiddenText(url, redacted=redacted)
|
| 569 |
+
|
| 570 |
+
|
| 571 |
+
def protect_pip_from_modification_on_windows(modifying_pip: bool) -> None:
|
| 572 |
+
"""Protection of pip.exe from modification on Windows
|
| 573 |
+
|
| 574 |
+
On Windows, any operation modifying pip should be run as:
|
| 575 |
+
python -m pip ...
|
| 576 |
+
"""
|
| 577 |
+
pip_names = [
|
| 578 |
+
"pip",
|
| 579 |
+
f"pip{sys.version_info.major}",
|
| 580 |
+
f"pip{sys.version_info.major}.{sys.version_info.minor}",
|
| 581 |
+
]
|
| 582 |
+
|
| 583 |
+
# See https://github.com/pypa/pip/issues/1299 for more discussion
|
| 584 |
+
should_show_use_python_msg = (
|
| 585 |
+
modifying_pip and WINDOWS and os.path.basename(sys.argv[0]) in pip_names
|
| 586 |
+
)
|
| 587 |
+
|
| 588 |
+
if should_show_use_python_msg:
|
| 589 |
+
new_command = [sys.executable, "-m", "pip"] + sys.argv[1:]
|
| 590 |
+
raise CommandError(
|
| 591 |
+
"To modify pip, please run the following command:\n{}".format(
|
| 592 |
+
" ".join(new_command)
|
| 593 |
+
)
|
| 594 |
+
)
|
| 595 |
+
|
| 596 |
+
|
| 597 |
+
def check_externally_managed() -> None:
|
| 598 |
+
"""Check whether the current environment is externally managed.
|
| 599 |
+
|
| 600 |
+
If the ``EXTERNALLY-MANAGED`` config file is found, the current environment
|
| 601 |
+
is considered externally managed, and an ExternallyManagedEnvironment is
|
| 602 |
+
raised.
|
| 603 |
+
"""
|
| 604 |
+
if running_under_virtualenv():
|
| 605 |
+
return
|
| 606 |
+
marker = os.path.join(sysconfig.get_path("stdlib"), "EXTERNALLY-MANAGED")
|
| 607 |
+
if not os.path.isfile(marker):
|
| 608 |
+
return
|
| 609 |
+
raise ExternallyManagedEnvironment.from_config(marker)
|
| 610 |
+
|
| 611 |
+
|
| 612 |
+
def is_console_interactive() -> bool:
|
| 613 |
+
"""Is this console interactive?"""
|
| 614 |
+
return sys.stdin is not None and sys.stdin.isatty()
|
| 615 |
+
|
| 616 |
+
|
| 617 |
+
def hash_file(path: str, blocksize: int = 1 << 20) -> Tuple[Any, int]:
|
| 618 |
+
"""Return (hash, length) for path using hashlib.sha256()"""
|
| 619 |
+
|
| 620 |
+
h = hashlib.sha256()
|
| 621 |
+
length = 0
|
| 622 |
+
with open(path, "rb") as f:
|
| 623 |
+
for block in read_chunks(f, size=blocksize):
|
| 624 |
+
length += len(block)
|
| 625 |
+
h.update(block)
|
| 626 |
+
return h, length
|
| 627 |
+
|
| 628 |
+
|
| 629 |
+
def pairwise(iterable: Iterable[Any]) -> Iterator[Tuple[Any, Any]]:
|
| 630 |
+
"""
|
| 631 |
+
Return paired elements.
|
| 632 |
+
|
| 633 |
+
For example:
|
| 634 |
+
s -> (s0, s1), (s2, s3), (s4, s5), ...
|
| 635 |
+
"""
|
| 636 |
+
iterable = iter(iterable)
|
| 637 |
+
return zip_longest(iterable, iterable)
|
| 638 |
+
|
| 639 |
+
|
| 640 |
+
def partition(
|
| 641 |
+
pred: Callable[[T], bool], iterable: Iterable[T]
|
| 642 |
+
) -> Tuple[Iterable[T], Iterable[T]]:
|
| 643 |
+
"""
|
| 644 |
+
Use a predicate to partition entries into false entries and true entries,
|
| 645 |
+
like
|
| 646 |
+
|
| 647 |
+
partition(is_odd, range(10)) --> 0 2 4 6 8 and 1 3 5 7 9
|
| 648 |
+
"""
|
| 649 |
+
t1, t2 = tee(iterable)
|
| 650 |
+
return filterfalse(pred, t1), filter(pred, t2)
|
| 651 |
+
|
| 652 |
+
|
| 653 |
+
class ConfiguredBuildBackendHookCaller(BuildBackendHookCaller):
|
| 654 |
+
def __init__(
|
| 655 |
+
self,
|
| 656 |
+
config_holder: Any,
|
| 657 |
+
source_dir: str,
|
| 658 |
+
build_backend: str,
|
| 659 |
+
backend_path: Optional[str] = None,
|
| 660 |
+
runner: Optional[Callable[..., None]] = None,
|
| 661 |
+
python_executable: Optional[str] = None,
|
| 662 |
+
):
|
| 663 |
+
super().__init__(
|
| 664 |
+
source_dir, build_backend, backend_path, runner, python_executable
|
| 665 |
+
)
|
| 666 |
+
self.config_holder = config_holder
|
| 667 |
+
|
| 668 |
+
def build_wheel(
|
| 669 |
+
self,
|
| 670 |
+
wheel_directory: str,
|
| 671 |
+
config_settings: Optional[Mapping[str, Any]] = None,
|
| 672 |
+
metadata_directory: Optional[str] = None,
|
| 673 |
+
) -> str:
|
| 674 |
+
cs = self.config_holder.config_settings
|
| 675 |
+
return super().build_wheel(
|
| 676 |
+
wheel_directory, config_settings=cs, metadata_directory=metadata_directory
|
| 677 |
+
)
|
| 678 |
+
|
| 679 |
+
def build_sdist(
|
| 680 |
+
self,
|
| 681 |
+
sdist_directory: str,
|
| 682 |
+
config_settings: Optional[Mapping[str, Any]] = None,
|
| 683 |
+
) -> str:
|
| 684 |
+
cs = self.config_holder.config_settings
|
| 685 |
+
return super().build_sdist(sdist_directory, config_settings=cs)
|
| 686 |
+
|
| 687 |
+
def build_editable(
|
| 688 |
+
self,
|
| 689 |
+
wheel_directory: str,
|
| 690 |
+
config_settings: Optional[Mapping[str, Any]] = None,
|
| 691 |
+
metadata_directory: Optional[str] = None,
|
| 692 |
+
) -> str:
|
| 693 |
+
cs = self.config_holder.config_settings
|
| 694 |
+
return super().build_editable(
|
| 695 |
+
wheel_directory, config_settings=cs, metadata_directory=metadata_directory
|
| 696 |
+
)
|
| 697 |
+
|
| 698 |
+
def get_requires_for_build_wheel(
|
| 699 |
+
self, config_settings: Optional[Mapping[str, Any]] = None
|
| 700 |
+
) -> Sequence[str]:
|
| 701 |
+
cs = self.config_holder.config_settings
|
| 702 |
+
return super().get_requires_for_build_wheel(config_settings=cs)
|
| 703 |
+
|
| 704 |
+
def get_requires_for_build_sdist(
|
| 705 |
+
self, config_settings: Optional[Mapping[str, Any]] = None
|
| 706 |
+
) -> Sequence[str]:
|
| 707 |
+
cs = self.config_holder.config_settings
|
| 708 |
+
return super().get_requires_for_build_sdist(config_settings=cs)
|
| 709 |
+
|
| 710 |
+
def get_requires_for_build_editable(
|
| 711 |
+
self, config_settings: Optional[Mapping[str, Any]] = None
|
| 712 |
+
) -> Sequence[str]:
|
| 713 |
+
cs = self.config_holder.config_settings
|
| 714 |
+
return super().get_requires_for_build_editable(config_settings=cs)
|
| 715 |
+
|
| 716 |
+
def prepare_metadata_for_build_wheel(
|
| 717 |
+
self,
|
| 718 |
+
metadata_directory: str,
|
| 719 |
+
config_settings: Optional[Mapping[str, Any]] = None,
|
| 720 |
+
_allow_fallback: bool = True,
|
| 721 |
+
) -> str:
|
| 722 |
+
cs = self.config_holder.config_settings
|
| 723 |
+
return super().prepare_metadata_for_build_wheel(
|
| 724 |
+
metadata_directory=metadata_directory,
|
| 725 |
+
config_settings=cs,
|
| 726 |
+
_allow_fallback=_allow_fallback,
|
| 727 |
+
)
|
| 728 |
+
|
| 729 |
+
def prepare_metadata_for_build_editable(
|
| 730 |
+
self,
|
| 731 |
+
metadata_directory: str,
|
| 732 |
+
config_settings: Optional[Mapping[str, Any]] = None,
|
| 733 |
+
_allow_fallback: bool = True,
|
| 734 |
+
) -> Optional[str]:
|
| 735 |
+
cs = self.config_holder.config_settings
|
| 736 |
+
return super().prepare_metadata_for_build_editable(
|
| 737 |
+
metadata_directory=metadata_directory,
|
| 738 |
+
config_settings=cs,
|
| 739 |
+
_allow_fallback=_allow_fallback,
|
| 740 |
+
)
|
| 741 |
+
|
| 742 |
+
|
| 743 |
+
def warn_if_run_as_root() -> None:
|
| 744 |
+
"""Output a warning for sudo users on Unix.
|
| 745 |
+
|
| 746 |
+
In a virtual environment, sudo pip still writes to virtualenv.
|
| 747 |
+
On Windows, users may run pip as Administrator without issues.
|
| 748 |
+
This warning only applies to Unix root users outside of virtualenv.
|
| 749 |
+
"""
|
| 750 |
+
if running_under_virtualenv():
|
| 751 |
+
return
|
| 752 |
+
if not hasattr(os, "getuid"):
|
| 753 |
+
return
|
| 754 |
+
# On Windows, there are no "system managed" Python packages. Installing as
|
| 755 |
+
# Administrator via pip is the correct way of updating system environments.
|
| 756 |
+
#
|
| 757 |
+
# We choose sys.platform over utils.compat.WINDOWS here to enable Mypy platform
|
| 758 |
+
# checks: https://mypy.readthedocs.io/en/stable/common_issues.html
|
| 759 |
+
if sys.platform == "win32" or sys.platform == "cygwin":
|
| 760 |
+
return
|
| 761 |
+
|
| 762 |
+
if os.getuid() != 0:
|
| 763 |
+
return
|
| 764 |
+
|
| 765 |
+
logger.warning(
|
| 766 |
+
"Running pip as the 'root' user can result in broken permissions and "
|
| 767 |
+
"conflicting behaviour with the system package manager, possibly "
|
| 768 |
+
"rendering your system unusable. "
|
| 769 |
+
"It is recommended to use a virtual environment instead: "
|
| 770 |
+
"https://pip.pypa.io/warnings/venv. "
|
| 771 |
+
"Use the --root-user-action option if you know what you are doing and "
|
| 772 |
+
"want to suppress this warning."
|
| 773 |
+
)
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/retry.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import functools
|
| 2 |
+
from time import perf_counter, sleep
|
| 3 |
+
from typing import Callable, TypeVar
|
| 4 |
+
|
| 5 |
+
from pip._vendor.typing_extensions import ParamSpec
|
| 6 |
+
|
| 7 |
+
T = TypeVar("T")
|
| 8 |
+
P = ParamSpec("P")
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def retry(
|
| 12 |
+
wait: float, stop_after_delay: float
|
| 13 |
+
) -> Callable[[Callable[P, T]], Callable[P, T]]:
|
| 14 |
+
"""Decorator to automatically retry a function on error.
|
| 15 |
+
|
| 16 |
+
If the function raises, the function is recalled with the same arguments
|
| 17 |
+
until it returns or the time limit is reached. When the time limit is
|
| 18 |
+
surpassed, the last exception raised is reraised.
|
| 19 |
+
|
| 20 |
+
:param wait: The time to wait after an error before retrying, in seconds.
|
| 21 |
+
:param stop_after_delay: The time limit after which retries will cease,
|
| 22 |
+
in seconds.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
def wrapper(func: Callable[P, T]) -> Callable[P, T]:
|
| 26 |
+
|
| 27 |
+
@functools.wraps(func)
|
| 28 |
+
def retry_wrapped(*args: P.args, **kwargs: P.kwargs) -> T:
|
| 29 |
+
# The performance counter is monotonic on all platforms we care
|
| 30 |
+
# about and has much better resolution than time.monotonic().
|
| 31 |
+
start_time = perf_counter()
|
| 32 |
+
while True:
|
| 33 |
+
try:
|
| 34 |
+
return func(*args, **kwargs)
|
| 35 |
+
except Exception:
|
| 36 |
+
if perf_counter() - start_time > stop_after_delay:
|
| 37 |
+
raise
|
| 38 |
+
sleep(wait)
|
| 39 |
+
|
| 40 |
+
return retry_wrapped
|
| 41 |
+
|
| 42 |
+
return wrapper
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/setuptools_build.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
import textwrap
|
| 3 |
+
from typing import List, Optional, Sequence
|
| 4 |
+
|
| 5 |
+
# Shim to wrap setup.py invocation with setuptools
|
| 6 |
+
# Note that __file__ is handled via two {!r} *and* %r, to ensure that paths on
|
| 7 |
+
# Windows are correctly handled (it should be "C:\\Users" not "C:\Users").
|
| 8 |
+
_SETUPTOOLS_SHIM = textwrap.dedent(
|
| 9 |
+
"""
|
| 10 |
+
exec(compile('''
|
| 11 |
+
# This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
|
| 12 |
+
#
|
| 13 |
+
# - It imports setuptools before invoking setup.py, to enable projects that directly
|
| 14 |
+
# import from `distutils.core` to work with newer packaging standards.
|
| 15 |
+
# - It provides a clear error message when setuptools is not installed.
|
| 16 |
+
# - It sets `sys.argv[0]` to the underlying `setup.py`, when invoking `setup.py` so
|
| 17 |
+
# setuptools doesn't think the script is `-c`. This avoids the following warning:
|
| 18 |
+
# manifest_maker: standard file '-c' not found".
|
| 19 |
+
# - It generates a shim setup.py, for handling setup.cfg-only projects.
|
| 20 |
+
import os, sys, tokenize
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
import setuptools
|
| 24 |
+
except ImportError as error:
|
| 25 |
+
print(
|
| 26 |
+
"ERROR: Can not execute `setup.py` since setuptools is not available in "
|
| 27 |
+
"the build environment.",
|
| 28 |
+
file=sys.stderr,
|
| 29 |
+
)
|
| 30 |
+
sys.exit(1)
|
| 31 |
+
|
| 32 |
+
__file__ = %r
|
| 33 |
+
sys.argv[0] = __file__
|
| 34 |
+
|
| 35 |
+
if os.path.exists(__file__):
|
| 36 |
+
filename = __file__
|
| 37 |
+
with tokenize.open(__file__) as f:
|
| 38 |
+
setup_py_code = f.read()
|
| 39 |
+
else:
|
| 40 |
+
filename = "<auto-generated setuptools caller>"
|
| 41 |
+
setup_py_code = "from setuptools import setup; setup()"
|
| 42 |
+
|
| 43 |
+
exec(compile(setup_py_code, filename, "exec"))
|
| 44 |
+
''' % ({!r},), "<pip-setuptools-caller>", "exec"))
|
| 45 |
+
"""
|
| 46 |
+
).rstrip()
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def make_setuptools_shim_args(
|
| 50 |
+
setup_py_path: str,
|
| 51 |
+
global_options: Optional[Sequence[str]] = None,
|
| 52 |
+
no_user_config: bool = False,
|
| 53 |
+
unbuffered_output: bool = False,
|
| 54 |
+
) -> List[str]:
|
| 55 |
+
"""
|
| 56 |
+
Get setuptools command arguments with shim wrapped setup file invocation.
|
| 57 |
+
|
| 58 |
+
:param setup_py_path: The path to setup.py to be wrapped.
|
| 59 |
+
:param global_options: Additional global options.
|
| 60 |
+
:param no_user_config: If True, disables personal user configuration.
|
| 61 |
+
:param unbuffered_output: If True, adds the unbuffered switch to the
|
| 62 |
+
argument list.
|
| 63 |
+
"""
|
| 64 |
+
args = [sys.executable]
|
| 65 |
+
if unbuffered_output:
|
| 66 |
+
args += ["-u"]
|
| 67 |
+
args += ["-c", _SETUPTOOLS_SHIM.format(setup_py_path)]
|
| 68 |
+
if global_options:
|
| 69 |
+
args += global_options
|
| 70 |
+
if no_user_config:
|
| 71 |
+
args += ["--no-user-cfg"]
|
| 72 |
+
return args
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def make_setuptools_bdist_wheel_args(
|
| 76 |
+
setup_py_path: str,
|
| 77 |
+
global_options: Sequence[str],
|
| 78 |
+
build_options: Sequence[str],
|
| 79 |
+
destination_dir: str,
|
| 80 |
+
) -> List[str]:
|
| 81 |
+
# NOTE: Eventually, we'd want to also -S to the flags here, when we're
|
| 82 |
+
# isolating. Currently, it breaks Python in virtualenvs, because it
|
| 83 |
+
# relies on site.py to find parts of the standard library outside the
|
| 84 |
+
# virtualenv.
|
| 85 |
+
args = make_setuptools_shim_args(
|
| 86 |
+
setup_py_path, global_options=global_options, unbuffered_output=True
|
| 87 |
+
)
|
| 88 |
+
args += ["bdist_wheel", "-d", destination_dir]
|
| 89 |
+
args += build_options
|
| 90 |
+
return args
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def make_setuptools_clean_args(
|
| 94 |
+
setup_py_path: str,
|
| 95 |
+
global_options: Sequence[str],
|
| 96 |
+
) -> List[str]:
|
| 97 |
+
args = make_setuptools_shim_args(
|
| 98 |
+
setup_py_path, global_options=global_options, unbuffered_output=True
|
| 99 |
+
)
|
| 100 |
+
args += ["clean", "--all"]
|
| 101 |
+
return args
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def make_setuptools_develop_args(
|
| 105 |
+
setup_py_path: str,
|
| 106 |
+
*,
|
| 107 |
+
global_options: Sequence[str],
|
| 108 |
+
no_user_config: bool,
|
| 109 |
+
prefix: Optional[str],
|
| 110 |
+
home: Optional[str],
|
| 111 |
+
use_user_site: bool,
|
| 112 |
+
) -> List[str]:
|
| 113 |
+
assert not (use_user_site and prefix)
|
| 114 |
+
|
| 115 |
+
args = make_setuptools_shim_args(
|
| 116 |
+
setup_py_path,
|
| 117 |
+
global_options=global_options,
|
| 118 |
+
no_user_config=no_user_config,
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
args += ["develop", "--no-deps"]
|
| 122 |
+
|
| 123 |
+
if prefix:
|
| 124 |
+
args += ["--prefix", prefix]
|
| 125 |
+
if home is not None:
|
| 126 |
+
args += ["--install-dir", home]
|
| 127 |
+
|
| 128 |
+
if use_user_site:
|
| 129 |
+
args += ["--user", "--prefix="]
|
| 130 |
+
|
| 131 |
+
return args
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
def make_setuptools_egg_info_args(
|
| 135 |
+
setup_py_path: str,
|
| 136 |
+
egg_info_dir: Optional[str],
|
| 137 |
+
no_user_config: bool,
|
| 138 |
+
) -> List[str]:
|
| 139 |
+
args = make_setuptools_shim_args(setup_py_path, no_user_config=no_user_config)
|
| 140 |
+
|
| 141 |
+
args += ["egg_info"]
|
| 142 |
+
|
| 143 |
+
if egg_info_dir:
|
| 144 |
+
args += ["--egg-base", egg_info_dir]
|
| 145 |
+
|
| 146 |
+
return args
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/subprocess.py
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import os
|
| 3 |
+
import shlex
|
| 4 |
+
import subprocess
|
| 5 |
+
from typing import Any, Callable, Iterable, List, Literal, Mapping, Optional, Union
|
| 6 |
+
|
| 7 |
+
from pip._vendor.rich.markup import escape
|
| 8 |
+
|
| 9 |
+
from pip._internal.cli.spinners import SpinnerInterface, open_spinner
|
| 10 |
+
from pip._internal.exceptions import InstallationSubprocessError
|
| 11 |
+
from pip._internal.utils.logging import VERBOSE, subprocess_logger
|
| 12 |
+
from pip._internal.utils.misc import HiddenText
|
| 13 |
+
|
| 14 |
+
CommandArgs = List[Union[str, HiddenText]]
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def make_command(*args: Union[str, HiddenText, CommandArgs]) -> CommandArgs:
|
| 18 |
+
"""
|
| 19 |
+
Create a CommandArgs object.
|
| 20 |
+
"""
|
| 21 |
+
command_args: CommandArgs = []
|
| 22 |
+
for arg in args:
|
| 23 |
+
# Check for list instead of CommandArgs since CommandArgs is
|
| 24 |
+
# only known during type-checking.
|
| 25 |
+
if isinstance(arg, list):
|
| 26 |
+
command_args.extend(arg)
|
| 27 |
+
else:
|
| 28 |
+
# Otherwise, arg is str or HiddenText.
|
| 29 |
+
command_args.append(arg)
|
| 30 |
+
|
| 31 |
+
return command_args
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def format_command_args(args: Union[List[str], CommandArgs]) -> str:
|
| 35 |
+
"""
|
| 36 |
+
Format command arguments for display.
|
| 37 |
+
"""
|
| 38 |
+
# For HiddenText arguments, display the redacted form by calling str().
|
| 39 |
+
# Also, we don't apply str() to arguments that aren't HiddenText since
|
| 40 |
+
# this can trigger a UnicodeDecodeError in Python 2 if the argument
|
| 41 |
+
# has type unicode and includes a non-ascii character. (The type
|
| 42 |
+
# checker doesn't ensure the annotations are correct in all cases.)
|
| 43 |
+
return " ".join(
|
| 44 |
+
shlex.quote(str(arg)) if isinstance(arg, HiddenText) else shlex.quote(arg)
|
| 45 |
+
for arg in args
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def reveal_command_args(args: Union[List[str], CommandArgs]) -> List[str]:
|
| 50 |
+
"""
|
| 51 |
+
Return the arguments in their raw, unredacted form.
|
| 52 |
+
"""
|
| 53 |
+
return [arg.secret if isinstance(arg, HiddenText) else arg for arg in args]
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def call_subprocess(
|
| 57 |
+
cmd: Union[List[str], CommandArgs],
|
| 58 |
+
show_stdout: bool = False,
|
| 59 |
+
cwd: Optional[str] = None,
|
| 60 |
+
on_returncode: 'Literal["raise", "warn", "ignore"]' = "raise",
|
| 61 |
+
extra_ok_returncodes: Optional[Iterable[int]] = None,
|
| 62 |
+
extra_environ: Optional[Mapping[str, Any]] = None,
|
| 63 |
+
unset_environ: Optional[Iterable[str]] = None,
|
| 64 |
+
spinner: Optional[SpinnerInterface] = None,
|
| 65 |
+
log_failed_cmd: Optional[bool] = True,
|
| 66 |
+
stdout_only: Optional[bool] = False,
|
| 67 |
+
*,
|
| 68 |
+
command_desc: str,
|
| 69 |
+
) -> str:
|
| 70 |
+
"""
|
| 71 |
+
Args:
|
| 72 |
+
show_stdout: if true, use INFO to log the subprocess's stderr and
|
| 73 |
+
stdout streams. Otherwise, use DEBUG. Defaults to False.
|
| 74 |
+
extra_ok_returncodes: an iterable of integer return codes that are
|
| 75 |
+
acceptable, in addition to 0. Defaults to None, which means [].
|
| 76 |
+
unset_environ: an iterable of environment variable names to unset
|
| 77 |
+
prior to calling subprocess.Popen().
|
| 78 |
+
log_failed_cmd: if false, failed commands are not logged, only raised.
|
| 79 |
+
stdout_only: if true, return only stdout, else return both. When true,
|
| 80 |
+
logging of both stdout and stderr occurs when the subprocess has
|
| 81 |
+
terminated, else logging occurs as subprocess output is produced.
|
| 82 |
+
"""
|
| 83 |
+
if extra_ok_returncodes is None:
|
| 84 |
+
extra_ok_returncodes = []
|
| 85 |
+
if unset_environ is None:
|
| 86 |
+
unset_environ = []
|
| 87 |
+
# Most places in pip use show_stdout=False. What this means is--
|
| 88 |
+
#
|
| 89 |
+
# - We connect the child's output (combined stderr and stdout) to a
|
| 90 |
+
# single pipe, which we read.
|
| 91 |
+
# - We log this output to stderr at DEBUG level as it is received.
|
| 92 |
+
# - If DEBUG logging isn't enabled (e.g. if --verbose logging wasn't
|
| 93 |
+
# requested), then we show a spinner so the user can still see the
|
| 94 |
+
# subprocess is in progress.
|
| 95 |
+
# - If the subprocess exits with an error, we log the output to stderr
|
| 96 |
+
# at ERROR level if it hasn't already been displayed to the console
|
| 97 |
+
# (e.g. if --verbose logging wasn't enabled). This way we don't log
|
| 98 |
+
# the output to the console twice.
|
| 99 |
+
#
|
| 100 |
+
# If show_stdout=True, then the above is still done, but with DEBUG
|
| 101 |
+
# replaced by INFO.
|
| 102 |
+
if show_stdout:
|
| 103 |
+
# Then log the subprocess output at INFO level.
|
| 104 |
+
log_subprocess: Callable[..., None] = subprocess_logger.info
|
| 105 |
+
used_level = logging.INFO
|
| 106 |
+
else:
|
| 107 |
+
# Then log the subprocess output using VERBOSE. This also ensures
|
| 108 |
+
# it will be logged to the log file (aka user_log), if enabled.
|
| 109 |
+
log_subprocess = subprocess_logger.verbose
|
| 110 |
+
used_level = VERBOSE
|
| 111 |
+
|
| 112 |
+
# Whether the subprocess will be visible in the console.
|
| 113 |
+
showing_subprocess = subprocess_logger.getEffectiveLevel() <= used_level
|
| 114 |
+
|
| 115 |
+
# Only use the spinner if we're not showing the subprocess output
|
| 116 |
+
# and we have a spinner.
|
| 117 |
+
use_spinner = not showing_subprocess and spinner is not None
|
| 118 |
+
|
| 119 |
+
log_subprocess("Running command %s", command_desc)
|
| 120 |
+
env = os.environ.copy()
|
| 121 |
+
if extra_environ:
|
| 122 |
+
env.update(extra_environ)
|
| 123 |
+
for name in unset_environ:
|
| 124 |
+
env.pop(name, None)
|
| 125 |
+
try:
|
| 126 |
+
proc = subprocess.Popen(
|
| 127 |
+
# Convert HiddenText objects to the underlying str.
|
| 128 |
+
reveal_command_args(cmd),
|
| 129 |
+
stdin=subprocess.PIPE,
|
| 130 |
+
stdout=subprocess.PIPE,
|
| 131 |
+
stderr=subprocess.STDOUT if not stdout_only else subprocess.PIPE,
|
| 132 |
+
cwd=cwd,
|
| 133 |
+
env=env,
|
| 134 |
+
errors="backslashreplace",
|
| 135 |
+
)
|
| 136 |
+
except Exception as exc:
|
| 137 |
+
if log_failed_cmd:
|
| 138 |
+
subprocess_logger.critical(
|
| 139 |
+
"Error %s while executing command %s",
|
| 140 |
+
exc,
|
| 141 |
+
command_desc,
|
| 142 |
+
)
|
| 143 |
+
raise
|
| 144 |
+
all_output = []
|
| 145 |
+
if not stdout_only:
|
| 146 |
+
assert proc.stdout
|
| 147 |
+
assert proc.stdin
|
| 148 |
+
proc.stdin.close()
|
| 149 |
+
# In this mode, stdout and stderr are in the same pipe.
|
| 150 |
+
while True:
|
| 151 |
+
line: str = proc.stdout.readline()
|
| 152 |
+
if not line:
|
| 153 |
+
break
|
| 154 |
+
line = line.rstrip()
|
| 155 |
+
all_output.append(line + "\n")
|
| 156 |
+
|
| 157 |
+
# Show the line immediately.
|
| 158 |
+
log_subprocess(line)
|
| 159 |
+
# Update the spinner.
|
| 160 |
+
if use_spinner:
|
| 161 |
+
assert spinner
|
| 162 |
+
spinner.spin()
|
| 163 |
+
try:
|
| 164 |
+
proc.wait()
|
| 165 |
+
finally:
|
| 166 |
+
if proc.stdout:
|
| 167 |
+
proc.stdout.close()
|
| 168 |
+
output = "".join(all_output)
|
| 169 |
+
else:
|
| 170 |
+
# In this mode, stdout and stderr are in different pipes.
|
| 171 |
+
# We must use communicate() which is the only safe way to read both.
|
| 172 |
+
out, err = proc.communicate()
|
| 173 |
+
# log line by line to preserve pip log indenting
|
| 174 |
+
for out_line in out.splitlines():
|
| 175 |
+
log_subprocess(out_line)
|
| 176 |
+
all_output.append(out)
|
| 177 |
+
for err_line in err.splitlines():
|
| 178 |
+
log_subprocess(err_line)
|
| 179 |
+
all_output.append(err)
|
| 180 |
+
output = out
|
| 181 |
+
|
| 182 |
+
proc_had_error = proc.returncode and proc.returncode not in extra_ok_returncodes
|
| 183 |
+
if use_spinner:
|
| 184 |
+
assert spinner
|
| 185 |
+
if proc_had_error:
|
| 186 |
+
spinner.finish("error")
|
| 187 |
+
else:
|
| 188 |
+
spinner.finish("done")
|
| 189 |
+
if proc_had_error:
|
| 190 |
+
if on_returncode == "raise":
|
| 191 |
+
error = InstallationSubprocessError(
|
| 192 |
+
command_description=command_desc,
|
| 193 |
+
exit_code=proc.returncode,
|
| 194 |
+
output_lines=all_output if not showing_subprocess else None,
|
| 195 |
+
)
|
| 196 |
+
if log_failed_cmd:
|
| 197 |
+
subprocess_logger.error("%s", error, extra={"rich": True})
|
| 198 |
+
subprocess_logger.verbose(
|
| 199 |
+
"[bold magenta]full command[/]: [blue]%s[/]",
|
| 200 |
+
escape(format_command_args(cmd)),
|
| 201 |
+
extra={"markup": True},
|
| 202 |
+
)
|
| 203 |
+
subprocess_logger.verbose(
|
| 204 |
+
"[bold magenta]cwd[/]: %s",
|
| 205 |
+
escape(cwd or "[inherit]"),
|
| 206 |
+
extra={"markup": True},
|
| 207 |
+
)
|
| 208 |
+
|
| 209 |
+
raise error
|
| 210 |
+
elif on_returncode == "warn":
|
| 211 |
+
subprocess_logger.warning(
|
| 212 |
+
'Command "%s" had error code %s in %s',
|
| 213 |
+
command_desc,
|
| 214 |
+
proc.returncode,
|
| 215 |
+
cwd,
|
| 216 |
+
)
|
| 217 |
+
elif on_returncode == "ignore":
|
| 218 |
+
pass
|
| 219 |
+
else:
|
| 220 |
+
raise ValueError(f"Invalid value: on_returncode={on_returncode!r}")
|
| 221 |
+
return output
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def runner_with_spinner_message(message: str) -> Callable[..., None]:
|
| 225 |
+
"""Provide a subprocess_runner that shows a spinner message.
|
| 226 |
+
|
| 227 |
+
Intended for use with for BuildBackendHookCaller. Thus, the runner has
|
| 228 |
+
an API that matches what's expected by BuildBackendHookCaller.subprocess_runner.
|
| 229 |
+
"""
|
| 230 |
+
|
| 231 |
+
def runner(
|
| 232 |
+
cmd: List[str],
|
| 233 |
+
cwd: Optional[str] = None,
|
| 234 |
+
extra_environ: Optional[Mapping[str, Any]] = None,
|
| 235 |
+
) -> None:
|
| 236 |
+
with open_spinner(message) as spinner:
|
| 237 |
+
call_subprocess(
|
| 238 |
+
cmd,
|
| 239 |
+
command_desc=message,
|
| 240 |
+
cwd=cwd,
|
| 241 |
+
extra_environ=extra_environ,
|
| 242 |
+
spinner=spinner,
|
| 243 |
+
)
|
| 244 |
+
|
| 245 |
+
return runner
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/temp_dir.py
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import errno
|
| 2 |
+
import itertools
|
| 3 |
+
import logging
|
| 4 |
+
import os.path
|
| 5 |
+
import tempfile
|
| 6 |
+
import traceback
|
| 7 |
+
from contextlib import ExitStack, contextmanager
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
from typing import (
|
| 10 |
+
Any,
|
| 11 |
+
Callable,
|
| 12 |
+
Dict,
|
| 13 |
+
Generator,
|
| 14 |
+
List,
|
| 15 |
+
Optional,
|
| 16 |
+
TypeVar,
|
| 17 |
+
Union,
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
from pip._internal.utils.misc import enum, rmtree
|
| 21 |
+
|
| 22 |
+
logger = logging.getLogger(__name__)
|
| 23 |
+
|
| 24 |
+
_T = TypeVar("_T", bound="TempDirectory")
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
# Kinds of temporary directories. Only needed for ones that are
|
| 28 |
+
# globally-managed.
|
| 29 |
+
tempdir_kinds = enum(
|
| 30 |
+
BUILD_ENV="build-env",
|
| 31 |
+
EPHEM_WHEEL_CACHE="ephem-wheel-cache",
|
| 32 |
+
REQ_BUILD="req-build",
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
_tempdir_manager: Optional[ExitStack] = None
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
@contextmanager
|
| 40 |
+
def global_tempdir_manager() -> Generator[None, None, None]:
|
| 41 |
+
global _tempdir_manager
|
| 42 |
+
with ExitStack() as stack:
|
| 43 |
+
old_tempdir_manager, _tempdir_manager = _tempdir_manager, stack
|
| 44 |
+
try:
|
| 45 |
+
yield
|
| 46 |
+
finally:
|
| 47 |
+
_tempdir_manager = old_tempdir_manager
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class TempDirectoryTypeRegistry:
|
| 51 |
+
"""Manages temp directory behavior"""
|
| 52 |
+
|
| 53 |
+
def __init__(self) -> None:
|
| 54 |
+
self._should_delete: Dict[str, bool] = {}
|
| 55 |
+
|
| 56 |
+
def set_delete(self, kind: str, value: bool) -> None:
|
| 57 |
+
"""Indicate whether a TempDirectory of the given kind should be
|
| 58 |
+
auto-deleted.
|
| 59 |
+
"""
|
| 60 |
+
self._should_delete[kind] = value
|
| 61 |
+
|
| 62 |
+
def get_delete(self, kind: str) -> bool:
|
| 63 |
+
"""Get configured auto-delete flag for a given TempDirectory type,
|
| 64 |
+
default True.
|
| 65 |
+
"""
|
| 66 |
+
return self._should_delete.get(kind, True)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
_tempdir_registry: Optional[TempDirectoryTypeRegistry] = None
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
@contextmanager
|
| 73 |
+
def tempdir_registry() -> Generator[TempDirectoryTypeRegistry, None, None]:
|
| 74 |
+
"""Provides a scoped global tempdir registry that can be used to dictate
|
| 75 |
+
whether directories should be deleted.
|
| 76 |
+
"""
|
| 77 |
+
global _tempdir_registry
|
| 78 |
+
old_tempdir_registry = _tempdir_registry
|
| 79 |
+
_tempdir_registry = TempDirectoryTypeRegistry()
|
| 80 |
+
try:
|
| 81 |
+
yield _tempdir_registry
|
| 82 |
+
finally:
|
| 83 |
+
_tempdir_registry = old_tempdir_registry
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
class _Default:
|
| 87 |
+
pass
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
_default = _Default()
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
class TempDirectory:
|
| 94 |
+
"""Helper class that owns and cleans up a temporary directory.
|
| 95 |
+
|
| 96 |
+
This class can be used as a context manager or as an OO representation of a
|
| 97 |
+
temporary directory.
|
| 98 |
+
|
| 99 |
+
Attributes:
|
| 100 |
+
path
|
| 101 |
+
Location to the created temporary directory
|
| 102 |
+
delete
|
| 103 |
+
Whether the directory should be deleted when exiting
|
| 104 |
+
(when used as a contextmanager)
|
| 105 |
+
|
| 106 |
+
Methods:
|
| 107 |
+
cleanup()
|
| 108 |
+
Deletes the temporary directory
|
| 109 |
+
|
| 110 |
+
When used as a context manager, if the delete attribute is True, on
|
| 111 |
+
exiting the context the temporary directory is deleted.
|
| 112 |
+
"""
|
| 113 |
+
|
| 114 |
+
def __init__(
|
| 115 |
+
self,
|
| 116 |
+
path: Optional[str] = None,
|
| 117 |
+
delete: Union[bool, None, _Default] = _default,
|
| 118 |
+
kind: str = "temp",
|
| 119 |
+
globally_managed: bool = False,
|
| 120 |
+
ignore_cleanup_errors: bool = True,
|
| 121 |
+
):
|
| 122 |
+
super().__init__()
|
| 123 |
+
|
| 124 |
+
if delete is _default:
|
| 125 |
+
if path is not None:
|
| 126 |
+
# If we were given an explicit directory, resolve delete option
|
| 127 |
+
# now.
|
| 128 |
+
delete = False
|
| 129 |
+
else:
|
| 130 |
+
# Otherwise, we wait until cleanup and see what
|
| 131 |
+
# tempdir_registry says.
|
| 132 |
+
delete = None
|
| 133 |
+
|
| 134 |
+
# The only time we specify path is in for editables where it
|
| 135 |
+
# is the value of the --src option.
|
| 136 |
+
if path is None:
|
| 137 |
+
path = self._create(kind)
|
| 138 |
+
|
| 139 |
+
self._path = path
|
| 140 |
+
self._deleted = False
|
| 141 |
+
self.delete = delete
|
| 142 |
+
self.kind = kind
|
| 143 |
+
self.ignore_cleanup_errors = ignore_cleanup_errors
|
| 144 |
+
|
| 145 |
+
if globally_managed:
|
| 146 |
+
assert _tempdir_manager is not None
|
| 147 |
+
_tempdir_manager.enter_context(self)
|
| 148 |
+
|
| 149 |
+
@property
|
| 150 |
+
def path(self) -> str:
|
| 151 |
+
assert not self._deleted, f"Attempted to access deleted path: {self._path}"
|
| 152 |
+
return self._path
|
| 153 |
+
|
| 154 |
+
def __repr__(self) -> str:
|
| 155 |
+
return f"<{self.__class__.__name__} {self.path!r}>"
|
| 156 |
+
|
| 157 |
+
def __enter__(self: _T) -> _T:
|
| 158 |
+
return self
|
| 159 |
+
|
| 160 |
+
def __exit__(self, exc: Any, value: Any, tb: Any) -> None:
|
| 161 |
+
if self.delete is not None:
|
| 162 |
+
delete = self.delete
|
| 163 |
+
elif _tempdir_registry:
|
| 164 |
+
delete = _tempdir_registry.get_delete(self.kind)
|
| 165 |
+
else:
|
| 166 |
+
delete = True
|
| 167 |
+
|
| 168 |
+
if delete:
|
| 169 |
+
self.cleanup()
|
| 170 |
+
|
| 171 |
+
def _create(self, kind: str) -> str:
|
| 172 |
+
"""Create a temporary directory and store its path in self.path"""
|
| 173 |
+
# We realpath here because some systems have their default tmpdir
|
| 174 |
+
# symlinked to another directory. This tends to confuse build
|
| 175 |
+
# scripts, so we canonicalize the path by traversing potential
|
| 176 |
+
# symlinks here.
|
| 177 |
+
path = os.path.realpath(tempfile.mkdtemp(prefix=f"pip-{kind}-"))
|
| 178 |
+
logger.debug("Created temporary directory: %s", path)
|
| 179 |
+
return path
|
| 180 |
+
|
| 181 |
+
def cleanup(self) -> None:
|
| 182 |
+
"""Remove the temporary directory created and reset state"""
|
| 183 |
+
self._deleted = True
|
| 184 |
+
if not os.path.exists(self._path):
|
| 185 |
+
return
|
| 186 |
+
|
| 187 |
+
errors: List[BaseException] = []
|
| 188 |
+
|
| 189 |
+
def onerror(
|
| 190 |
+
func: Callable[..., Any],
|
| 191 |
+
path: Path,
|
| 192 |
+
exc_val: BaseException,
|
| 193 |
+
) -> None:
|
| 194 |
+
"""Log a warning for a `rmtree` error and continue"""
|
| 195 |
+
formatted_exc = "\n".join(
|
| 196 |
+
traceback.format_exception_only(type(exc_val), exc_val)
|
| 197 |
+
)
|
| 198 |
+
formatted_exc = formatted_exc.rstrip() # remove trailing new line
|
| 199 |
+
if func in (os.unlink, os.remove, os.rmdir):
|
| 200 |
+
logger.debug(
|
| 201 |
+
"Failed to remove a temporary file '%s' due to %s.\n",
|
| 202 |
+
path,
|
| 203 |
+
formatted_exc,
|
| 204 |
+
)
|
| 205 |
+
else:
|
| 206 |
+
logger.debug("%s failed with %s.", func.__qualname__, formatted_exc)
|
| 207 |
+
errors.append(exc_val)
|
| 208 |
+
|
| 209 |
+
if self.ignore_cleanup_errors:
|
| 210 |
+
try:
|
| 211 |
+
# first try with @retry; retrying to handle ephemeral errors
|
| 212 |
+
rmtree(self._path, ignore_errors=False)
|
| 213 |
+
except OSError:
|
| 214 |
+
# last pass ignore/log all errors
|
| 215 |
+
rmtree(self._path, onexc=onerror)
|
| 216 |
+
if errors:
|
| 217 |
+
logger.warning(
|
| 218 |
+
"Failed to remove contents in a temporary directory '%s'.\n"
|
| 219 |
+
"You can safely remove it manually.",
|
| 220 |
+
self._path,
|
| 221 |
+
)
|
| 222 |
+
else:
|
| 223 |
+
rmtree(self._path)
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
class AdjacentTempDirectory(TempDirectory):
|
| 227 |
+
"""Helper class that creates a temporary directory adjacent to a real one.
|
| 228 |
+
|
| 229 |
+
Attributes:
|
| 230 |
+
original
|
| 231 |
+
The original directory to create a temp directory for.
|
| 232 |
+
path
|
| 233 |
+
After calling create() or entering, contains the full
|
| 234 |
+
path to the temporary directory.
|
| 235 |
+
delete
|
| 236 |
+
Whether the directory should be deleted when exiting
|
| 237 |
+
(when used as a contextmanager)
|
| 238 |
+
|
| 239 |
+
"""
|
| 240 |
+
|
| 241 |
+
# The characters that may be used to name the temp directory
|
| 242 |
+
# We always prepend a ~ and then rotate through these until
|
| 243 |
+
# a usable name is found.
|
| 244 |
+
# pkg_resources raises a different error for .dist-info folder
|
| 245 |
+
# with leading '-' and invalid metadata
|
| 246 |
+
LEADING_CHARS = "-~.=%0123456789"
|
| 247 |
+
|
| 248 |
+
def __init__(self, original: str, delete: Optional[bool] = None) -> None:
|
| 249 |
+
self.original = original.rstrip("/\\")
|
| 250 |
+
super().__init__(delete=delete)
|
| 251 |
+
|
| 252 |
+
@classmethod
|
| 253 |
+
def _generate_names(cls, name: str) -> Generator[str, None, None]:
|
| 254 |
+
"""Generates a series of temporary names.
|
| 255 |
+
|
| 256 |
+
The algorithm replaces the leading characters in the name
|
| 257 |
+
with ones that are valid filesystem characters, but are not
|
| 258 |
+
valid package names (for both Python and pip definitions of
|
| 259 |
+
package).
|
| 260 |
+
"""
|
| 261 |
+
for i in range(1, len(name)):
|
| 262 |
+
for candidate in itertools.combinations_with_replacement(
|
| 263 |
+
cls.LEADING_CHARS, i - 1
|
| 264 |
+
):
|
| 265 |
+
new_name = "~" + "".join(candidate) + name[i:]
|
| 266 |
+
if new_name != name:
|
| 267 |
+
yield new_name
|
| 268 |
+
|
| 269 |
+
# If we make it this far, we will have to make a longer name
|
| 270 |
+
for i in range(len(cls.LEADING_CHARS)):
|
| 271 |
+
for candidate in itertools.combinations_with_replacement(
|
| 272 |
+
cls.LEADING_CHARS, i
|
| 273 |
+
):
|
| 274 |
+
new_name = "~" + "".join(candidate) + name
|
| 275 |
+
if new_name != name:
|
| 276 |
+
yield new_name
|
| 277 |
+
|
| 278 |
+
def _create(self, kind: str) -> str:
|
| 279 |
+
root, name = os.path.split(self.original)
|
| 280 |
+
for candidate in self._generate_names(name):
|
| 281 |
+
path = os.path.join(root, candidate)
|
| 282 |
+
try:
|
| 283 |
+
os.mkdir(path)
|
| 284 |
+
except OSError as ex:
|
| 285 |
+
# Continue if the name exists already
|
| 286 |
+
if ex.errno != errno.EEXIST:
|
| 287 |
+
raise
|
| 288 |
+
else:
|
| 289 |
+
path = os.path.realpath(path)
|
| 290 |
+
break
|
| 291 |
+
else:
|
| 292 |
+
# Final fallback on the default behavior.
|
| 293 |
+
path = os.path.realpath(tempfile.mkdtemp(prefix=f"pip-{kind}-"))
|
| 294 |
+
|
| 295 |
+
logger.debug("Created temporary directory: %s", path)
|
| 296 |
+
return path
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/urls.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import string
|
| 3 |
+
import urllib.parse
|
| 4 |
+
import urllib.request
|
| 5 |
+
|
| 6 |
+
from .compat import WINDOWS
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def path_to_url(path: str) -> str:
|
| 10 |
+
"""
|
| 11 |
+
Convert a path to a file: URL. The path will be made absolute and have
|
| 12 |
+
quoted path parts.
|
| 13 |
+
"""
|
| 14 |
+
path = os.path.normpath(os.path.abspath(path))
|
| 15 |
+
url = urllib.parse.urljoin("file:", urllib.request.pathname2url(path))
|
| 16 |
+
return url
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def url_to_path(url: str) -> str:
|
| 20 |
+
"""
|
| 21 |
+
Convert a file: URL to a path.
|
| 22 |
+
"""
|
| 23 |
+
assert url.startswith(
|
| 24 |
+
"file:"
|
| 25 |
+
), f"You can only turn file: urls into filenames (not {url!r})"
|
| 26 |
+
|
| 27 |
+
_, netloc, path, _, _ = urllib.parse.urlsplit(url)
|
| 28 |
+
|
| 29 |
+
if not netloc or netloc == "localhost":
|
| 30 |
+
# According to RFC 8089, same as empty authority.
|
| 31 |
+
netloc = ""
|
| 32 |
+
elif WINDOWS:
|
| 33 |
+
# If we have a UNC path, prepend UNC share notation.
|
| 34 |
+
netloc = "\\\\" + netloc
|
| 35 |
+
else:
|
| 36 |
+
raise ValueError(
|
| 37 |
+
f"non-local file URIs are not supported on this platform: {url!r}"
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
path = urllib.request.url2pathname(netloc + path)
|
| 41 |
+
|
| 42 |
+
# On Windows, urlsplit parses the path as something like "/C:/Users/foo".
|
| 43 |
+
# This creates issues for path-related functions like io.open(), so we try
|
| 44 |
+
# to detect and strip the leading slash.
|
| 45 |
+
if (
|
| 46 |
+
WINDOWS
|
| 47 |
+
and not netloc # Not UNC.
|
| 48 |
+
and len(path) >= 3
|
| 49 |
+
and path[0] == "/" # Leading slash to strip.
|
| 50 |
+
and path[1] in string.ascii_letters # Drive letter.
|
| 51 |
+
and path[2:4] in (":", ":/") # Colon + end of string, or colon + absolute path.
|
| 52 |
+
):
|
| 53 |
+
path = path[1:]
|
| 54 |
+
|
| 55 |
+
return path
|
videollama2/lib/python3.10/site-packages/pip/_internal/utils/wheel.py
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Support functions for working with wheel files.
|
| 2 |
+
"""
|
| 3 |
+
|
| 4 |
+
import logging
|
| 5 |
+
from email.message import Message
|
| 6 |
+
from email.parser import Parser
|
| 7 |
+
from typing import Tuple
|
| 8 |
+
from zipfile import BadZipFile, ZipFile
|
| 9 |
+
|
| 10 |
+
from pip._vendor.packaging.utils import canonicalize_name
|
| 11 |
+
|
| 12 |
+
from pip._internal.exceptions import UnsupportedWheel
|
| 13 |
+
|
| 14 |
+
VERSION_COMPATIBLE = (1, 0)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
logger = logging.getLogger(__name__)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def parse_wheel(wheel_zip: ZipFile, name: str) -> Tuple[str, Message]:
|
| 21 |
+
"""Extract information from the provided wheel, ensuring it meets basic
|
| 22 |
+
standards.
|
| 23 |
+
|
| 24 |
+
Returns the name of the .dist-info directory and the parsed WHEEL metadata.
|
| 25 |
+
"""
|
| 26 |
+
try:
|
| 27 |
+
info_dir = wheel_dist_info_dir(wheel_zip, name)
|
| 28 |
+
metadata = wheel_metadata(wheel_zip, info_dir)
|
| 29 |
+
version = wheel_version(metadata)
|
| 30 |
+
except UnsupportedWheel as e:
|
| 31 |
+
raise UnsupportedWheel(f"{name} has an invalid wheel, {e}")
|
| 32 |
+
|
| 33 |
+
check_compatibility(version, name)
|
| 34 |
+
|
| 35 |
+
return info_dir, metadata
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def wheel_dist_info_dir(source: ZipFile, name: str) -> str:
|
| 39 |
+
"""Returns the name of the contained .dist-info directory.
|
| 40 |
+
|
| 41 |
+
Raises AssertionError or UnsupportedWheel if not found, >1 found, or
|
| 42 |
+
it doesn't match the provided name.
|
| 43 |
+
"""
|
| 44 |
+
# Zip file path separators must be /
|
| 45 |
+
subdirs = {p.split("/", 1)[0] for p in source.namelist()}
|
| 46 |
+
|
| 47 |
+
info_dirs = [s for s in subdirs if s.endswith(".dist-info")]
|
| 48 |
+
|
| 49 |
+
if not info_dirs:
|
| 50 |
+
raise UnsupportedWheel(".dist-info directory not found")
|
| 51 |
+
|
| 52 |
+
if len(info_dirs) > 1:
|
| 53 |
+
raise UnsupportedWheel(
|
| 54 |
+
"multiple .dist-info directories found: {}".format(", ".join(info_dirs))
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
info_dir = info_dirs[0]
|
| 58 |
+
|
| 59 |
+
info_dir_name = canonicalize_name(info_dir)
|
| 60 |
+
canonical_name = canonicalize_name(name)
|
| 61 |
+
if not info_dir_name.startswith(canonical_name):
|
| 62 |
+
raise UnsupportedWheel(
|
| 63 |
+
f".dist-info directory {info_dir!r} does not start with {canonical_name!r}"
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
return info_dir
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def read_wheel_metadata_file(source: ZipFile, path: str) -> bytes:
|
| 70 |
+
try:
|
| 71 |
+
return source.read(path)
|
| 72 |
+
# BadZipFile for general corruption, KeyError for missing entry,
|
| 73 |
+
# and RuntimeError for password-protected files
|
| 74 |
+
except (BadZipFile, KeyError, RuntimeError) as e:
|
| 75 |
+
raise UnsupportedWheel(f"could not read {path!r} file: {e!r}")
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def wheel_metadata(source: ZipFile, dist_info_dir: str) -> Message:
|
| 79 |
+
"""Return the WHEEL metadata of an extracted wheel, if possible.
|
| 80 |
+
Otherwise, raise UnsupportedWheel.
|
| 81 |
+
"""
|
| 82 |
+
path = f"{dist_info_dir}/WHEEL"
|
| 83 |
+
# Zip file path separators must be /
|
| 84 |
+
wheel_contents = read_wheel_metadata_file(source, path)
|
| 85 |
+
|
| 86 |
+
try:
|
| 87 |
+
wheel_text = wheel_contents.decode()
|
| 88 |
+
except UnicodeDecodeError as e:
|
| 89 |
+
raise UnsupportedWheel(f"error decoding {path!r}: {e!r}")
|
| 90 |
+
|
| 91 |
+
# FeedParser (used by Parser) does not raise any exceptions. The returned
|
| 92 |
+
# message may have .defects populated, but for backwards-compatibility we
|
| 93 |
+
# currently ignore them.
|
| 94 |
+
return Parser().parsestr(wheel_text)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def wheel_version(wheel_data: Message) -> Tuple[int, ...]:
|
| 98 |
+
"""Given WHEEL metadata, return the parsed Wheel-Version.
|
| 99 |
+
Otherwise, raise UnsupportedWheel.
|
| 100 |
+
"""
|
| 101 |
+
version_text = wheel_data["Wheel-Version"]
|
| 102 |
+
if version_text is None:
|
| 103 |
+
raise UnsupportedWheel("WHEEL is missing Wheel-Version")
|
| 104 |
+
|
| 105 |
+
version = version_text.strip()
|
| 106 |
+
|
| 107 |
+
try:
|
| 108 |
+
return tuple(map(int, version.split(".")))
|
| 109 |
+
except ValueError:
|
| 110 |
+
raise UnsupportedWheel(f"invalid Wheel-Version: {version!r}")
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def check_compatibility(version: Tuple[int, ...], name: str) -> None:
|
| 114 |
+
"""Raises errors or warns if called with an incompatible Wheel-Version.
|
| 115 |
+
|
| 116 |
+
pip should refuse to install a Wheel-Version that's a major series
|
| 117 |
+
ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when
|
| 118 |
+
installing a version only minor version ahead (e.g 1.2 > 1.1).
|
| 119 |
+
|
| 120 |
+
version: a 2-tuple representing a Wheel-Version (Major, Minor)
|
| 121 |
+
name: name of wheel or package to raise exception about
|
| 122 |
+
|
| 123 |
+
:raises UnsupportedWheel: when an incompatible Wheel-Version is given
|
| 124 |
+
"""
|
| 125 |
+
if version[0] > VERSION_COMPATIBLE[0]:
|
| 126 |
+
raise UnsupportedWheel(
|
| 127 |
+
"{}'s Wheel-Version ({}) is not compatible with this version "
|
| 128 |
+
"of pip".format(name, ".".join(map(str, version)))
|
| 129 |
+
)
|
| 130 |
+
elif version > VERSION_COMPATIBLE:
|
| 131 |
+
logger.warning(
|
| 132 |
+
"Installing from a newer Wheel-Version (%s)",
|
| 133 |
+
".".join(map(str, version)),
|
| 134 |
+
)
|
vllm/lib/python3.10/site-packages/cupy/_core/_routines_statistics.cpython-310-x86_64-linux-gnu.so
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4886f8ecbc3079a0b55acd1aeda5a89711d4674dd18709782df832efd1c257ef
|
| 3 |
+
size 1246528
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/binary_search.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the binary_search.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch binary_search
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/binary_search.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/binary_search.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/binary_search.h>
|
| 41 |
+
# include <thrust/system/omp/detail/binary_search.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/binary_search.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_BINARY_SEARCH_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/binary_search.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_BINARY_SEARCH_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_BINARY_SEARCH_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_BINARY_SEARCH_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/binary_search.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_BINARY_SEARCH_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_BINARY_SEARCH_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/extrema.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a extrema of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the extrema.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch extrema
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/extrema.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/extrema.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/extrema.h>
|
| 41 |
+
# include <thrust/system/omp/detail/extrema.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/extrema.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_EXTREMA_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/extrema.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_EXTREMA_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_EXTREMA_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_EXTREMA_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/extrema.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_EXTREMA_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_EXTREMA_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/fill.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a fill of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the fill.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch fill
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/fill.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/fill.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/fill.h>
|
| 41 |
+
# include <thrust/system/omp/detail/fill.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/fill.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_FILL_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/fill.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_FILL_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_FILL_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_FILL_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/fill.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_FILL_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_FILL_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/inner_product.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a fill of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the inner_product.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch inner_product
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/inner_product.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/inner_product.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/inner_product.h>
|
| 41 |
+
# include <thrust/system/omp/detail/inner_product.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/inner_product.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_INNER_PRODUCT_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/inner_product.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_INNER_PRODUCT_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_INNER_PRODUCT_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_INNER_PRODUCT_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/inner_product.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_INNER_PRODUCT_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_INNER_PRODUCT_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/mismatch.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a fill of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the mismatch.h header
|
| 30 |
+
// of the host and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch mismatch
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/mismatch.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/mismatch.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/mismatch.h>
|
| 41 |
+
# include <thrust/system/omp/detail/mismatch.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/mismatch.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_MISMATCH_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/mismatch.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_MISMATCH_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_MISMATCH_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_MISMATCH_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/mismatch.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_MISMATCH_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_MISMATCH_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/partition.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a fill of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the partition.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch partition
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/partition.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/partition.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/partition.h>
|
| 41 |
+
# include <thrust/system/omp/detail/partition.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/partition.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_PARTITION_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/partition.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_PARTITION_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_PARTITION_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_PARTITION_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/partition.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_PARTITION_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_PARTITION_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/replace.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a fill of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the replace.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch replace
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/replace.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/replace.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/replace.h>
|
| 41 |
+
# include <thrust/system/omp/detail/replace.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/replace.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_REPLACE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/replace.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_REPLACE_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_REPLACE_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_REPLACE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/replace.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_REPLACE_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_REPLACE_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/scan.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the scan.h header
|
| 30 |
+
// of the host and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch scan
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/scan.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/scan.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/scan.h>
|
| 41 |
+
# include <thrust/system/omp/detail/scan.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/scan.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_SCAN_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/scan.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_SCAN_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_SCAN_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_SCAN_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/scan.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_SCAN_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_SCAN_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/scan_by_key.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the scan_by_key.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch scan_by_key
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/scan_by_key.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/scan_by_key.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/scan_by_key.h>
|
| 41 |
+
# include <thrust/system/omp/detail/scan_by_key.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/scan_by_key.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_SCAN_BY_KEY_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/scan_by_key.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_SCAN_BY_KEY_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_SCAN_BY_KEY_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_SCAN_BY_KEY_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/scan_by_key.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_SCAN_BY_KEY_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_SCAN_BY_KEY_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/scatter.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a fill of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the scatter.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch scatter
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/scatter.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/scatter.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/scatter.h>
|
| 41 |
+
# include <thrust/system/omp/detail/scatter.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/scatter.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_SCATTER_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/scatter.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_SCATTER_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_SCATTER_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_SCATTER_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/scatter.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_SCATTER_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_SCATTER_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/transform.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a fill of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the transform.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch transform
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/transform.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/transform.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/transform.h>
|
| 41 |
+
# include <thrust/system/omp/detail/transform.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/transform.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_TRANSFORM_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/transform.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_TRANSFORM_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_TRANSFORM_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_TRANSFORM_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/transform.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_TRANSFORM_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_TRANSFORM_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/transform_reduce.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a fill of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the transform_reduce.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch transform_reduce
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/transform_reduce.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/transform_reduce.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/transform_reduce.h>
|
| 41 |
+
# include <thrust/system/omp/detail/transform_reduce.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/transform_reduce.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_TRANSFORM_REDUCE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/transform_reduce.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_TRANSFORM_REDUCE_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_TRANSFORM_REDUCE_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_TRANSFORM_REDUCE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/transform_reduce.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_TRANSFORM_REDUCE_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_TRANSFORM_REDUCE_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/uninitialized_copy.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a fill of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the uninitialized_copy.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch uninitialized_copy
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/uninitialized_copy.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/uninitialized_copy.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/uninitialized_copy.h>
|
| 41 |
+
# include <thrust/system/omp/detail/uninitialized_copy.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/uninitialized_copy.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_UNINITIALIZED_COPY_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/uninitialized_copy.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_UNINITIALIZED_COPY_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_UNINITIALIZED_COPY_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_UNINITIALIZED_COPY_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/uninitialized_copy.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_UNINITIALIZED_COPY_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_UNINITIALIZED_COPY_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/adl/unique.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a fill of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
// the purpose of this header is to #include the unique.h header
|
| 30 |
+
// of the sequential, host, and device systems. It should be #included in any
|
| 31 |
+
// code which uses adl to dispatch unique
|
| 32 |
+
|
| 33 |
+
#include <thrust/system/detail/sequential/unique.h>
|
| 34 |
+
|
| 35 |
+
// SCons can't see through the #defines below to figure out what this header
|
| 36 |
+
// includes, so we fake it out by specifying all possible files we might end up
|
| 37 |
+
// including inside an #if 0.
|
| 38 |
+
#if 0
|
| 39 |
+
# include <thrust/system/cpp/detail/unique.h>
|
| 40 |
+
# include <thrust/system/cuda/detail/unique.h>
|
| 41 |
+
# include <thrust/system/omp/detail/unique.h>
|
| 42 |
+
# include <thrust/system/tbb/detail/unique.h>
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#define __THRUST_HOST_SYSTEM_UNIQUE_HEADER <__THRUST_HOST_SYSTEM_ROOT/detail/unique.h>
|
| 46 |
+
#include __THRUST_HOST_SYSTEM_UNIQUE_HEADER
|
| 47 |
+
#undef __THRUST_HOST_SYSTEM_UNIQUE_HEADER
|
| 48 |
+
|
| 49 |
+
#define __THRUST_DEVICE_SYSTEM_UNIQUE_HEADER <__THRUST_DEVICE_SYSTEM_ROOT/detail/unique.h>
|
| 50 |
+
#include __THRUST_DEVICE_SYSTEM_UNIQUE_HEADER
|
| 51 |
+
#undef __THRUST_DEVICE_SYSTEM_UNIQUE_HEADER
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/advance.h
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
THRUST_NAMESPACE_BEGIN
|
| 30 |
+
namespace system
|
| 31 |
+
{
|
| 32 |
+
namespace detail
|
| 33 |
+
{
|
| 34 |
+
namespace generic
|
| 35 |
+
{
|
| 36 |
+
|
| 37 |
+
template <typename InputIterator, typename Distance>
|
| 38 |
+
_CCCL_HOST_DEVICE void advance(InputIterator& i, Distance n);
|
| 39 |
+
|
| 40 |
+
} // end namespace generic
|
| 41 |
+
} // end namespace detail
|
| 42 |
+
} // end namespace system
|
| 43 |
+
THRUST_NAMESPACE_END
|
| 44 |
+
|
| 45 |
+
#include <thrust/system/detail/generic/advance.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/binary_search.inl
ADDED
|
@@ -0,0 +1,391 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/binary_search.h>
|
| 29 |
+
#include <thrust/detail/function.h>
|
| 30 |
+
#include <thrust/detail/temporary_array.h>
|
| 31 |
+
#include <thrust/detail/type_traits.h>
|
| 32 |
+
#include <thrust/distance.h>
|
| 33 |
+
#include <thrust/for_each.h>
|
| 34 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 35 |
+
#include <thrust/iterator/zip_iterator.h>
|
| 36 |
+
#include <thrust/system/detail/generic/scalar/binary_search.h>
|
| 37 |
+
#include <thrust/system/detail/generic/select_system.h>
|
| 38 |
+
|
| 39 |
+
THRUST_NAMESPACE_BEGIN
|
| 40 |
+
namespace detail
|
| 41 |
+
{
|
| 42 |
+
|
| 43 |
+
// XXX WAR circular #inclusion with this forward declaration
|
| 44 |
+
template <typename, typename>
|
| 45 |
+
class temporary_array;
|
| 46 |
+
|
| 47 |
+
} // namespace detail
|
| 48 |
+
namespace system
|
| 49 |
+
{
|
| 50 |
+
namespace detail
|
| 51 |
+
{
|
| 52 |
+
namespace generic
|
| 53 |
+
{
|
| 54 |
+
namespace detail
|
| 55 |
+
{
|
| 56 |
+
|
| 57 |
+
// short names to avoid nvcc bug
|
| 58 |
+
struct lbf
|
| 59 |
+
{
|
| 60 |
+
template <typename RandomAccessIterator, typename T, typename StrictWeakOrdering>
|
| 61 |
+
_CCCL_HOST_DEVICE typename thrust::iterator_traits<RandomAccessIterator>::difference_type
|
| 62 |
+
operator()(RandomAccessIterator begin, RandomAccessIterator end, const T& value, StrictWeakOrdering comp)
|
| 63 |
+
{
|
| 64 |
+
return thrust::system::detail::generic::scalar::lower_bound(begin, end, value, comp) - begin;
|
| 65 |
+
}
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
struct ubf
|
| 69 |
+
{
|
| 70 |
+
template <typename RandomAccessIterator, typename T, typename StrictWeakOrdering>
|
| 71 |
+
_CCCL_HOST_DEVICE typename thrust::iterator_traits<RandomAccessIterator>::difference_type
|
| 72 |
+
operator()(RandomAccessIterator begin, RandomAccessIterator end, const T& value, StrictWeakOrdering comp)
|
| 73 |
+
{
|
| 74 |
+
return thrust::system::detail::generic::scalar::upper_bound(begin, end, value, comp) - begin;
|
| 75 |
+
}
|
| 76 |
+
};
|
| 77 |
+
|
| 78 |
+
struct bsf
|
| 79 |
+
{
|
| 80 |
+
template <typename RandomAccessIterator, typename T, typename StrictWeakOrdering>
|
| 81 |
+
_CCCL_HOST_DEVICE bool
|
| 82 |
+
operator()(RandomAccessIterator begin, RandomAccessIterator end, const T& value, StrictWeakOrdering comp)
|
| 83 |
+
{
|
| 84 |
+
RandomAccessIterator iter = thrust::system::detail::generic::scalar::lower_bound(begin, end, value, comp);
|
| 85 |
+
|
| 86 |
+
thrust::detail::wrapped_function<StrictWeakOrdering, bool> wrapped_comp{comp};
|
| 87 |
+
|
| 88 |
+
return iter != end && !wrapped_comp(value, *iter);
|
| 89 |
+
}
|
| 90 |
+
};
|
| 91 |
+
|
| 92 |
+
template <typename ForwardIterator, typename StrictWeakOrdering, typename BinarySearchFunction>
|
| 93 |
+
struct binary_search_functor
|
| 94 |
+
{
|
| 95 |
+
ForwardIterator begin;
|
| 96 |
+
ForwardIterator end;
|
| 97 |
+
StrictWeakOrdering comp;
|
| 98 |
+
BinarySearchFunction func;
|
| 99 |
+
|
| 100 |
+
_CCCL_HOST_DEVICE
|
| 101 |
+
binary_search_functor(ForwardIterator begin, ForwardIterator end, StrictWeakOrdering comp, BinarySearchFunction func)
|
| 102 |
+
: begin(begin)
|
| 103 |
+
, end(end)
|
| 104 |
+
, comp(comp)
|
| 105 |
+
, func(func)
|
| 106 |
+
{}
|
| 107 |
+
|
| 108 |
+
template <typename Tuple>
|
| 109 |
+
_CCCL_HOST_DEVICE void operator()(Tuple t)
|
| 110 |
+
{
|
| 111 |
+
thrust::get<1>(t) = func(begin, end, thrust::get<0>(t), comp);
|
| 112 |
+
}
|
| 113 |
+
}; // binary_search_functor
|
| 114 |
+
|
| 115 |
+
// Vector Implementation
|
| 116 |
+
template <typename DerivedPolicy,
|
| 117 |
+
typename ForwardIterator,
|
| 118 |
+
typename InputIterator,
|
| 119 |
+
typename OutputIterator,
|
| 120 |
+
typename StrictWeakOrdering,
|
| 121 |
+
typename BinarySearchFunction>
|
| 122 |
+
_CCCL_HOST_DEVICE OutputIterator binary_search(
|
| 123 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 124 |
+
ForwardIterator begin,
|
| 125 |
+
ForwardIterator end,
|
| 126 |
+
InputIterator values_begin,
|
| 127 |
+
InputIterator values_end,
|
| 128 |
+
OutputIterator output,
|
| 129 |
+
StrictWeakOrdering comp,
|
| 130 |
+
BinarySearchFunction func)
|
| 131 |
+
{
|
| 132 |
+
thrust::for_each(
|
| 133 |
+
exec,
|
| 134 |
+
thrust::make_zip_iterator(thrust::make_tuple(values_begin, output)),
|
| 135 |
+
thrust::make_zip_iterator(thrust::make_tuple(values_end, output + thrust::distance(values_begin, values_end))),
|
| 136 |
+
detail::binary_search_functor<ForwardIterator, StrictWeakOrdering, BinarySearchFunction>(begin, end, comp, func));
|
| 137 |
+
|
| 138 |
+
return output + thrust::distance(values_begin, values_end);
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
// Scalar Implementation
|
| 142 |
+
template <typename OutputType,
|
| 143 |
+
typename DerivedPolicy,
|
| 144 |
+
typename ForwardIterator,
|
| 145 |
+
typename T,
|
| 146 |
+
typename StrictWeakOrdering,
|
| 147 |
+
typename BinarySearchFunction>
|
| 148 |
+
_CCCL_HOST_DEVICE OutputType binary_search(
|
| 149 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 150 |
+
ForwardIterator begin,
|
| 151 |
+
ForwardIterator end,
|
| 152 |
+
const T& value,
|
| 153 |
+
StrictWeakOrdering comp,
|
| 154 |
+
BinarySearchFunction func)
|
| 155 |
+
{
|
| 156 |
+
// use the vectorized path to implement the scalar version
|
| 157 |
+
|
| 158 |
+
// allocate device buffers for value and output
|
| 159 |
+
thrust::detail::temporary_array<T, DerivedPolicy> d_value(exec, 1);
|
| 160 |
+
thrust::detail::temporary_array<OutputType, DerivedPolicy> d_output(exec, 1);
|
| 161 |
+
|
| 162 |
+
{ // copy value to device
|
| 163 |
+
using value_in_system_t = typename thrust::iterator_system<const T*>::type;
|
| 164 |
+
value_in_system_t value_in_system;
|
| 165 |
+
using thrust::system::detail::generic::select_system;
|
| 166 |
+
thrust::copy_n(select_system(thrust::detail::derived_cast(thrust::detail::strip_const(value_in_system)),
|
| 167 |
+
thrust::detail::derived_cast(thrust::detail::strip_const(exec))),
|
| 168 |
+
&value,
|
| 169 |
+
1,
|
| 170 |
+
d_value.begin());
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
// perform the query
|
| 174 |
+
thrust::system::detail::generic::detail::binary_search(
|
| 175 |
+
exec, begin, end, d_value.begin(), d_value.end(), d_output.begin(), comp, func);
|
| 176 |
+
|
| 177 |
+
OutputType output;
|
| 178 |
+
{ // copy result to host and return
|
| 179 |
+
using result_out_system_t = typename thrust::iterator_system<OutputType*>::type;
|
| 180 |
+
result_out_system_t result_out_system;
|
| 181 |
+
using thrust::system::detail::generic::select_system;
|
| 182 |
+
thrust::copy_n(select_system(thrust::detail::derived_cast(thrust::detail::strip_const(exec)),
|
| 183 |
+
thrust::detail::derived_cast(thrust::detail::strip_const(result_out_system))),
|
| 184 |
+
d_output.begin(),
|
| 185 |
+
1,
|
| 186 |
+
&output);
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
return output;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
// this functor differs from thrust::less<T>
|
| 193 |
+
// because it allows the types of lhs & rhs to differ
|
| 194 |
+
// which is required by the binary search functions
|
| 195 |
+
// XXX use C++14 thrust::less<> when it's ready
|
| 196 |
+
struct binary_search_less
|
| 197 |
+
{
|
| 198 |
+
template <typename T1, typename T2>
|
| 199 |
+
_CCCL_HOST_DEVICE bool operator()(const T1& lhs, const T2& rhs) const
|
| 200 |
+
{
|
| 201 |
+
return lhs < rhs;
|
| 202 |
+
}
|
| 203 |
+
};
|
| 204 |
+
|
| 205 |
+
} // end namespace detail
|
| 206 |
+
|
| 207 |
+
//////////////////////
|
| 208 |
+
// Scalar Functions //
|
| 209 |
+
//////////////////////
|
| 210 |
+
|
| 211 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename T>
|
| 212 |
+
_CCCL_HOST_DEVICE ForwardIterator
|
| 213 |
+
lower_bound(thrust::execution_policy<DerivedPolicy>& exec, ForwardIterator begin, ForwardIterator end, const T& value)
|
| 214 |
+
{
|
| 215 |
+
namespace p = thrust::placeholders;
|
| 216 |
+
return thrust::lower_bound(exec, begin, end, value, detail::binary_search_less());
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename T, typename StrictWeakOrdering>
|
| 220 |
+
_CCCL_HOST_DEVICE ForwardIterator lower_bound(
|
| 221 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 222 |
+
ForwardIterator begin,
|
| 223 |
+
ForwardIterator end,
|
| 224 |
+
const T& value,
|
| 225 |
+
StrictWeakOrdering comp)
|
| 226 |
+
{
|
| 227 |
+
using difference_type = typename thrust::iterator_traits<ForwardIterator>::difference_type;
|
| 228 |
+
|
| 229 |
+
return begin + detail::binary_search<difference_type>(exec, begin, end, value, comp, detail::lbf());
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename T>
|
| 233 |
+
_CCCL_HOST_DEVICE ForwardIterator
|
| 234 |
+
upper_bound(thrust::execution_policy<DerivedPolicy>& exec, ForwardIterator begin, ForwardIterator end, const T& value)
|
| 235 |
+
{
|
| 236 |
+
namespace p = thrust::placeholders;
|
| 237 |
+
return thrust::upper_bound(exec, begin, end, value, detail::binary_search_less());
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename T, typename StrictWeakOrdering>
|
| 241 |
+
_CCCL_HOST_DEVICE ForwardIterator upper_bound(
|
| 242 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 243 |
+
ForwardIterator begin,
|
| 244 |
+
ForwardIterator end,
|
| 245 |
+
const T& value,
|
| 246 |
+
StrictWeakOrdering comp)
|
| 247 |
+
{
|
| 248 |
+
using difference_type = typename thrust::iterator_traits<ForwardIterator>::difference_type;
|
| 249 |
+
|
| 250 |
+
return begin + detail::binary_search<difference_type>(exec, begin, end, value, comp, detail::ubf());
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename T>
|
| 254 |
+
_CCCL_HOST_DEVICE bool
|
| 255 |
+
binary_search(thrust::execution_policy<DerivedPolicy>& exec, ForwardIterator begin, ForwardIterator end, const T& value)
|
| 256 |
+
{
|
| 257 |
+
return thrust::binary_search(exec, begin, end, value, detail::binary_search_less());
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename T, typename StrictWeakOrdering>
|
| 261 |
+
_CCCL_HOST_DEVICE bool binary_search(
|
| 262 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 263 |
+
ForwardIterator begin,
|
| 264 |
+
ForwardIterator end,
|
| 265 |
+
const T& value,
|
| 266 |
+
StrictWeakOrdering comp)
|
| 267 |
+
{
|
| 268 |
+
return detail::binary_search<bool>(exec, begin, end, value, comp, detail::bsf());
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
//////////////////////
|
| 272 |
+
// Vector Functions //
|
| 273 |
+
//////////////////////
|
| 274 |
+
|
| 275 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename InputIterator, typename OutputIterator>
|
| 276 |
+
_CCCL_HOST_DEVICE OutputIterator lower_bound(
|
| 277 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 278 |
+
ForwardIterator begin,
|
| 279 |
+
ForwardIterator end,
|
| 280 |
+
InputIterator values_begin,
|
| 281 |
+
InputIterator values_end,
|
| 282 |
+
OutputIterator output)
|
| 283 |
+
{
|
| 284 |
+
namespace p = thrust::placeholders;
|
| 285 |
+
return thrust::lower_bound(exec, begin, end, values_begin, values_end, output, detail::binary_search_less());
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
template <typename DerivedPolicy,
|
| 289 |
+
typename ForwardIterator,
|
| 290 |
+
typename InputIterator,
|
| 291 |
+
typename OutputIterator,
|
| 292 |
+
typename StrictWeakOrdering>
|
| 293 |
+
_CCCL_HOST_DEVICE OutputIterator lower_bound(
|
| 294 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 295 |
+
ForwardIterator begin,
|
| 296 |
+
ForwardIterator end,
|
| 297 |
+
InputIterator values_begin,
|
| 298 |
+
InputIterator values_end,
|
| 299 |
+
OutputIterator output,
|
| 300 |
+
StrictWeakOrdering comp)
|
| 301 |
+
{
|
| 302 |
+
return detail::binary_search(exec, begin, end, values_begin, values_end, output, comp, detail::lbf());
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename InputIterator, typename OutputIterator>
|
| 306 |
+
_CCCL_HOST_DEVICE OutputIterator upper_bound(
|
| 307 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 308 |
+
ForwardIterator begin,
|
| 309 |
+
ForwardIterator end,
|
| 310 |
+
InputIterator values_begin,
|
| 311 |
+
InputIterator values_end,
|
| 312 |
+
OutputIterator output)
|
| 313 |
+
{
|
| 314 |
+
namespace p = thrust::placeholders;
|
| 315 |
+
return thrust::upper_bound(exec, begin, end, values_begin, values_end, output, detail::binary_search_less());
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
template <typename DerivedPolicy,
|
| 319 |
+
typename ForwardIterator,
|
| 320 |
+
typename InputIterator,
|
| 321 |
+
typename OutputIterator,
|
| 322 |
+
typename StrictWeakOrdering>
|
| 323 |
+
_CCCL_HOST_DEVICE OutputIterator upper_bound(
|
| 324 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 325 |
+
ForwardIterator begin,
|
| 326 |
+
ForwardIterator end,
|
| 327 |
+
InputIterator values_begin,
|
| 328 |
+
InputIterator values_end,
|
| 329 |
+
OutputIterator output,
|
| 330 |
+
StrictWeakOrdering comp)
|
| 331 |
+
{
|
| 332 |
+
return detail::binary_search(exec, begin, end, values_begin, values_end, output, comp, detail::ubf());
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename InputIterator, typename OutputIterator>
|
| 336 |
+
_CCCL_HOST_DEVICE OutputIterator binary_search(
|
| 337 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 338 |
+
ForwardIterator begin,
|
| 339 |
+
ForwardIterator end,
|
| 340 |
+
InputIterator values_begin,
|
| 341 |
+
InputIterator values_end,
|
| 342 |
+
OutputIterator output)
|
| 343 |
+
{
|
| 344 |
+
namespace p = thrust::placeholders;
|
| 345 |
+
return thrust::binary_search(exec, begin, end, values_begin, values_end, output, detail::binary_search_less());
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
template <typename DerivedPolicy,
|
| 349 |
+
typename ForwardIterator,
|
| 350 |
+
typename InputIterator,
|
| 351 |
+
typename OutputIterator,
|
| 352 |
+
typename StrictWeakOrdering>
|
| 353 |
+
_CCCL_HOST_DEVICE OutputIterator binary_search(
|
| 354 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 355 |
+
ForwardIterator begin,
|
| 356 |
+
ForwardIterator end,
|
| 357 |
+
InputIterator values_begin,
|
| 358 |
+
InputIterator values_end,
|
| 359 |
+
OutputIterator output,
|
| 360 |
+
StrictWeakOrdering comp)
|
| 361 |
+
{
|
| 362 |
+
return detail::binary_search(exec, begin, end, values_begin, values_end, output, comp, detail::bsf());
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename LessThanComparable>
|
| 366 |
+
_CCCL_HOST_DEVICE thrust::pair<ForwardIterator, ForwardIterator> equal_range(
|
| 367 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 368 |
+
ForwardIterator first,
|
| 369 |
+
ForwardIterator last,
|
| 370 |
+
const LessThanComparable& value)
|
| 371 |
+
{
|
| 372 |
+
return thrust::equal_range(exec, first, last, value, detail::binary_search_less());
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename T, typename StrictWeakOrdering>
|
| 376 |
+
_CCCL_HOST_DEVICE thrust::pair<ForwardIterator, ForwardIterator> equal_range(
|
| 377 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 378 |
+
ForwardIterator first,
|
| 379 |
+
ForwardIterator last,
|
| 380 |
+
const T& value,
|
| 381 |
+
StrictWeakOrdering comp)
|
| 382 |
+
{
|
| 383 |
+
ForwardIterator lb = thrust::lower_bound(exec, first, last, value, comp);
|
| 384 |
+
ForwardIterator ub = thrust::upper_bound(exec, first, last, value, comp);
|
| 385 |
+
return thrust::make_pair(lb, ub);
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
} // end namespace generic
|
| 389 |
+
} // end namespace detail
|
| 390 |
+
} // end namespace system
|
| 391 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/copy.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/system/detail/generic/tag.h>
|
| 29 |
+
|
| 30 |
+
THRUST_NAMESPACE_BEGIN
|
| 31 |
+
namespace system
|
| 32 |
+
{
|
| 33 |
+
namespace detail
|
| 34 |
+
{
|
| 35 |
+
namespace generic
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
template <typename DerivedPolicy, typename InputIterator, typename OutputIterator>
|
| 39 |
+
_CCCL_HOST_DEVICE OutputIterator
|
| 40 |
+
copy(thrust::execution_policy<DerivedPolicy>& exec, InputIterator first, InputIterator last, OutputIterator result);
|
| 41 |
+
|
| 42 |
+
template <typename DerivedPolicy, typename InputIterator, typename Size, typename OutputIterator>
|
| 43 |
+
_CCCL_HOST_DEVICE OutputIterator
|
| 44 |
+
copy_n(thrust::execution_policy<DerivedPolicy>& exec, InputIterator first, Size n, OutputIterator result);
|
| 45 |
+
|
| 46 |
+
} // namespace generic
|
| 47 |
+
} // namespace detail
|
| 48 |
+
} // namespace system
|
| 49 |
+
THRUST_NAMESPACE_END
|
| 50 |
+
|
| 51 |
+
#include <thrust/system/detail/generic/copy.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/copy.inl
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/internal_functional.h>
|
| 29 |
+
#include <thrust/for_each.h>
|
| 30 |
+
#include <thrust/functional.h>
|
| 31 |
+
#include <thrust/iterator/detail/minimum_system.h>
|
| 32 |
+
#include <thrust/iterator/zip_iterator.h>
|
| 33 |
+
#include <thrust/system/detail/generic/copy.h>
|
| 34 |
+
#include <thrust/transform.h>
|
| 35 |
+
#include <thrust/tuple.h>
|
| 36 |
+
|
| 37 |
+
THRUST_NAMESPACE_BEGIN
|
| 38 |
+
namespace system
|
| 39 |
+
{
|
| 40 |
+
namespace detail
|
| 41 |
+
{
|
| 42 |
+
namespace generic
|
| 43 |
+
{
|
| 44 |
+
|
| 45 |
+
template <typename DerivedPolicy, typename InputIterator, typename OutputIterator>
|
| 46 |
+
_CCCL_HOST_DEVICE OutputIterator
|
| 47 |
+
copy(thrust::execution_policy<DerivedPolicy>& exec, InputIterator first, InputIterator last, OutputIterator result)
|
| 48 |
+
{
|
| 49 |
+
using T = typename thrust::iterator_value<InputIterator>::type;
|
| 50 |
+
return thrust::transform(exec, first, last, result, thrust::identity<T>());
|
| 51 |
+
} // end copy()
|
| 52 |
+
|
| 53 |
+
template <typename DerivedPolicy, typename InputIterator, typename Size, typename OutputIterator>
|
| 54 |
+
_CCCL_HOST_DEVICE OutputIterator
|
| 55 |
+
copy_n(thrust::execution_policy<DerivedPolicy>& exec, InputIterator first, Size n, OutputIterator result)
|
| 56 |
+
{
|
| 57 |
+
using value_type = typename thrust::iterator_value<InputIterator>::type;
|
| 58 |
+
using xfrm_type = thrust::identity<value_type>;
|
| 59 |
+
|
| 60 |
+
using functor_type = thrust::detail::unary_transform_functor<xfrm_type>;
|
| 61 |
+
|
| 62 |
+
using iterator_tuple = thrust::tuple<InputIterator, OutputIterator>;
|
| 63 |
+
using zip_iter = thrust::zip_iterator<iterator_tuple>;
|
| 64 |
+
|
| 65 |
+
zip_iter zipped = thrust::make_zip_iterator(thrust::make_tuple(first, result));
|
| 66 |
+
|
| 67 |
+
return thrust::get<1>(thrust::for_each_n(exec, zipped, n, functor_type(xfrm_type())).get_iterator_tuple());
|
| 68 |
+
} // end copy_n()
|
| 69 |
+
|
| 70 |
+
} // namespace generic
|
| 71 |
+
} // namespace detail
|
| 72 |
+
} // namespace system
|
| 73 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/copy_if.h
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/system/detail/generic/tag.h>
|
| 29 |
+
|
| 30 |
+
THRUST_NAMESPACE_BEGIN
|
| 31 |
+
namespace system
|
| 32 |
+
{
|
| 33 |
+
namespace detail
|
| 34 |
+
{
|
| 35 |
+
namespace generic
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
template <typename DerivedPolicy, typename InputIterator, typename OutputIterator, typename Predicate>
|
| 39 |
+
_CCCL_HOST_DEVICE OutputIterator copy_if(
|
| 40 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 41 |
+
InputIterator first,
|
| 42 |
+
InputIterator last,
|
| 43 |
+
OutputIterator result,
|
| 44 |
+
Predicate pred);
|
| 45 |
+
|
| 46 |
+
template <typename DerivedPolicy,
|
| 47 |
+
typename InputIterator1,
|
| 48 |
+
typename InputIterator2,
|
| 49 |
+
typename OutputIterator,
|
| 50 |
+
typename Predicate>
|
| 51 |
+
_CCCL_HOST_DEVICE OutputIterator copy_if(
|
| 52 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 53 |
+
InputIterator1 first,
|
| 54 |
+
InputIterator1 last,
|
| 55 |
+
InputIterator2 stencil,
|
| 56 |
+
OutputIterator result,
|
| 57 |
+
Predicate pred);
|
| 58 |
+
|
| 59 |
+
} // end namespace generic
|
| 60 |
+
} // end namespace detail
|
| 61 |
+
} // end namespace system
|
| 62 |
+
THRUST_NAMESPACE_END
|
| 63 |
+
|
| 64 |
+
#include <thrust/system/detail/generic/copy_if.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/copy_if.inl
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/copy_if.h>
|
| 29 |
+
#include <thrust/detail/integer_traits.h>
|
| 30 |
+
#include <thrust/detail/internal_functional.h>
|
| 31 |
+
#include <thrust/detail/temporary_array.h>
|
| 32 |
+
#include <thrust/detail/type_traits.h>
|
| 33 |
+
#include <thrust/distance.h>
|
| 34 |
+
#include <thrust/functional.h>
|
| 35 |
+
#include <thrust/iterator/detail/minimum_system.h>
|
| 36 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 37 |
+
#include <thrust/scan.h>
|
| 38 |
+
#include <thrust/scatter.h>
|
| 39 |
+
#include <thrust/system/detail/generic/copy_if.h>
|
| 40 |
+
#include <thrust/transform.h>
|
| 41 |
+
|
| 42 |
+
#include <limits>
|
| 43 |
+
|
| 44 |
+
THRUST_NAMESPACE_BEGIN
|
| 45 |
+
namespace system
|
| 46 |
+
{
|
| 47 |
+
namespace detail
|
| 48 |
+
{
|
| 49 |
+
namespace generic
|
| 50 |
+
{
|
| 51 |
+
namespace detail
|
| 52 |
+
{
|
| 53 |
+
|
| 54 |
+
template <typename IndexType,
|
| 55 |
+
typename DerivedPolicy,
|
| 56 |
+
typename InputIterator1,
|
| 57 |
+
typename InputIterator2,
|
| 58 |
+
typename OutputIterator,
|
| 59 |
+
typename Predicate>
|
| 60 |
+
_CCCL_HOST_DEVICE OutputIterator copy_if(
|
| 61 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 62 |
+
InputIterator1 first,
|
| 63 |
+
InputIterator1 last,
|
| 64 |
+
InputIterator2 stencil,
|
| 65 |
+
OutputIterator result,
|
| 66 |
+
Predicate pred)
|
| 67 |
+
{
|
| 68 |
+
const auto n = static_cast<IndexType>(thrust::distance(first, last));
|
| 69 |
+
|
| 70 |
+
// compute {0,1} predicates
|
| 71 |
+
thrust::detail::temporary_array<IndexType, DerivedPolicy> predicates(exec, n);
|
| 72 |
+
thrust::transform(
|
| 73 |
+
exec, stencil, stencil + n, predicates.begin(), thrust::detail::predicate_to_integral<Predicate, IndexType>(pred));
|
| 74 |
+
|
| 75 |
+
// scan {0,1} predicates
|
| 76 |
+
thrust::detail::temporary_array<IndexType, DerivedPolicy> scatter_indices(exec, n);
|
| 77 |
+
thrust::exclusive_scan(
|
| 78 |
+
exec,
|
| 79 |
+
predicates.begin(),
|
| 80 |
+
predicates.end(),
|
| 81 |
+
scatter_indices.begin(),
|
| 82 |
+
static_cast<IndexType>(0),
|
| 83 |
+
thrust::plus<IndexType>());
|
| 84 |
+
|
| 85 |
+
// scatter the true elements
|
| 86 |
+
thrust::scatter_if(
|
| 87 |
+
exec, first, last, scatter_indices.begin(), predicates.begin(), result, thrust::identity<IndexType>());
|
| 88 |
+
|
| 89 |
+
// find the end of the new sequence
|
| 90 |
+
IndexType output_size = scatter_indices[n - 1] + predicates[n - 1];
|
| 91 |
+
|
| 92 |
+
return result + output_size;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
} // end namespace detail
|
| 96 |
+
|
| 97 |
+
template <typename DerivedPolicy, typename InputIterator, typename OutputIterator, typename Predicate>
|
| 98 |
+
_CCCL_HOST_DEVICE OutputIterator copy_if(
|
| 99 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 100 |
+
InputIterator first,
|
| 101 |
+
InputIterator last,
|
| 102 |
+
OutputIterator result,
|
| 103 |
+
Predicate pred)
|
| 104 |
+
{
|
| 105 |
+
// XXX it's potentially expensive to send [first,last) twice
|
| 106 |
+
// we should probably specialize this case for POD
|
| 107 |
+
// since we can safely keep the input in a temporary instead
|
| 108 |
+
// of doing two loads
|
| 109 |
+
return thrust::copy_if(exec, first, last, first, result, pred);
|
| 110 |
+
} // end copy_if()
|
| 111 |
+
|
| 112 |
+
template <typename DerivedPolicy,
|
| 113 |
+
typename InputIterator1,
|
| 114 |
+
typename InputIterator2,
|
| 115 |
+
typename OutputIterator,
|
| 116 |
+
typename Predicate>
|
| 117 |
+
_CCCL_HOST_DEVICE OutputIterator copy_if(
|
| 118 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 119 |
+
InputIterator1 first,
|
| 120 |
+
InputIterator1 last,
|
| 121 |
+
InputIterator2 stencil,
|
| 122 |
+
OutputIterator result,
|
| 123 |
+
Predicate pred)
|
| 124 |
+
{
|
| 125 |
+
using difference_type = typename thrust::iterator_traits<InputIterator1>::difference_type;
|
| 126 |
+
|
| 127 |
+
// empty sequence
|
| 128 |
+
if (first == last)
|
| 129 |
+
{
|
| 130 |
+
return result;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
difference_type n = thrust::distance(first, last);
|
| 134 |
+
|
| 135 |
+
// create an unsigned version of n (we know n is positive from the comparison above)
|
| 136 |
+
// to avoid a warning in the compare below
|
| 137 |
+
::cuda::std::make_unsigned_t<difference_type> unsigned_n(n);
|
| 138 |
+
|
| 139 |
+
// use 32-bit indices when possible (almost always)
|
| 140 |
+
if (sizeof(difference_type) > sizeof(unsigned int)
|
| 141 |
+
&& unsigned_n > thrust::detail::integer_traits<unsigned int>::const_max)
|
| 142 |
+
{
|
| 143 |
+
result = detail::copy_if<difference_type>(exec, first, last, stencil, result, pred);
|
| 144 |
+
} // end if
|
| 145 |
+
else
|
| 146 |
+
{
|
| 147 |
+
result = detail::copy_if<unsigned int>(exec, first, last, stencil, result, pred);
|
| 148 |
+
} // end else
|
| 149 |
+
|
| 150 |
+
return result;
|
| 151 |
+
} // end copy_if()
|
| 152 |
+
|
| 153 |
+
} // end namespace generic
|
| 154 |
+
} // end namespace detail
|
| 155 |
+
} // end namespace system
|
| 156 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/count.h
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/system/detail/generic/tag.h>
|
| 29 |
+
|
| 30 |
+
THRUST_NAMESPACE_BEGIN
|
| 31 |
+
namespace system
|
| 32 |
+
{
|
| 33 |
+
namespace detail
|
| 34 |
+
{
|
| 35 |
+
namespace generic
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
template <typename DerivedPolicy, typename InputIterator, typename EqualityComparable>
|
| 39 |
+
_CCCL_HOST_DEVICE typename thrust::iterator_traits<InputIterator>::difference_type
|
| 40 |
+
count(thrust::execution_policy<DerivedPolicy>& exec,
|
| 41 |
+
InputIterator first,
|
| 42 |
+
InputIterator last,
|
| 43 |
+
const EqualityComparable& value);
|
| 44 |
+
|
| 45 |
+
template <typename DerivedPolicy, typename InputIterator, typename Predicate>
|
| 46 |
+
_CCCL_HOST_DEVICE typename thrust::iterator_traits<InputIterator>::difference_type
|
| 47 |
+
count_if(thrust::execution_policy<DerivedPolicy>& exec, InputIterator first, InputIterator last, Predicate pred);
|
| 48 |
+
|
| 49 |
+
} // end namespace generic
|
| 50 |
+
} // end namespace detail
|
| 51 |
+
} // end namespace system
|
| 52 |
+
THRUST_NAMESPACE_END
|
| 53 |
+
|
| 54 |
+
#include <thrust/system/detail/generic/count.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/distance.h
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 29 |
+
|
| 30 |
+
THRUST_NAMESPACE_BEGIN
|
| 31 |
+
namespace system
|
| 32 |
+
{
|
| 33 |
+
namespace detail
|
| 34 |
+
{
|
| 35 |
+
namespace generic
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
template <typename InputIterator>
|
| 39 |
+
inline _CCCL_HOST_DEVICE typename thrust::iterator_traits<InputIterator>::difference_type
|
| 40 |
+
distance(InputIterator first, InputIterator last);
|
| 41 |
+
|
| 42 |
+
} // end namespace generic
|
| 43 |
+
} // end namespace detail
|
| 44 |
+
} // end namespace system
|
| 45 |
+
THRUST_NAMESPACE_END
|
| 46 |
+
|
| 47 |
+
#include <thrust/system/detail/generic/distance.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/distance.inl
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 29 |
+
#include <thrust/system/detail/generic/distance.h>
|
| 30 |
+
|
| 31 |
+
THRUST_NAMESPACE_BEGIN
|
| 32 |
+
namespace system
|
| 33 |
+
{
|
| 34 |
+
namespace detail
|
| 35 |
+
{
|
| 36 |
+
namespace generic
|
| 37 |
+
{
|
| 38 |
+
namespace detail
|
| 39 |
+
{
|
| 40 |
+
|
| 41 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 42 |
+
template <typename InputIterator>
|
| 43 |
+
inline _CCCL_HOST_DEVICE typename thrust::iterator_traits<InputIterator>::difference_type
|
| 44 |
+
distance(InputIterator first, InputIterator last, thrust::incrementable_traversal_tag)
|
| 45 |
+
{
|
| 46 |
+
typename thrust::iterator_traits<InputIterator>::difference_type result(0);
|
| 47 |
+
|
| 48 |
+
while (first != last)
|
| 49 |
+
{
|
| 50 |
+
++first;
|
| 51 |
+
++result;
|
| 52 |
+
} // end while
|
| 53 |
+
|
| 54 |
+
return result;
|
| 55 |
+
} // end advance()
|
| 56 |
+
|
| 57 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 58 |
+
template <typename InputIterator>
|
| 59 |
+
inline _CCCL_HOST_DEVICE typename thrust::iterator_traits<InputIterator>::difference_type
|
| 60 |
+
distance(InputIterator first, InputIterator last, thrust::random_access_traversal_tag)
|
| 61 |
+
{
|
| 62 |
+
return last - first;
|
| 63 |
+
} // end distance()
|
| 64 |
+
|
| 65 |
+
} // namespace detail
|
| 66 |
+
|
| 67 |
+
_CCCL_EXEC_CHECK_DISABLE
|
| 68 |
+
template <typename InputIterator>
|
| 69 |
+
inline _CCCL_HOST_DEVICE typename thrust::iterator_traits<InputIterator>::difference_type
|
| 70 |
+
distance(InputIterator first, InputIterator last)
|
| 71 |
+
{
|
| 72 |
+
// dispatch on iterator traversal
|
| 73 |
+
return thrust::system::detail::generic::detail::distance(
|
| 74 |
+
first, last, typename thrust::iterator_traversal<InputIterator>::type());
|
| 75 |
+
} // end advance()
|
| 76 |
+
|
| 77 |
+
} // end namespace generic
|
| 78 |
+
} // end namespace detail
|
| 79 |
+
} // end namespace system
|
| 80 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/extrema.inl
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
/*! \file distance.h
|
| 18 |
+
* \brief Device implementations for distance.
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
#pragma once
|
| 22 |
+
|
| 23 |
+
#include <thrust/detail/config.h>
|
| 24 |
+
|
| 25 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 26 |
+
# pragma GCC system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 28 |
+
# pragma clang system_header
|
| 29 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 30 |
+
# pragma system_header
|
| 31 |
+
#endif // no system header
|
| 32 |
+
#include <thrust/detail/get_iterator_value.h>
|
| 33 |
+
#include <thrust/extrema.h>
|
| 34 |
+
#include <thrust/functional.h>
|
| 35 |
+
#include <thrust/iterator/counting_iterator.h>
|
| 36 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 37 |
+
#include <thrust/iterator/zip_iterator.h>
|
| 38 |
+
#include <thrust/pair.h>
|
| 39 |
+
#include <thrust/reduce.h>
|
| 40 |
+
#include <thrust/transform_reduce.h>
|
| 41 |
+
|
| 42 |
+
THRUST_NAMESPACE_BEGIN
|
| 43 |
+
namespace system
|
| 44 |
+
{
|
| 45 |
+
namespace detail
|
| 46 |
+
{
|
| 47 |
+
namespace generic
|
| 48 |
+
{
|
| 49 |
+
namespace detail
|
| 50 |
+
{
|
| 51 |
+
|
| 52 |
+
//////////////
|
| 53 |
+
// Functors //
|
| 54 |
+
//////////////
|
| 55 |
+
//
|
| 56 |
+
|
| 57 |
+
// return the smaller/larger element making sure to prefer the
|
| 58 |
+
// first occurrence of the minimum/maximum element
|
| 59 |
+
template <typename InputType, typename IndexType, typename BinaryPredicate>
|
| 60 |
+
struct min_element_reduction
|
| 61 |
+
{
|
| 62 |
+
BinaryPredicate comp;
|
| 63 |
+
|
| 64 |
+
_CCCL_HOST_DEVICE min_element_reduction(BinaryPredicate comp)
|
| 65 |
+
: comp(comp)
|
| 66 |
+
{}
|
| 67 |
+
|
| 68 |
+
_CCCL_HOST_DEVICE thrust::tuple<InputType, IndexType>
|
| 69 |
+
operator()(const thrust::tuple<InputType, IndexType>& lhs, const thrust::tuple<InputType, IndexType>& rhs)
|
| 70 |
+
{
|
| 71 |
+
if (comp(thrust::get<0>(lhs), thrust::get<0>(rhs)))
|
| 72 |
+
{
|
| 73 |
+
return lhs;
|
| 74 |
+
}
|
| 75 |
+
if (comp(thrust::get<0>(rhs), thrust::get<0>(lhs)))
|
| 76 |
+
{
|
| 77 |
+
return rhs;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
// values are equivalent, prefer value with smaller index
|
| 81 |
+
if (thrust::get<1>(lhs) < thrust::get<1>(rhs))
|
| 82 |
+
{
|
| 83 |
+
return lhs;
|
| 84 |
+
}
|
| 85 |
+
else
|
| 86 |
+
{
|
| 87 |
+
return rhs;
|
| 88 |
+
}
|
| 89 |
+
} // end operator()()
|
| 90 |
+
}; // end min_element_reduction
|
| 91 |
+
|
| 92 |
+
template <typename InputType, typename IndexType, typename BinaryPredicate>
|
| 93 |
+
struct max_element_reduction
|
| 94 |
+
{
|
| 95 |
+
BinaryPredicate comp;
|
| 96 |
+
|
| 97 |
+
_CCCL_HOST_DEVICE max_element_reduction(BinaryPredicate comp)
|
| 98 |
+
: comp(comp)
|
| 99 |
+
{}
|
| 100 |
+
|
| 101 |
+
_CCCL_HOST_DEVICE thrust::tuple<InputType, IndexType>
|
| 102 |
+
operator()(const thrust::tuple<InputType, IndexType>& lhs, const thrust::tuple<InputType, IndexType>& rhs)
|
| 103 |
+
{
|
| 104 |
+
if (comp(thrust::get<0>(lhs), thrust::get<0>(rhs)))
|
| 105 |
+
{
|
| 106 |
+
return rhs;
|
| 107 |
+
}
|
| 108 |
+
if (comp(thrust::get<0>(rhs), thrust::get<0>(lhs)))
|
| 109 |
+
{
|
| 110 |
+
return lhs;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
// values are equivalent, prefer value with smaller index
|
| 114 |
+
if (thrust::get<1>(lhs) < thrust::get<1>(rhs))
|
| 115 |
+
{
|
| 116 |
+
return lhs;
|
| 117 |
+
}
|
| 118 |
+
else
|
| 119 |
+
{
|
| 120 |
+
return rhs;
|
| 121 |
+
}
|
| 122 |
+
} // end operator()()
|
| 123 |
+
}; // end max_element_reduction
|
| 124 |
+
|
| 125 |
+
// return the smaller & larger element making sure to prefer the
|
| 126 |
+
// first occurrence of the minimum/maximum element
|
| 127 |
+
template <typename InputType, typename IndexType, typename BinaryPredicate>
|
| 128 |
+
struct minmax_element_reduction
|
| 129 |
+
{
|
| 130 |
+
BinaryPredicate comp;
|
| 131 |
+
|
| 132 |
+
_CCCL_HOST_DEVICE minmax_element_reduction(BinaryPredicate comp)
|
| 133 |
+
: comp(comp)
|
| 134 |
+
{}
|
| 135 |
+
|
| 136 |
+
_CCCL_HOST_DEVICE thrust::tuple<thrust::tuple<InputType, IndexType>, thrust::tuple<InputType, IndexType>>
|
| 137 |
+
operator()(const thrust::tuple<thrust::tuple<InputType, IndexType>, thrust::tuple<InputType, IndexType>>& lhs,
|
| 138 |
+
const thrust::tuple<thrust::tuple<InputType, IndexType>, thrust::tuple<InputType, IndexType>>& rhs)
|
| 139 |
+
{
|
| 140 |
+
return thrust::make_tuple(
|
| 141 |
+
min_element_reduction<InputType, IndexType, BinaryPredicate>(comp)(thrust::get<0>(lhs), thrust::get<0>(rhs)),
|
| 142 |
+
max_element_reduction<InputType, IndexType, BinaryPredicate>(comp)(thrust::get<1>(lhs), thrust::get<1>(rhs)));
|
| 143 |
+
} // end operator()()
|
| 144 |
+
}; // end minmax_element_reduction
|
| 145 |
+
|
| 146 |
+
template <typename InputType, typename IndexType>
|
| 147 |
+
struct duplicate_tuple
|
| 148 |
+
{
|
| 149 |
+
_CCCL_HOST_DEVICE thrust::tuple<thrust::tuple<InputType, IndexType>, thrust::tuple<InputType, IndexType>>
|
| 150 |
+
operator()(const thrust::tuple<InputType, IndexType>& t)
|
| 151 |
+
{
|
| 152 |
+
return thrust::make_tuple(t, t);
|
| 153 |
+
}
|
| 154 |
+
}; // end duplicate_tuple
|
| 155 |
+
|
| 156 |
+
} // end namespace detail
|
| 157 |
+
|
| 158 |
+
template <typename DerivedPolicy, typename ForwardIterator>
|
| 159 |
+
_CCCL_HOST_DEVICE ForwardIterator
|
| 160 |
+
min_element(thrust::execution_policy<DerivedPolicy>& exec, ForwardIterator first, ForwardIterator last)
|
| 161 |
+
{
|
| 162 |
+
using value_type = typename thrust::iterator_value<ForwardIterator>::type;
|
| 163 |
+
|
| 164 |
+
return thrust::min_element(exec, first, last, thrust::less<value_type>());
|
| 165 |
+
} // end min_element()
|
| 166 |
+
|
| 167 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename BinaryPredicate>
|
| 168 |
+
_CCCL_HOST_DEVICE ForwardIterator min_element(
|
| 169 |
+
thrust::execution_policy<DerivedPolicy>& exec, ForwardIterator first, ForwardIterator last, BinaryPredicate comp)
|
| 170 |
+
{
|
| 171 |
+
if (first == last)
|
| 172 |
+
{
|
| 173 |
+
return last;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
using InputType = typename thrust::iterator_traits<ForwardIterator>::value_type;
|
| 177 |
+
using IndexType = typename thrust::iterator_traits<ForwardIterator>::difference_type;
|
| 178 |
+
|
| 179 |
+
thrust::tuple<InputType, IndexType> result = thrust::reduce(
|
| 180 |
+
exec,
|
| 181 |
+
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))),
|
| 182 |
+
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))) + (last - first),
|
| 183 |
+
thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec), first), 0),
|
| 184 |
+
detail::min_element_reduction<InputType, IndexType, BinaryPredicate>(comp));
|
| 185 |
+
|
| 186 |
+
return first + thrust::get<1>(result);
|
| 187 |
+
} // end min_element()
|
| 188 |
+
|
| 189 |
+
template <typename DerivedPolicy, typename ForwardIterator>
|
| 190 |
+
_CCCL_HOST_DEVICE ForwardIterator
|
| 191 |
+
max_element(thrust::execution_policy<DerivedPolicy>& exec, ForwardIterator first, ForwardIterator last)
|
| 192 |
+
{
|
| 193 |
+
using value_type = typename thrust::iterator_value<ForwardIterator>::type;
|
| 194 |
+
|
| 195 |
+
return thrust::max_element(exec, first, last, thrust::less<value_type>());
|
| 196 |
+
} // end max_element()
|
| 197 |
+
|
| 198 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename BinaryPredicate>
|
| 199 |
+
_CCCL_HOST_DEVICE ForwardIterator max_element(
|
| 200 |
+
thrust::execution_policy<DerivedPolicy>& exec, ForwardIterator first, ForwardIterator last, BinaryPredicate comp)
|
| 201 |
+
{
|
| 202 |
+
if (first == last)
|
| 203 |
+
{
|
| 204 |
+
return last;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
using InputType = typename thrust::iterator_traits<ForwardIterator>::value_type;
|
| 208 |
+
using IndexType = typename thrust::iterator_traits<ForwardIterator>::difference_type;
|
| 209 |
+
|
| 210 |
+
thrust::tuple<InputType, IndexType> result = thrust::reduce(
|
| 211 |
+
exec,
|
| 212 |
+
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))),
|
| 213 |
+
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))) + (last - first),
|
| 214 |
+
thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec), first), 0),
|
| 215 |
+
detail::max_element_reduction<InputType, IndexType, BinaryPredicate>(comp));
|
| 216 |
+
|
| 217 |
+
return first + thrust::get<1>(result);
|
| 218 |
+
} // end max_element()
|
| 219 |
+
|
| 220 |
+
template <typename DerivedPolicy, typename ForwardIterator>
|
| 221 |
+
_CCCL_HOST_DEVICE thrust::pair<ForwardIterator, ForwardIterator>
|
| 222 |
+
minmax_element(thrust::execution_policy<DerivedPolicy>& exec, ForwardIterator first, ForwardIterator last)
|
| 223 |
+
{
|
| 224 |
+
using value_type = typename thrust::iterator_value<ForwardIterator>::type;
|
| 225 |
+
|
| 226 |
+
return thrust::minmax_element(exec, first, last, thrust::less<value_type>());
|
| 227 |
+
} // end minmax_element()
|
| 228 |
+
|
| 229 |
+
template <typename DerivedPolicy, typename ForwardIterator, typename BinaryPredicate>
|
| 230 |
+
_CCCL_HOST_DEVICE thrust::pair<ForwardIterator, ForwardIterator> minmax_element(
|
| 231 |
+
thrust::execution_policy<DerivedPolicy>& exec, ForwardIterator first, ForwardIterator last, BinaryPredicate comp)
|
| 232 |
+
{
|
| 233 |
+
if (first == last)
|
| 234 |
+
{
|
| 235 |
+
return thrust::make_pair(last, last);
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
using InputType = typename thrust::iterator_traits<ForwardIterator>::value_type;
|
| 239 |
+
using IndexType = typename thrust::iterator_traits<ForwardIterator>::difference_type;
|
| 240 |
+
|
| 241 |
+
thrust::tuple<thrust::tuple<InputType, IndexType>, thrust::tuple<InputType, IndexType>> result =
|
| 242 |
+
thrust::transform_reduce(
|
| 243 |
+
exec,
|
| 244 |
+
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))),
|
| 245 |
+
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))) + (last - first),
|
| 246 |
+
detail::duplicate_tuple<InputType, IndexType>(),
|
| 247 |
+
detail::duplicate_tuple<InputType, IndexType>()(
|
| 248 |
+
thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec), first), 0)),
|
| 249 |
+
detail::minmax_element_reduction<InputType, IndexType, BinaryPredicate>(comp));
|
| 250 |
+
|
| 251 |
+
return thrust::make_pair(first + thrust::get<1>(thrust::get<0>(result)),
|
| 252 |
+
first + thrust::get<1>(thrust::get<1>(result)));
|
| 253 |
+
} // end minmax_element()
|
| 254 |
+
|
| 255 |
+
} // end namespace generic
|
| 256 |
+
} // end namespace detail
|
| 257 |
+
} // end namespace system
|
| 258 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/find.h
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/system/detail/generic/tag.h>
|
| 29 |
+
|
| 30 |
+
THRUST_NAMESPACE_BEGIN
|
| 31 |
+
namespace system
|
| 32 |
+
{
|
| 33 |
+
namespace detail
|
| 34 |
+
{
|
| 35 |
+
namespace generic
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
template <typename DerivedPolicy, typename InputIterator, typename T>
|
| 39 |
+
_CCCL_HOST_DEVICE InputIterator
|
| 40 |
+
find(thrust::execution_policy<DerivedPolicy>& exec, InputIterator first, InputIterator last, const T& value);
|
| 41 |
+
|
| 42 |
+
template <typename DerivedPolicy, typename InputIterator, typename Predicate>
|
| 43 |
+
_CCCL_HOST_DEVICE InputIterator
|
| 44 |
+
find_if(thrust::execution_policy<DerivedPolicy>& exec, InputIterator first, InputIterator last, Predicate pred);
|
| 45 |
+
|
| 46 |
+
template <typename DerivedPolicy, typename InputIterator, typename Predicate>
|
| 47 |
+
_CCCL_HOST_DEVICE InputIterator
|
| 48 |
+
find_if_not(thrust::execution_policy<DerivedPolicy>& exec, InputIterator first, InputIterator last, Predicate pred);
|
| 49 |
+
|
| 50 |
+
} // end namespace generic
|
| 51 |
+
} // end namespace detail
|
| 52 |
+
} // end namespace system
|
| 53 |
+
THRUST_NAMESPACE_END
|
| 54 |
+
|
| 55 |
+
#include <thrust/system/detail/generic/find.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/for_each.h
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
/*! \file for_each.h
|
| 18 |
+
* \brief Generic implementation of for_each & for_each_n.
|
| 19 |
+
* It is an error to call these functions; they have no implementation.
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
#pragma once
|
| 23 |
+
|
| 24 |
+
#include <thrust/detail/config.h>
|
| 25 |
+
|
| 26 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 27 |
+
# pragma GCC system_header
|
| 28 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 29 |
+
# pragma clang system_header
|
| 30 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 31 |
+
# pragma system_header
|
| 32 |
+
#endif // no system header
|
| 33 |
+
#include <thrust/detail/execution_policy.h>
|
| 34 |
+
#include <thrust/detail/static_assert.h>
|
| 35 |
+
#include <thrust/system/detail/generic/tag.h>
|
| 36 |
+
|
| 37 |
+
THRUST_NAMESPACE_BEGIN
|
| 38 |
+
namespace system
|
| 39 |
+
{
|
| 40 |
+
namespace detail
|
| 41 |
+
{
|
| 42 |
+
namespace generic
|
| 43 |
+
{
|
| 44 |
+
|
| 45 |
+
template <typename DerivedPolicy, typename InputIterator, typename UnaryFunction>
|
| 46 |
+
_CCCL_HOST_DEVICE InputIterator
|
| 47 |
+
for_each(thrust::execution_policy<DerivedPolicy>&, InputIterator first, InputIterator, UnaryFunction)
|
| 48 |
+
{
|
| 49 |
+
THRUST_STATIC_ASSERT_MSG((thrust::detail::depend_on_instantiation<InputIterator, false>::value),
|
| 50 |
+
"unimplemented for this system");
|
| 51 |
+
return first;
|
| 52 |
+
} // end for_each()
|
| 53 |
+
|
| 54 |
+
template <typename DerivedPolicy, typename InputIterator, typename Size, typename UnaryFunction>
|
| 55 |
+
_CCCL_HOST_DEVICE InputIterator
|
| 56 |
+
for_each_n(thrust::execution_policy<DerivedPolicy>&, InputIterator first, Size, UnaryFunction)
|
| 57 |
+
{
|
| 58 |
+
THRUST_STATIC_ASSERT_MSG((thrust::detail::depend_on_instantiation<InputIterator, false>::value),
|
| 59 |
+
"unimplemented for this system");
|
| 60 |
+
return first;
|
| 61 |
+
} // end for_each_n()
|
| 62 |
+
|
| 63 |
+
} // end namespace generic
|
| 64 |
+
} // end namespace detail
|
| 65 |
+
} // end namespace system
|
| 66 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/gather.h
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/system/detail/generic/tag.h>
|
| 29 |
+
|
| 30 |
+
THRUST_NAMESPACE_BEGIN
|
| 31 |
+
namespace system
|
| 32 |
+
{
|
| 33 |
+
namespace detail
|
| 34 |
+
{
|
| 35 |
+
namespace generic
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
template <typename DerivedPolicy, typename InputIterator, typename RandomAccessIterator, typename OutputIterator>
|
| 39 |
+
_CCCL_HOST_DEVICE OutputIterator gather(
|
| 40 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 41 |
+
InputIterator map_first,
|
| 42 |
+
InputIterator map_last,
|
| 43 |
+
RandomAccessIterator input_first,
|
| 44 |
+
OutputIterator result);
|
| 45 |
+
|
| 46 |
+
template <typename DerivedPolicy,
|
| 47 |
+
typename InputIterator1,
|
| 48 |
+
typename InputIterator2,
|
| 49 |
+
typename RandomAccessIterator,
|
| 50 |
+
typename OutputIterator>
|
| 51 |
+
_CCCL_HOST_DEVICE OutputIterator gather_if(
|
| 52 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 53 |
+
InputIterator1 map_first,
|
| 54 |
+
InputIterator1 map_last,
|
| 55 |
+
InputIterator2 stencil,
|
| 56 |
+
RandomAccessIterator input_first,
|
| 57 |
+
OutputIterator result);
|
| 58 |
+
|
| 59 |
+
template <typename DerivedPolicy,
|
| 60 |
+
typename InputIterator1,
|
| 61 |
+
typename InputIterator2,
|
| 62 |
+
typename RandomAccessIterator,
|
| 63 |
+
typename OutputIterator,
|
| 64 |
+
typename Predicate>
|
| 65 |
+
_CCCL_HOST_DEVICE OutputIterator gather_if(
|
| 66 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 67 |
+
InputIterator1 map_first,
|
| 68 |
+
InputIterator1 map_last,
|
| 69 |
+
InputIterator2 stencil,
|
| 70 |
+
RandomAccessIterator input_first,
|
| 71 |
+
OutputIterator result,
|
| 72 |
+
Predicate pred);
|
| 73 |
+
|
| 74 |
+
} // end namespace generic
|
| 75 |
+
} // end namespace detail
|
| 76 |
+
} // end namespace system
|
| 77 |
+
THRUST_NAMESPACE_END
|
| 78 |
+
|
| 79 |
+
#include <thrust/system/detail/generic/gather.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/gather.inl
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/functional.h>
|
| 29 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 30 |
+
#include <thrust/iterator/permutation_iterator.h>
|
| 31 |
+
#include <thrust/system/detail/generic/gather.h>
|
| 32 |
+
#include <thrust/transform.h>
|
| 33 |
+
|
| 34 |
+
THRUST_NAMESPACE_BEGIN
|
| 35 |
+
namespace system
|
| 36 |
+
{
|
| 37 |
+
namespace detail
|
| 38 |
+
{
|
| 39 |
+
namespace generic
|
| 40 |
+
{
|
| 41 |
+
|
| 42 |
+
template <typename DerivedPolicy, typename InputIterator, typename RandomAccessIterator, typename OutputIterator>
|
| 43 |
+
_CCCL_HOST_DEVICE OutputIterator gather(
|
| 44 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 45 |
+
InputIterator map_first,
|
| 46 |
+
InputIterator map_last,
|
| 47 |
+
RandomAccessIterator input_first,
|
| 48 |
+
OutputIterator result)
|
| 49 |
+
{
|
| 50 |
+
return thrust::transform(
|
| 51 |
+
exec,
|
| 52 |
+
thrust::make_permutation_iterator(input_first, map_first),
|
| 53 |
+
thrust::make_permutation_iterator(input_first, map_last),
|
| 54 |
+
result,
|
| 55 |
+
thrust::identity<typename thrust::iterator_value<RandomAccessIterator>::type>());
|
| 56 |
+
} // end gather()
|
| 57 |
+
|
| 58 |
+
template <typename DerivedPolicy,
|
| 59 |
+
typename InputIterator1,
|
| 60 |
+
typename InputIterator2,
|
| 61 |
+
typename RandomAccessIterator,
|
| 62 |
+
typename OutputIterator>
|
| 63 |
+
_CCCL_HOST_DEVICE OutputIterator gather_if(
|
| 64 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 65 |
+
InputIterator1 map_first,
|
| 66 |
+
InputIterator1 map_last,
|
| 67 |
+
InputIterator2 stencil,
|
| 68 |
+
RandomAccessIterator input_first,
|
| 69 |
+
OutputIterator result)
|
| 70 |
+
{
|
| 71 |
+
using StencilType = typename thrust::iterator_value<InputIterator2>::type;
|
| 72 |
+
return thrust::gather_if(exec, map_first, map_last, stencil, input_first, result, thrust::identity<StencilType>());
|
| 73 |
+
} // end gather_if()
|
| 74 |
+
|
| 75 |
+
template <typename DerivedPolicy,
|
| 76 |
+
typename InputIterator1,
|
| 77 |
+
typename InputIterator2,
|
| 78 |
+
typename RandomAccessIterator,
|
| 79 |
+
typename OutputIterator,
|
| 80 |
+
typename Predicate>
|
| 81 |
+
_CCCL_HOST_DEVICE OutputIterator gather_if(
|
| 82 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 83 |
+
InputIterator1 map_first,
|
| 84 |
+
InputIterator1 map_last,
|
| 85 |
+
InputIterator2 stencil,
|
| 86 |
+
RandomAccessIterator input_first,
|
| 87 |
+
OutputIterator result,
|
| 88 |
+
Predicate pred)
|
| 89 |
+
{
|
| 90 |
+
using InputType = typename thrust::iterator_value<RandomAccessIterator>::type;
|
| 91 |
+
return thrust::transform_if(
|
| 92 |
+
exec,
|
| 93 |
+
thrust::make_permutation_iterator(input_first, map_first),
|
| 94 |
+
thrust::make_permutation_iterator(input_first, map_last),
|
| 95 |
+
stencil,
|
| 96 |
+
result,
|
| 97 |
+
thrust::identity<InputType>(),
|
| 98 |
+
pred);
|
| 99 |
+
} // end gather_if()
|
| 100 |
+
|
| 101 |
+
} // end namespace generic
|
| 102 |
+
} // end namespace detail
|
| 103 |
+
} // end namespace system
|
| 104 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/generate.h
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/system/detail/generic/tag.h>
|
| 29 |
+
|
| 30 |
+
THRUST_NAMESPACE_BEGIN
|
| 31 |
+
namespace system
|
| 32 |
+
{
|
| 33 |
+
namespace detail
|
| 34 |
+
{
|
| 35 |
+
namespace generic
|
| 36 |
+
{
|
| 37 |
+
|
| 38 |
+
template <typename ExecutionPolicy, typename ForwardIterator, typename Generator>
|
| 39 |
+
_CCCL_HOST_DEVICE void
|
| 40 |
+
generate(thrust::execution_policy<ExecutionPolicy>& exec, ForwardIterator first, ForwardIterator last, Generator gen);
|
| 41 |
+
|
| 42 |
+
template <typename ExecutionPolicy, typename OutputIterator, typename Size, typename Generator>
|
| 43 |
+
_CCCL_HOST_DEVICE OutputIterator
|
| 44 |
+
generate_n(thrust::execution_policy<ExecutionPolicy>& exec, OutputIterator first, Size n, Generator gen);
|
| 45 |
+
|
| 46 |
+
} // end namespace generic
|
| 47 |
+
} // end namespace detail
|
| 48 |
+
} // end namespace system
|
| 49 |
+
THRUST_NAMESPACE_END
|
| 50 |
+
|
| 51 |
+
#include <thrust/system/detail/generic/generate.inl>
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/generate.inl
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/internal_functional.h>
|
| 29 |
+
#include <thrust/detail/static_assert.h>
|
| 30 |
+
#include <thrust/for_each.h>
|
| 31 |
+
#include <thrust/iterator/iterator_traits.h>
|
| 32 |
+
#include <thrust/system/detail/generic/generate.h>
|
| 33 |
+
|
| 34 |
+
THRUST_NAMESPACE_BEGIN
|
| 35 |
+
namespace system
|
| 36 |
+
{
|
| 37 |
+
namespace detail
|
| 38 |
+
{
|
| 39 |
+
namespace generic
|
| 40 |
+
{
|
| 41 |
+
|
| 42 |
+
template <typename ExecutionPolicy, typename ForwardIterator, typename Generator>
|
| 43 |
+
_CCCL_HOST_DEVICE void
|
| 44 |
+
generate(thrust::execution_policy<ExecutionPolicy>& exec, ForwardIterator first, ForwardIterator last, Generator gen)
|
| 45 |
+
{
|
| 46 |
+
// this static assert is necessary due to a workaround in generate_functor
|
| 47 |
+
// it takes a const reference to accept temporaries from proxy iterators
|
| 48 |
+
// and then const_casts the constness away
|
| 49 |
+
//
|
| 50 |
+
// this had the weird side effect of allowing generate (and fill, and whatever
|
| 51 |
+
// else is implemented in terms of generate) to fill through const iterators.
|
| 52 |
+
// this might become unnecessary once Thrust is C++11-and-above only, since the
|
| 53 |
+
// other solution is to take an rvalue reference in a second overload of
|
| 54 |
+
// operator() of the function object, but until we support pre-11, this is a
|
| 55 |
+
// nice solution that validates the const_cast and doesn't take away any
|
| 56 |
+
// functionality.
|
| 57 |
+
THRUST_STATIC_ASSERT_MSG(
|
| 58 |
+
!::cuda::std::is_const<
|
| 59 |
+
::cuda::std::remove_reference_t<typename thrust::iterator_traits<ForwardIterator>::reference>>::value,
|
| 60 |
+
"generating to `const` iterators is not allowed");
|
| 61 |
+
thrust::for_each(exec, first, last, typename thrust::detail::generate_functor<ExecutionPolicy, Generator>::type(gen));
|
| 62 |
+
} // end generate()
|
| 63 |
+
|
| 64 |
+
template <typename ExecutionPolicy, typename OutputIterator, typename Size, typename Generator>
|
| 65 |
+
_CCCL_HOST_DEVICE OutputIterator
|
| 66 |
+
generate_n(thrust::execution_policy<ExecutionPolicy>& exec, OutputIterator first, Size n, Generator gen)
|
| 67 |
+
{
|
| 68 |
+
// this static assert is necessary due to a workaround in generate_functor
|
| 69 |
+
// it takes a const reference to accept temporaries from proxy iterators
|
| 70 |
+
// and then const_casts the constness away
|
| 71 |
+
//
|
| 72 |
+
// this had the weird side effect of allowing generate (and fill, and whatever
|
| 73 |
+
// else is implemented in terms of generate) to fill through const iterators.
|
| 74 |
+
// this might become unnecessary once Thrust is C++11-and-above only, since the
|
| 75 |
+
// other solution is to take an rvalue reference in a second overload of
|
| 76 |
+
// operator() of the function object, but until we support pre-11, this is a
|
| 77 |
+
// nice solution that validates the const_cast and doesn't take away any
|
| 78 |
+
// functionality.
|
| 79 |
+
THRUST_STATIC_ASSERT_MSG(
|
| 80 |
+
!::cuda::std::is_const<
|
| 81 |
+
::cuda::std::remove_reference_t<typename thrust::iterator_traits<OutputIterator>::reference>>::value,
|
| 82 |
+
"generating to `const` iterators is not allowed");
|
| 83 |
+
return thrust::for_each_n(
|
| 84 |
+
exec, first, n, typename thrust::detail::generate_functor<ExecutionPolicy, Generator>::type(gen));
|
| 85 |
+
} // end generate()
|
| 86 |
+
|
| 87 |
+
} // end namespace generic
|
| 88 |
+
} // end namespace detail
|
| 89 |
+
} // end namespace system
|
| 90 |
+
THRUST_NAMESPACE_END
|
vllm/lib/python3.10/site-packages/cupy/_core/include/cupy/_cccl/thrust/thrust/system/detail/generic/inner_product.inl
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2008-2013 NVIDIA Corporation
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
* you may not use this file except in compliance with the License.
|
| 6 |
+
* You may obtain a copy of the License at
|
| 7 |
+
*
|
| 8 |
+
* http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
*
|
| 10 |
+
* Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
* See the License for the specific language governing permissions and
|
| 14 |
+
* limitations under the License.
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
#pragma once
|
| 18 |
+
|
| 19 |
+
#include <thrust/detail/config.h>
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
#include <thrust/detail/internal_functional.h>
|
| 29 |
+
#include <thrust/functional.h>
|
| 30 |
+
#include <thrust/system/detail/generic/inner_product.h>
|
| 31 |
+
#include <thrust/transform_reduce.h>
|
| 32 |
+
#include <thrust/zip_function.h>
|
| 33 |
+
|
| 34 |
+
THRUST_NAMESPACE_BEGIN
|
| 35 |
+
namespace system
|
| 36 |
+
{
|
| 37 |
+
namespace detail
|
| 38 |
+
{
|
| 39 |
+
namespace generic
|
| 40 |
+
{
|
| 41 |
+
|
| 42 |
+
template <typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputType>
|
| 43 |
+
_CCCL_HOST_DEVICE OutputType inner_product(
|
| 44 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 45 |
+
InputIterator1 first1,
|
| 46 |
+
InputIterator1 last1,
|
| 47 |
+
InputIterator2 first2,
|
| 48 |
+
OutputType init)
|
| 49 |
+
{
|
| 50 |
+
thrust::plus<OutputType> binary_op1;
|
| 51 |
+
thrust::multiplies<OutputType> binary_op2;
|
| 52 |
+
return thrust::inner_product(exec, first1, last1, first2, init, binary_op1, binary_op2);
|
| 53 |
+
} // end inner_product()
|
| 54 |
+
|
| 55 |
+
template <typename DerivedPolicy,
|
| 56 |
+
typename InputIterator1,
|
| 57 |
+
typename InputIterator2,
|
| 58 |
+
typename OutputType,
|
| 59 |
+
typename BinaryFunction1,
|
| 60 |
+
typename BinaryFunction2>
|
| 61 |
+
_CCCL_HOST_DEVICE OutputType inner_product(
|
| 62 |
+
thrust::execution_policy<DerivedPolicy>& exec,
|
| 63 |
+
InputIterator1 first1,
|
| 64 |
+
InputIterator1 last1,
|
| 65 |
+
InputIterator2 first2,
|
| 66 |
+
OutputType init,
|
| 67 |
+
BinaryFunction1 binary_op1,
|
| 68 |
+
BinaryFunction2 binary_op2)
|
| 69 |
+
{
|
| 70 |
+
const auto first = thrust::make_zip_iterator(first1, first2);
|
| 71 |
+
const auto last = thrust::make_zip_iterator(last1, first2); // only first iterator matters
|
| 72 |
+
return thrust::transform_reduce(exec, first, last, thrust::make_zip_function(binary_op2), init, binary_op1);
|
| 73 |
+
} // end inner_product()
|
| 74 |
+
|
| 75 |
+
} // namespace generic
|
| 76 |
+
} // namespace detail
|
| 77 |
+
} // namespace system
|
| 78 |
+
THRUST_NAMESPACE_END
|