Datasets:
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 +5 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/1908303.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908284/1908284.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908252/1908252.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908290/1908290.tif +3 -0
- material/dataset/Datasets/Electron Microscopy Images/SEM/1908258.tif +3 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/__init__.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/autocompletion.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/base_command.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/cmdoptions.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/command_context.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/main_parser.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/parser.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/progress_bars.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/req_command.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/spinners.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/cmdoptions.py +1018 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/command_context.py +27 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/parser.py +292 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/req_command.py +506 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/check.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/completion.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/configuration.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/debug.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/download.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/index.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/install.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/list.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/show.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/wheel.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/candidate.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/index.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/scheme.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/selection_prefs.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/target_python.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/wheel.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/candidate.py +34 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/link.py +288 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/scheme.py +31 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/search_scope.py +129 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/network/__pycache__/lazy_wheel.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/network/__pycache__/session.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/__pycache__/__init__.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/__pycache__/check.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/__pycache__/freeze.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/__pycache__/prepare.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__init__.py +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/__init__.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/metadata_legacy.cpython-310.pyc +0 -0
- material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/wheel_editable.cpython-310.pyc +0 -0
.gitattributes
CHANGED
|
@@ -308,3 +308,8 @@ material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:
|
|
| 308 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908312/1908312.tif filter=lfs diff=lfs merge=lfs -text
|
| 309 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908250/1908250.tif filter=lfs diff=lfs merge=lfs -text
|
| 310 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908320/1908320.tif filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908312/1908312.tif filter=lfs diff=lfs merge=lfs -text
|
| 309 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908250/1908250.tif filter=lfs diff=lfs merge=lfs -text
|
| 310 |
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908320/1908320.tif filter=lfs diff=lfs merge=lfs -text
|
| 311 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/1908303.tif filter=lfs diff=lfs merge=lfs -text
|
| 312 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908252/1908252.tif filter=lfs diff=lfs merge=lfs -text
|
| 313 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Images/SEM/1908258.tif filter=lfs diff=lfs merge=lfs -text
|
| 314 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908284/1908284.tif filter=lfs diff=lfs merge=lfs -text
|
| 315 |
+
material/dataset/Datasets/Electron[[:space:]]Microscopy[[:space:]]Image[[:space:]]Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908290/1908290.tif filter=lfs diff=lfs merge=lfs -text
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/1908303.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Input/1908284/1908284.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908252/1908252.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Image Masks/TiO2_Masks_TSEM/Image_Registration/Output/1908290/1908290.tif
ADDED
|
|
Git LFS Details
|
material/dataset/Datasets/Electron Microscopy Images/SEM/1908258.tif
ADDED
|
|
Git LFS Details
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (323 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/autocompletion.cpython-310.pyc
ADDED
|
Binary file (5.36 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/base_command.cpython-310.pyc
ADDED
|
Binary file (6.3 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/cmdoptions.cpython-310.pyc
ADDED
|
Binary file (22.6 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/command_context.cpython-310.pyc
ADDED
|
Binary file (1.36 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/main_parser.cpython-310.pyc
ADDED
|
Binary file (2.21 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/parser.cpython-310.pyc
ADDED
|
Binary file (9.99 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/progress_bars.cpython-310.pyc
ADDED
|
Binary file (9.28 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/req_command.cpython-310.pyc
ADDED
|
Binary file (13.6 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/__pycache__/spinners.cpython-310.pyc
ADDED
|
Binary file (5 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/cmdoptions.py
ADDED
|
@@ -0,0 +1,1018 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
shared options and groups
|
| 3 |
+
|
| 4 |
+
The principle here is to define options once, but *not* instantiate them
|
| 5 |
+
globally. One reason being that options with action='append' can carry state
|
| 6 |
+
between parses. pip parses general options twice internally, and shouldn't
|
| 7 |
+
pass on state. To be consistent, all options will follow this design.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
# The following comment should be removed at some point in the future.
|
| 11 |
+
# mypy: strict-optional=False
|
| 12 |
+
|
| 13 |
+
import logging
|
| 14 |
+
import os
|
| 15 |
+
import textwrap
|
| 16 |
+
from functools import partial
|
| 17 |
+
from optparse import SUPPRESS_HELP, Option, OptionGroup, OptionParser, Values
|
| 18 |
+
from textwrap import dedent
|
| 19 |
+
from typing import Any, Callable, Dict, Optional, Tuple
|
| 20 |
+
|
| 21 |
+
from pip._vendor.packaging.utils import canonicalize_name
|
| 22 |
+
|
| 23 |
+
from pip._internal.cli.parser import ConfigOptionParser
|
| 24 |
+
from pip._internal.cli.progress_bars import BAR_TYPES
|
| 25 |
+
from pip._internal.exceptions import CommandError
|
| 26 |
+
from pip._internal.locations import USER_CACHE_DIR, get_src_prefix
|
| 27 |
+
from pip._internal.models.format_control import FormatControl
|
| 28 |
+
from pip._internal.models.index import PyPI
|
| 29 |
+
from pip._internal.models.target_python import TargetPython
|
| 30 |
+
from pip._internal.utils.hashes import STRONG_HASHES
|
| 31 |
+
from pip._internal.utils.misc import strtobool
|
| 32 |
+
|
| 33 |
+
logger = logging.getLogger(__name__)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def raise_option_error(parser: OptionParser, option: Option, msg: str) -> None:
|
| 37 |
+
"""
|
| 38 |
+
Raise an option parsing error using parser.error().
|
| 39 |
+
|
| 40 |
+
Args:
|
| 41 |
+
parser: an OptionParser instance.
|
| 42 |
+
option: an Option instance.
|
| 43 |
+
msg: the error text.
|
| 44 |
+
"""
|
| 45 |
+
msg = f"{option} error: {msg}"
|
| 46 |
+
msg = textwrap.fill(" ".join(msg.split()))
|
| 47 |
+
parser.error(msg)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def make_option_group(group: Dict[str, Any], parser: ConfigOptionParser) -> OptionGroup:
|
| 51 |
+
"""
|
| 52 |
+
Return an OptionGroup object
|
| 53 |
+
group -- assumed to be dict with 'name' and 'options' keys
|
| 54 |
+
parser -- an optparse Parser
|
| 55 |
+
"""
|
| 56 |
+
option_group = OptionGroup(parser, group["name"])
|
| 57 |
+
for option in group["options"]:
|
| 58 |
+
option_group.add_option(option())
|
| 59 |
+
return option_group
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def check_install_build_global(
|
| 63 |
+
options: Values, check_options: Optional[Values] = None
|
| 64 |
+
) -> None:
|
| 65 |
+
"""Disable wheels if per-setup.py call options are set.
|
| 66 |
+
|
| 67 |
+
:param options: The OptionParser options to update.
|
| 68 |
+
:param check_options: The options to check, if not supplied defaults to
|
| 69 |
+
options.
|
| 70 |
+
"""
|
| 71 |
+
if check_options is None:
|
| 72 |
+
check_options = options
|
| 73 |
+
|
| 74 |
+
def getname(n: str) -> Optional[Any]:
|
| 75 |
+
return getattr(check_options, n, None)
|
| 76 |
+
|
| 77 |
+
names = ["build_options", "global_options", "install_options"]
|
| 78 |
+
if any(map(getname, names)):
|
| 79 |
+
control = options.format_control
|
| 80 |
+
control.disallow_binaries()
|
| 81 |
+
logger.warning(
|
| 82 |
+
"Disabling all use of wheels due to the use of --build-option "
|
| 83 |
+
"/ --global-option / --install-option.",
|
| 84 |
+
)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def check_dist_restriction(options: Values, check_target: bool = False) -> None:
|
| 88 |
+
"""Function for determining if custom platform options are allowed.
|
| 89 |
+
|
| 90 |
+
:param options: The OptionParser options.
|
| 91 |
+
:param check_target: Whether or not to check if --target is being used.
|
| 92 |
+
"""
|
| 93 |
+
dist_restriction_set = any(
|
| 94 |
+
[
|
| 95 |
+
options.python_version,
|
| 96 |
+
options.platforms,
|
| 97 |
+
options.abis,
|
| 98 |
+
options.implementation,
|
| 99 |
+
]
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
binary_only = FormatControl(set(), {":all:"})
|
| 103 |
+
sdist_dependencies_allowed = (
|
| 104 |
+
options.format_control != binary_only and not options.ignore_dependencies
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
# Installations or downloads using dist restrictions must not combine
|
| 108 |
+
# source distributions and dist-specific wheels, as they are not
|
| 109 |
+
# guaranteed to be locally compatible.
|
| 110 |
+
if dist_restriction_set and sdist_dependencies_allowed:
|
| 111 |
+
raise CommandError(
|
| 112 |
+
"When restricting platform and interpreter constraints using "
|
| 113 |
+
"--python-version, --platform, --abi, or --implementation, "
|
| 114 |
+
"either --no-deps must be set, or --only-binary=:all: must be "
|
| 115 |
+
"set and --no-binary must not be set (or must be set to "
|
| 116 |
+
":none:)."
|
| 117 |
+
)
|
| 118 |
+
|
| 119 |
+
if check_target:
|
| 120 |
+
if dist_restriction_set and not options.target_dir:
|
| 121 |
+
raise CommandError(
|
| 122 |
+
"Can not use any platform or abi specific options unless "
|
| 123 |
+
"installing via '--target'"
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def _path_option_check(option: Option, opt: str, value: str) -> str:
|
| 128 |
+
return os.path.expanduser(value)
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def _package_name_option_check(option: Option, opt: str, value: str) -> str:
|
| 132 |
+
return canonicalize_name(value)
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
class PipOption(Option):
|
| 136 |
+
TYPES = Option.TYPES + ("path", "package_name")
|
| 137 |
+
TYPE_CHECKER = Option.TYPE_CHECKER.copy()
|
| 138 |
+
TYPE_CHECKER["package_name"] = _package_name_option_check
|
| 139 |
+
TYPE_CHECKER["path"] = _path_option_check
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
###########
|
| 143 |
+
# options #
|
| 144 |
+
###########
|
| 145 |
+
|
| 146 |
+
help_: Callable[..., Option] = partial(
|
| 147 |
+
Option,
|
| 148 |
+
"-h",
|
| 149 |
+
"--help",
|
| 150 |
+
dest="help",
|
| 151 |
+
action="help",
|
| 152 |
+
help="Show help.",
|
| 153 |
+
)
|
| 154 |
+
|
| 155 |
+
debug_mode: Callable[..., Option] = partial(
|
| 156 |
+
Option,
|
| 157 |
+
"--debug",
|
| 158 |
+
dest="debug_mode",
|
| 159 |
+
action="store_true",
|
| 160 |
+
default=False,
|
| 161 |
+
help=(
|
| 162 |
+
"Let unhandled exceptions propagate outside the main subroutine, "
|
| 163 |
+
"instead of logging them to stderr."
|
| 164 |
+
),
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
isolated_mode: Callable[..., Option] = partial(
|
| 168 |
+
Option,
|
| 169 |
+
"--isolated",
|
| 170 |
+
dest="isolated_mode",
|
| 171 |
+
action="store_true",
|
| 172 |
+
default=False,
|
| 173 |
+
help=(
|
| 174 |
+
"Run pip in an isolated mode, ignoring environment variables and user "
|
| 175 |
+
"configuration."
|
| 176 |
+
),
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
+
require_virtualenv: Callable[..., Option] = partial(
|
| 180 |
+
Option,
|
| 181 |
+
"--require-virtualenv",
|
| 182 |
+
"--require-venv",
|
| 183 |
+
dest="require_venv",
|
| 184 |
+
action="store_true",
|
| 185 |
+
default=False,
|
| 186 |
+
help=(
|
| 187 |
+
"Allow pip to only run in a virtual environment; "
|
| 188 |
+
"exit with an error otherwise."
|
| 189 |
+
),
|
| 190 |
+
)
|
| 191 |
+
|
| 192 |
+
verbose: Callable[..., Option] = partial(
|
| 193 |
+
Option,
|
| 194 |
+
"-v",
|
| 195 |
+
"--verbose",
|
| 196 |
+
dest="verbose",
|
| 197 |
+
action="count",
|
| 198 |
+
default=0,
|
| 199 |
+
help="Give more output. Option is additive, and can be used up to 3 times.",
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
no_color: Callable[..., Option] = partial(
|
| 203 |
+
Option,
|
| 204 |
+
"--no-color",
|
| 205 |
+
dest="no_color",
|
| 206 |
+
action="store_true",
|
| 207 |
+
default=False,
|
| 208 |
+
help="Suppress colored output.",
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
version: Callable[..., Option] = partial(
|
| 212 |
+
Option,
|
| 213 |
+
"-V",
|
| 214 |
+
"--version",
|
| 215 |
+
dest="version",
|
| 216 |
+
action="store_true",
|
| 217 |
+
help="Show version and exit.",
|
| 218 |
+
)
|
| 219 |
+
|
| 220 |
+
quiet: Callable[..., Option] = partial(
|
| 221 |
+
Option,
|
| 222 |
+
"-q",
|
| 223 |
+
"--quiet",
|
| 224 |
+
dest="quiet",
|
| 225 |
+
action="count",
|
| 226 |
+
default=0,
|
| 227 |
+
help=(
|
| 228 |
+
"Give less output. Option is additive, and can be used up to 3"
|
| 229 |
+
" times (corresponding to WARNING, ERROR, and CRITICAL logging"
|
| 230 |
+
" levels)."
|
| 231 |
+
),
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
progress_bar: Callable[..., Option] = partial(
|
| 235 |
+
Option,
|
| 236 |
+
"--progress-bar",
|
| 237 |
+
dest="progress_bar",
|
| 238 |
+
type="choice",
|
| 239 |
+
choices=list(BAR_TYPES.keys()),
|
| 240 |
+
default="on",
|
| 241 |
+
help=(
|
| 242 |
+
"Specify type of progress to be displayed ["
|
| 243 |
+
+ "|".join(BAR_TYPES.keys())
|
| 244 |
+
+ "] (default: %default)"
|
| 245 |
+
),
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
+
log: Callable[..., Option] = partial(
|
| 249 |
+
PipOption,
|
| 250 |
+
"--log",
|
| 251 |
+
"--log-file",
|
| 252 |
+
"--local-log",
|
| 253 |
+
dest="log",
|
| 254 |
+
metavar="path",
|
| 255 |
+
type="path",
|
| 256 |
+
help="Path to a verbose appending log.",
|
| 257 |
+
)
|
| 258 |
+
|
| 259 |
+
no_input: Callable[..., Option] = partial(
|
| 260 |
+
Option,
|
| 261 |
+
# Don't ask for input
|
| 262 |
+
"--no-input",
|
| 263 |
+
dest="no_input",
|
| 264 |
+
action="store_true",
|
| 265 |
+
default=False,
|
| 266 |
+
help="Disable prompting for input.",
|
| 267 |
+
)
|
| 268 |
+
|
| 269 |
+
proxy: Callable[..., Option] = partial(
|
| 270 |
+
Option,
|
| 271 |
+
"--proxy",
|
| 272 |
+
dest="proxy",
|
| 273 |
+
type="str",
|
| 274 |
+
default="",
|
| 275 |
+
help="Specify a proxy in the form [user:passwd@]proxy.server:port.",
|
| 276 |
+
)
|
| 277 |
+
|
| 278 |
+
retries: Callable[..., Option] = partial(
|
| 279 |
+
Option,
|
| 280 |
+
"--retries",
|
| 281 |
+
dest="retries",
|
| 282 |
+
type="int",
|
| 283 |
+
default=5,
|
| 284 |
+
help="Maximum number of retries each connection should attempt "
|
| 285 |
+
"(default %default times).",
|
| 286 |
+
)
|
| 287 |
+
|
| 288 |
+
timeout: Callable[..., Option] = partial(
|
| 289 |
+
Option,
|
| 290 |
+
"--timeout",
|
| 291 |
+
"--default-timeout",
|
| 292 |
+
metavar="sec",
|
| 293 |
+
dest="timeout",
|
| 294 |
+
type="float",
|
| 295 |
+
default=15,
|
| 296 |
+
help="Set the socket timeout (default %default seconds).",
|
| 297 |
+
)
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
def exists_action() -> Option:
|
| 301 |
+
return Option(
|
| 302 |
+
# Option when path already exist
|
| 303 |
+
"--exists-action",
|
| 304 |
+
dest="exists_action",
|
| 305 |
+
type="choice",
|
| 306 |
+
choices=["s", "i", "w", "b", "a"],
|
| 307 |
+
default=[],
|
| 308 |
+
action="append",
|
| 309 |
+
metavar="action",
|
| 310 |
+
help="Default action when a path already exists: "
|
| 311 |
+
"(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.",
|
| 312 |
+
)
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
cert: Callable[..., Option] = partial(
|
| 316 |
+
PipOption,
|
| 317 |
+
"--cert",
|
| 318 |
+
dest="cert",
|
| 319 |
+
type="path",
|
| 320 |
+
metavar="path",
|
| 321 |
+
help=(
|
| 322 |
+
"Path to PEM-encoded CA certificate bundle. "
|
| 323 |
+
"If provided, overrides the default. "
|
| 324 |
+
"See 'SSL Certificate Verification' in pip documentation "
|
| 325 |
+
"for more information."
|
| 326 |
+
),
|
| 327 |
+
)
|
| 328 |
+
|
| 329 |
+
client_cert: Callable[..., Option] = partial(
|
| 330 |
+
PipOption,
|
| 331 |
+
"--client-cert",
|
| 332 |
+
dest="client_cert",
|
| 333 |
+
type="path",
|
| 334 |
+
default=None,
|
| 335 |
+
metavar="path",
|
| 336 |
+
help="Path to SSL client certificate, a single file containing the "
|
| 337 |
+
"private key and the certificate in PEM format.",
|
| 338 |
+
)
|
| 339 |
+
|
| 340 |
+
index_url: Callable[..., Option] = partial(
|
| 341 |
+
Option,
|
| 342 |
+
"-i",
|
| 343 |
+
"--index-url",
|
| 344 |
+
"--pypi-url",
|
| 345 |
+
dest="index_url",
|
| 346 |
+
metavar="URL",
|
| 347 |
+
default=PyPI.simple_url,
|
| 348 |
+
help="Base URL of the Python Package Index (default %default). "
|
| 349 |
+
"This should point to a repository compliant with PEP 503 "
|
| 350 |
+
"(the simple repository API) or a local directory laid out "
|
| 351 |
+
"in the same format.",
|
| 352 |
+
)
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
def extra_index_url() -> Option:
|
| 356 |
+
return Option(
|
| 357 |
+
"--extra-index-url",
|
| 358 |
+
dest="extra_index_urls",
|
| 359 |
+
metavar="URL",
|
| 360 |
+
action="append",
|
| 361 |
+
default=[],
|
| 362 |
+
help="Extra URLs of package indexes to use in addition to "
|
| 363 |
+
"--index-url. Should follow the same rules as "
|
| 364 |
+
"--index-url.",
|
| 365 |
+
)
|
| 366 |
+
|
| 367 |
+
|
| 368 |
+
no_index: Callable[..., Option] = partial(
|
| 369 |
+
Option,
|
| 370 |
+
"--no-index",
|
| 371 |
+
dest="no_index",
|
| 372 |
+
action="store_true",
|
| 373 |
+
default=False,
|
| 374 |
+
help="Ignore package index (only looking at --find-links URLs instead).",
|
| 375 |
+
)
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
def find_links() -> Option:
|
| 379 |
+
return Option(
|
| 380 |
+
"-f",
|
| 381 |
+
"--find-links",
|
| 382 |
+
dest="find_links",
|
| 383 |
+
action="append",
|
| 384 |
+
default=[],
|
| 385 |
+
metavar="url",
|
| 386 |
+
help="If a URL or path to an html file, then parse for links to "
|
| 387 |
+
"archives such as sdist (.tar.gz) or wheel (.whl) files. "
|
| 388 |
+
"If a local path or file:// URL that's a directory, "
|
| 389 |
+
"then look for archives in the directory listing. "
|
| 390 |
+
"Links to VCS project URLs are not supported.",
|
| 391 |
+
)
|
| 392 |
+
|
| 393 |
+
|
| 394 |
+
def trusted_host() -> Option:
|
| 395 |
+
return Option(
|
| 396 |
+
"--trusted-host",
|
| 397 |
+
dest="trusted_hosts",
|
| 398 |
+
action="append",
|
| 399 |
+
metavar="HOSTNAME",
|
| 400 |
+
default=[],
|
| 401 |
+
help="Mark this host or host:port pair as trusted, even though it "
|
| 402 |
+
"does not have valid or any HTTPS.",
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
|
| 406 |
+
def constraints() -> Option:
|
| 407 |
+
return Option(
|
| 408 |
+
"-c",
|
| 409 |
+
"--constraint",
|
| 410 |
+
dest="constraints",
|
| 411 |
+
action="append",
|
| 412 |
+
default=[],
|
| 413 |
+
metavar="file",
|
| 414 |
+
help="Constrain versions using the given constraints file. "
|
| 415 |
+
"This option can be used multiple times.",
|
| 416 |
+
)
|
| 417 |
+
|
| 418 |
+
|
| 419 |
+
def requirements() -> Option:
|
| 420 |
+
return Option(
|
| 421 |
+
"-r",
|
| 422 |
+
"--requirement",
|
| 423 |
+
dest="requirements",
|
| 424 |
+
action="append",
|
| 425 |
+
default=[],
|
| 426 |
+
metavar="file",
|
| 427 |
+
help="Install from the given requirements file. "
|
| 428 |
+
"This option can be used multiple times.",
|
| 429 |
+
)
|
| 430 |
+
|
| 431 |
+
|
| 432 |
+
def editable() -> Option:
|
| 433 |
+
return Option(
|
| 434 |
+
"-e",
|
| 435 |
+
"--editable",
|
| 436 |
+
dest="editables",
|
| 437 |
+
action="append",
|
| 438 |
+
default=[],
|
| 439 |
+
metavar="path/url",
|
| 440 |
+
help=(
|
| 441 |
+
"Install a project in editable mode (i.e. setuptools "
|
| 442 |
+
'"develop mode") from a local project path or a VCS url.'
|
| 443 |
+
),
|
| 444 |
+
)
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
def _handle_src(option: Option, opt_str: str, value: str, parser: OptionParser) -> None:
|
| 448 |
+
value = os.path.abspath(value)
|
| 449 |
+
setattr(parser.values, option.dest, value)
|
| 450 |
+
|
| 451 |
+
|
| 452 |
+
src: Callable[..., Option] = partial(
|
| 453 |
+
PipOption,
|
| 454 |
+
"--src",
|
| 455 |
+
"--source",
|
| 456 |
+
"--source-dir",
|
| 457 |
+
"--source-directory",
|
| 458 |
+
dest="src_dir",
|
| 459 |
+
type="path",
|
| 460 |
+
metavar="dir",
|
| 461 |
+
default=get_src_prefix(),
|
| 462 |
+
action="callback",
|
| 463 |
+
callback=_handle_src,
|
| 464 |
+
help="Directory to check out editable projects into. "
|
| 465 |
+
'The default in a virtualenv is "<venv path>/src". '
|
| 466 |
+
'The default for global installs is "<current dir>/src".',
|
| 467 |
+
)
|
| 468 |
+
|
| 469 |
+
|
| 470 |
+
def _get_format_control(values: Values, option: Option) -> Any:
|
| 471 |
+
"""Get a format_control object."""
|
| 472 |
+
return getattr(values, option.dest)
|
| 473 |
+
|
| 474 |
+
|
| 475 |
+
def _handle_no_binary(
|
| 476 |
+
option: Option, opt_str: str, value: str, parser: OptionParser
|
| 477 |
+
) -> None:
|
| 478 |
+
existing = _get_format_control(parser.values, option)
|
| 479 |
+
FormatControl.handle_mutual_excludes(
|
| 480 |
+
value,
|
| 481 |
+
existing.no_binary,
|
| 482 |
+
existing.only_binary,
|
| 483 |
+
)
|
| 484 |
+
|
| 485 |
+
|
| 486 |
+
def _handle_only_binary(
|
| 487 |
+
option: Option, opt_str: str, value: str, parser: OptionParser
|
| 488 |
+
) -> None:
|
| 489 |
+
existing = _get_format_control(parser.values, option)
|
| 490 |
+
FormatControl.handle_mutual_excludes(
|
| 491 |
+
value,
|
| 492 |
+
existing.only_binary,
|
| 493 |
+
existing.no_binary,
|
| 494 |
+
)
|
| 495 |
+
|
| 496 |
+
|
| 497 |
+
def no_binary() -> Option:
|
| 498 |
+
format_control = FormatControl(set(), set())
|
| 499 |
+
return Option(
|
| 500 |
+
"--no-binary",
|
| 501 |
+
dest="format_control",
|
| 502 |
+
action="callback",
|
| 503 |
+
callback=_handle_no_binary,
|
| 504 |
+
type="str",
|
| 505 |
+
default=format_control,
|
| 506 |
+
help="Do not use binary packages. Can be supplied multiple times, and "
|
| 507 |
+
'each time adds to the existing value. Accepts either ":all:" to '
|
| 508 |
+
'disable all binary packages, ":none:" to empty the set (notice '
|
| 509 |
+
"the colons), or one or more package names with commas between "
|
| 510 |
+
"them (no colons). Note that some packages are tricky to compile "
|
| 511 |
+
"and may fail to install when this option is used on them.",
|
| 512 |
+
)
|
| 513 |
+
|
| 514 |
+
|
| 515 |
+
def only_binary() -> Option:
|
| 516 |
+
format_control = FormatControl(set(), set())
|
| 517 |
+
return Option(
|
| 518 |
+
"--only-binary",
|
| 519 |
+
dest="format_control",
|
| 520 |
+
action="callback",
|
| 521 |
+
callback=_handle_only_binary,
|
| 522 |
+
type="str",
|
| 523 |
+
default=format_control,
|
| 524 |
+
help="Do not use source packages. Can be supplied multiple times, and "
|
| 525 |
+
'each time adds to the existing value. Accepts either ":all:" to '
|
| 526 |
+
'disable all source packages, ":none:" to empty the set, or one '
|
| 527 |
+
"or more package names with commas between them. Packages "
|
| 528 |
+
"without binary distributions will fail to install when this "
|
| 529 |
+
"option is used on them.",
|
| 530 |
+
)
|
| 531 |
+
|
| 532 |
+
|
| 533 |
+
platforms: Callable[..., Option] = partial(
|
| 534 |
+
Option,
|
| 535 |
+
"--platform",
|
| 536 |
+
dest="platforms",
|
| 537 |
+
metavar="platform",
|
| 538 |
+
action="append",
|
| 539 |
+
default=None,
|
| 540 |
+
help=(
|
| 541 |
+
"Only use wheels compatible with <platform>. Defaults to the "
|
| 542 |
+
"platform of the running system. Use this option multiple times to "
|
| 543 |
+
"specify multiple platforms supported by the target interpreter."
|
| 544 |
+
),
|
| 545 |
+
)
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
# This was made a separate function for unit-testing purposes.
|
| 549 |
+
def _convert_python_version(value: str) -> Tuple[Tuple[int, ...], Optional[str]]:
|
| 550 |
+
"""
|
| 551 |
+
Convert a version string like "3", "37", or "3.7.3" into a tuple of ints.
|
| 552 |
+
|
| 553 |
+
:return: A 2-tuple (version_info, error_msg), where `error_msg` is
|
| 554 |
+
non-None if and only if there was a parsing error.
|
| 555 |
+
"""
|
| 556 |
+
if not value:
|
| 557 |
+
# The empty string is the same as not providing a value.
|
| 558 |
+
return (None, None)
|
| 559 |
+
|
| 560 |
+
parts = value.split(".")
|
| 561 |
+
if len(parts) > 3:
|
| 562 |
+
return ((), "at most three version parts are allowed")
|
| 563 |
+
|
| 564 |
+
if len(parts) == 1:
|
| 565 |
+
# Then we are in the case of "3" or "37".
|
| 566 |
+
value = parts[0]
|
| 567 |
+
if len(value) > 1:
|
| 568 |
+
parts = [value[0], value[1:]]
|
| 569 |
+
|
| 570 |
+
try:
|
| 571 |
+
version_info = tuple(int(part) for part in parts)
|
| 572 |
+
except ValueError:
|
| 573 |
+
return ((), "each version part must be an integer")
|
| 574 |
+
|
| 575 |
+
return (version_info, None)
|
| 576 |
+
|
| 577 |
+
|
| 578 |
+
def _handle_python_version(
|
| 579 |
+
option: Option, opt_str: str, value: str, parser: OptionParser
|
| 580 |
+
) -> None:
|
| 581 |
+
"""
|
| 582 |
+
Handle a provided --python-version value.
|
| 583 |
+
"""
|
| 584 |
+
version_info, error_msg = _convert_python_version(value)
|
| 585 |
+
if error_msg is not None:
|
| 586 |
+
msg = "invalid --python-version value: {!r}: {}".format(
|
| 587 |
+
value,
|
| 588 |
+
error_msg,
|
| 589 |
+
)
|
| 590 |
+
raise_option_error(parser, option=option, msg=msg)
|
| 591 |
+
|
| 592 |
+
parser.values.python_version = version_info
|
| 593 |
+
|
| 594 |
+
|
| 595 |
+
python_version: Callable[..., Option] = partial(
|
| 596 |
+
Option,
|
| 597 |
+
"--python-version",
|
| 598 |
+
dest="python_version",
|
| 599 |
+
metavar="python_version",
|
| 600 |
+
action="callback",
|
| 601 |
+
callback=_handle_python_version,
|
| 602 |
+
type="str",
|
| 603 |
+
default=None,
|
| 604 |
+
help=dedent(
|
| 605 |
+
"""\
|
| 606 |
+
The Python interpreter version to use for wheel and "Requires-Python"
|
| 607 |
+
compatibility checks. Defaults to a version derived from the running
|
| 608 |
+
interpreter. The version can be specified using up to three dot-separated
|
| 609 |
+
integers (e.g. "3" for 3.0.0, "3.7" for 3.7.0, or "3.7.3"). A major-minor
|
| 610 |
+
version can also be given as a string without dots (e.g. "37" for 3.7.0).
|
| 611 |
+
"""
|
| 612 |
+
),
|
| 613 |
+
)
|
| 614 |
+
|
| 615 |
+
|
| 616 |
+
implementation: Callable[..., Option] = partial(
|
| 617 |
+
Option,
|
| 618 |
+
"--implementation",
|
| 619 |
+
dest="implementation",
|
| 620 |
+
metavar="implementation",
|
| 621 |
+
default=None,
|
| 622 |
+
help=(
|
| 623 |
+
"Only use wheels compatible with Python "
|
| 624 |
+
"implementation <implementation>, e.g. 'pp', 'jy', 'cp', "
|
| 625 |
+
" or 'ip'. If not specified, then the current "
|
| 626 |
+
"interpreter implementation is used. Use 'py' to force "
|
| 627 |
+
"implementation-agnostic wheels."
|
| 628 |
+
),
|
| 629 |
+
)
|
| 630 |
+
|
| 631 |
+
|
| 632 |
+
abis: Callable[..., Option] = partial(
|
| 633 |
+
Option,
|
| 634 |
+
"--abi",
|
| 635 |
+
dest="abis",
|
| 636 |
+
metavar="abi",
|
| 637 |
+
action="append",
|
| 638 |
+
default=None,
|
| 639 |
+
help=(
|
| 640 |
+
"Only use wheels compatible with Python abi <abi>, e.g. 'pypy_41'. "
|
| 641 |
+
"If not specified, then the current interpreter abi tag is used. "
|
| 642 |
+
"Use this option multiple times to specify multiple abis supported "
|
| 643 |
+
"by the target interpreter. Generally you will need to specify "
|
| 644 |
+
"--implementation, --platform, and --python-version when using this "
|
| 645 |
+
"option."
|
| 646 |
+
),
|
| 647 |
+
)
|
| 648 |
+
|
| 649 |
+
|
| 650 |
+
def add_target_python_options(cmd_opts: OptionGroup) -> None:
|
| 651 |
+
cmd_opts.add_option(platforms())
|
| 652 |
+
cmd_opts.add_option(python_version())
|
| 653 |
+
cmd_opts.add_option(implementation())
|
| 654 |
+
cmd_opts.add_option(abis())
|
| 655 |
+
|
| 656 |
+
|
| 657 |
+
def make_target_python(options: Values) -> TargetPython:
|
| 658 |
+
target_python = TargetPython(
|
| 659 |
+
platforms=options.platforms,
|
| 660 |
+
py_version_info=options.python_version,
|
| 661 |
+
abis=options.abis,
|
| 662 |
+
implementation=options.implementation,
|
| 663 |
+
)
|
| 664 |
+
|
| 665 |
+
return target_python
|
| 666 |
+
|
| 667 |
+
|
| 668 |
+
def prefer_binary() -> Option:
|
| 669 |
+
return Option(
|
| 670 |
+
"--prefer-binary",
|
| 671 |
+
dest="prefer_binary",
|
| 672 |
+
action="store_true",
|
| 673 |
+
default=False,
|
| 674 |
+
help="Prefer older binary packages over newer source packages.",
|
| 675 |
+
)
|
| 676 |
+
|
| 677 |
+
|
| 678 |
+
cache_dir: Callable[..., Option] = partial(
|
| 679 |
+
PipOption,
|
| 680 |
+
"--cache-dir",
|
| 681 |
+
dest="cache_dir",
|
| 682 |
+
default=USER_CACHE_DIR,
|
| 683 |
+
metavar="dir",
|
| 684 |
+
type="path",
|
| 685 |
+
help="Store the cache data in <dir>.",
|
| 686 |
+
)
|
| 687 |
+
|
| 688 |
+
|
| 689 |
+
def _handle_no_cache_dir(
|
| 690 |
+
option: Option, opt: str, value: str, parser: OptionParser
|
| 691 |
+
) -> None:
|
| 692 |
+
"""
|
| 693 |
+
Process a value provided for the --no-cache-dir option.
|
| 694 |
+
|
| 695 |
+
This is an optparse.Option callback for the --no-cache-dir option.
|
| 696 |
+
"""
|
| 697 |
+
# The value argument will be None if --no-cache-dir is passed via the
|
| 698 |
+
# command-line, since the option doesn't accept arguments. However,
|
| 699 |
+
# the value can be non-None if the option is triggered e.g. by an
|
| 700 |
+
# environment variable, like PIP_NO_CACHE_DIR=true.
|
| 701 |
+
if value is not None:
|
| 702 |
+
# Then parse the string value to get argument error-checking.
|
| 703 |
+
try:
|
| 704 |
+
strtobool(value)
|
| 705 |
+
except ValueError as exc:
|
| 706 |
+
raise_option_error(parser, option=option, msg=str(exc))
|
| 707 |
+
|
| 708 |
+
# Originally, setting PIP_NO_CACHE_DIR to a value that strtobool()
|
| 709 |
+
# converted to 0 (like "false" or "no") caused cache_dir to be disabled
|
| 710 |
+
# rather than enabled (logic would say the latter). Thus, we disable
|
| 711 |
+
# the cache directory not just on values that parse to True, but (for
|
| 712 |
+
# backwards compatibility reasons) also on values that parse to False.
|
| 713 |
+
# In other words, always set it to False if the option is provided in
|
| 714 |
+
# some (valid) form.
|
| 715 |
+
parser.values.cache_dir = False
|
| 716 |
+
|
| 717 |
+
|
| 718 |
+
no_cache: Callable[..., Option] = partial(
|
| 719 |
+
Option,
|
| 720 |
+
"--no-cache-dir",
|
| 721 |
+
dest="cache_dir",
|
| 722 |
+
action="callback",
|
| 723 |
+
callback=_handle_no_cache_dir,
|
| 724 |
+
help="Disable the cache.",
|
| 725 |
+
)
|
| 726 |
+
|
| 727 |
+
no_deps: Callable[..., Option] = partial(
|
| 728 |
+
Option,
|
| 729 |
+
"--no-deps",
|
| 730 |
+
"--no-dependencies",
|
| 731 |
+
dest="ignore_dependencies",
|
| 732 |
+
action="store_true",
|
| 733 |
+
default=False,
|
| 734 |
+
help="Don't install package dependencies.",
|
| 735 |
+
)
|
| 736 |
+
|
| 737 |
+
ignore_requires_python: Callable[..., Option] = partial(
|
| 738 |
+
Option,
|
| 739 |
+
"--ignore-requires-python",
|
| 740 |
+
dest="ignore_requires_python",
|
| 741 |
+
action="store_true",
|
| 742 |
+
help="Ignore the Requires-Python information.",
|
| 743 |
+
)
|
| 744 |
+
|
| 745 |
+
no_build_isolation: Callable[..., Option] = partial(
|
| 746 |
+
Option,
|
| 747 |
+
"--no-build-isolation",
|
| 748 |
+
dest="build_isolation",
|
| 749 |
+
action="store_false",
|
| 750 |
+
default=True,
|
| 751 |
+
help="Disable isolation when building a modern source distribution. "
|
| 752 |
+
"Build dependencies specified by PEP 518 must be already installed "
|
| 753 |
+
"if this option is used.",
|
| 754 |
+
)
|
| 755 |
+
|
| 756 |
+
|
| 757 |
+
def _handle_no_use_pep517(
|
| 758 |
+
option: Option, opt: str, value: str, parser: OptionParser
|
| 759 |
+
) -> None:
|
| 760 |
+
"""
|
| 761 |
+
Process a value provided for the --no-use-pep517 option.
|
| 762 |
+
|
| 763 |
+
This is an optparse.Option callback for the no_use_pep517 option.
|
| 764 |
+
"""
|
| 765 |
+
# Since --no-use-pep517 doesn't accept arguments, the value argument
|
| 766 |
+
# will be None if --no-use-pep517 is passed via the command-line.
|
| 767 |
+
# However, the value can be non-None if the option is triggered e.g.
|
| 768 |
+
# by an environment variable, for example "PIP_NO_USE_PEP517=true".
|
| 769 |
+
if value is not None:
|
| 770 |
+
msg = """A value was passed for --no-use-pep517,
|
| 771 |
+
probably using either the PIP_NO_USE_PEP517 environment variable
|
| 772 |
+
or the "no-use-pep517" config file option. Use an appropriate value
|
| 773 |
+
of the PIP_USE_PEP517 environment variable or the "use-pep517"
|
| 774 |
+
config file option instead.
|
| 775 |
+
"""
|
| 776 |
+
raise_option_error(parser, option=option, msg=msg)
|
| 777 |
+
|
| 778 |
+
# Otherwise, --no-use-pep517 was passed via the command-line.
|
| 779 |
+
parser.values.use_pep517 = False
|
| 780 |
+
|
| 781 |
+
|
| 782 |
+
use_pep517: Any = partial(
|
| 783 |
+
Option,
|
| 784 |
+
"--use-pep517",
|
| 785 |
+
dest="use_pep517",
|
| 786 |
+
action="store_true",
|
| 787 |
+
default=None,
|
| 788 |
+
help="Use PEP 517 for building source distributions "
|
| 789 |
+
"(use --no-use-pep517 to force legacy behaviour).",
|
| 790 |
+
)
|
| 791 |
+
|
| 792 |
+
no_use_pep517: Any = partial(
|
| 793 |
+
Option,
|
| 794 |
+
"--no-use-pep517",
|
| 795 |
+
dest="use_pep517",
|
| 796 |
+
action="callback",
|
| 797 |
+
callback=_handle_no_use_pep517,
|
| 798 |
+
default=None,
|
| 799 |
+
help=SUPPRESS_HELP,
|
| 800 |
+
)
|
| 801 |
+
|
| 802 |
+
install_options: Callable[..., Option] = partial(
|
| 803 |
+
Option,
|
| 804 |
+
"--install-option",
|
| 805 |
+
dest="install_options",
|
| 806 |
+
action="append",
|
| 807 |
+
metavar="options",
|
| 808 |
+
help="Extra arguments to be supplied to the setup.py install "
|
| 809 |
+
'command (use like --install-option="--install-scripts=/usr/local/'
|
| 810 |
+
'bin"). Use multiple --install-option options to pass multiple '
|
| 811 |
+
"options to setup.py install. If you are using an option with a "
|
| 812 |
+
"directory path, be sure to use absolute path.",
|
| 813 |
+
)
|
| 814 |
+
|
| 815 |
+
build_options: Callable[..., Option] = partial(
|
| 816 |
+
Option,
|
| 817 |
+
"--build-option",
|
| 818 |
+
dest="build_options",
|
| 819 |
+
metavar="options",
|
| 820 |
+
action="append",
|
| 821 |
+
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
|
| 822 |
+
)
|
| 823 |
+
|
| 824 |
+
global_options: Callable[..., Option] = partial(
|
| 825 |
+
Option,
|
| 826 |
+
"--global-option",
|
| 827 |
+
dest="global_options",
|
| 828 |
+
action="append",
|
| 829 |
+
metavar="options",
|
| 830 |
+
help="Extra global options to be supplied to the setup.py "
|
| 831 |
+
"call before the install or bdist_wheel command.",
|
| 832 |
+
)
|
| 833 |
+
|
| 834 |
+
no_clean: Callable[..., Option] = partial(
|
| 835 |
+
Option,
|
| 836 |
+
"--no-clean",
|
| 837 |
+
action="store_true",
|
| 838 |
+
default=False,
|
| 839 |
+
help="Don't clean up build directories.",
|
| 840 |
+
)
|
| 841 |
+
|
| 842 |
+
pre: Callable[..., Option] = partial(
|
| 843 |
+
Option,
|
| 844 |
+
"--pre",
|
| 845 |
+
action="store_true",
|
| 846 |
+
default=False,
|
| 847 |
+
help="Include pre-release and development versions. By default, "
|
| 848 |
+
"pip only finds stable versions.",
|
| 849 |
+
)
|
| 850 |
+
|
| 851 |
+
disable_pip_version_check: Callable[..., Option] = partial(
|
| 852 |
+
Option,
|
| 853 |
+
"--disable-pip-version-check",
|
| 854 |
+
dest="disable_pip_version_check",
|
| 855 |
+
action="store_true",
|
| 856 |
+
default=True,
|
| 857 |
+
help="Don't periodically check PyPI to determine whether a new version "
|
| 858 |
+
"of pip is available for download. Implied with --no-index.",
|
| 859 |
+
)
|
| 860 |
+
|
| 861 |
+
|
| 862 |
+
def _handle_merge_hash(
|
| 863 |
+
option: Option, opt_str: str, value: str, parser: OptionParser
|
| 864 |
+
) -> None:
|
| 865 |
+
"""Given a value spelled "algo:digest", append the digest to a list
|
| 866 |
+
pointed to in a dict by the algo name."""
|
| 867 |
+
if not parser.values.hashes:
|
| 868 |
+
parser.values.hashes = {}
|
| 869 |
+
try:
|
| 870 |
+
algo, digest = value.split(":", 1)
|
| 871 |
+
except ValueError:
|
| 872 |
+
parser.error(
|
| 873 |
+
"Arguments to {} must be a hash name " # noqa
|
| 874 |
+
"followed by a value, like --hash=sha256:"
|
| 875 |
+
"abcde...".format(opt_str)
|
| 876 |
+
)
|
| 877 |
+
if algo not in STRONG_HASHES:
|
| 878 |
+
parser.error(
|
| 879 |
+
"Allowed hash algorithms for {} are {}.".format( # noqa
|
| 880 |
+
opt_str, ", ".join(STRONG_HASHES)
|
| 881 |
+
)
|
| 882 |
+
)
|
| 883 |
+
parser.values.hashes.setdefault(algo, []).append(digest)
|
| 884 |
+
|
| 885 |
+
|
| 886 |
+
hash: Callable[..., Option] = partial(
|
| 887 |
+
Option,
|
| 888 |
+
"--hash",
|
| 889 |
+
# Hash values eventually end up in InstallRequirement.hashes due to
|
| 890 |
+
# __dict__ copying in process_line().
|
| 891 |
+
dest="hashes",
|
| 892 |
+
action="callback",
|
| 893 |
+
callback=_handle_merge_hash,
|
| 894 |
+
type="string",
|
| 895 |
+
help="Verify that the package's archive matches this "
|
| 896 |
+
"hash before installing. Example: --hash=sha256:abcdef...",
|
| 897 |
+
)
|
| 898 |
+
|
| 899 |
+
|
| 900 |
+
require_hashes: Callable[..., Option] = partial(
|
| 901 |
+
Option,
|
| 902 |
+
"--require-hashes",
|
| 903 |
+
dest="require_hashes",
|
| 904 |
+
action="store_true",
|
| 905 |
+
default=False,
|
| 906 |
+
help="Require a hash to check each requirement against, for "
|
| 907 |
+
"repeatable installs. This option is implied when any package in a "
|
| 908 |
+
"requirements file has a --hash option.",
|
| 909 |
+
)
|
| 910 |
+
|
| 911 |
+
|
| 912 |
+
list_path: Callable[..., Option] = partial(
|
| 913 |
+
PipOption,
|
| 914 |
+
"--path",
|
| 915 |
+
dest="path",
|
| 916 |
+
type="path",
|
| 917 |
+
action="append",
|
| 918 |
+
help="Restrict to the specified installation path for listing "
|
| 919 |
+
"packages (can be used multiple times).",
|
| 920 |
+
)
|
| 921 |
+
|
| 922 |
+
|
| 923 |
+
def check_list_path_option(options: Values) -> None:
|
| 924 |
+
if options.path and (options.user or options.local):
|
| 925 |
+
raise CommandError("Cannot combine '--path' with '--user' or '--local'")
|
| 926 |
+
|
| 927 |
+
|
| 928 |
+
list_exclude: Callable[..., Option] = partial(
|
| 929 |
+
PipOption,
|
| 930 |
+
"--exclude",
|
| 931 |
+
dest="excludes",
|
| 932 |
+
action="append",
|
| 933 |
+
metavar="package",
|
| 934 |
+
type="package_name",
|
| 935 |
+
help="Exclude specified package from the output",
|
| 936 |
+
)
|
| 937 |
+
|
| 938 |
+
|
| 939 |
+
no_python_version_warning: Callable[..., Option] = partial(
|
| 940 |
+
Option,
|
| 941 |
+
"--no-python-version-warning",
|
| 942 |
+
dest="no_python_version_warning",
|
| 943 |
+
action="store_true",
|
| 944 |
+
default=False,
|
| 945 |
+
help="Silence deprecation warnings for upcoming unsupported Pythons.",
|
| 946 |
+
)
|
| 947 |
+
|
| 948 |
+
|
| 949 |
+
use_new_feature: Callable[..., Option] = partial(
|
| 950 |
+
Option,
|
| 951 |
+
"--use-feature",
|
| 952 |
+
dest="features_enabled",
|
| 953 |
+
metavar="feature",
|
| 954 |
+
action="append",
|
| 955 |
+
default=[],
|
| 956 |
+
choices=["2020-resolver", "fast-deps", "in-tree-build"],
|
| 957 |
+
help="Enable new functionality, that may be backward incompatible.",
|
| 958 |
+
)
|
| 959 |
+
|
| 960 |
+
use_deprecated_feature: Callable[..., Option] = partial(
|
| 961 |
+
Option,
|
| 962 |
+
"--use-deprecated",
|
| 963 |
+
dest="deprecated_features_enabled",
|
| 964 |
+
metavar="feature",
|
| 965 |
+
action="append",
|
| 966 |
+
default=[],
|
| 967 |
+
choices=[
|
| 968 |
+
"legacy-resolver",
|
| 969 |
+
"out-of-tree-build",
|
| 970 |
+
"backtrack-on-build-failures",
|
| 971 |
+
"html5lib",
|
| 972 |
+
],
|
| 973 |
+
help=("Enable deprecated functionality, that will be removed in the future."),
|
| 974 |
+
)
|
| 975 |
+
|
| 976 |
+
|
| 977 |
+
##########
|
| 978 |
+
# groups #
|
| 979 |
+
##########
|
| 980 |
+
|
| 981 |
+
general_group: Dict[str, Any] = {
|
| 982 |
+
"name": "General Options",
|
| 983 |
+
"options": [
|
| 984 |
+
help_,
|
| 985 |
+
debug_mode,
|
| 986 |
+
isolated_mode,
|
| 987 |
+
require_virtualenv,
|
| 988 |
+
verbose,
|
| 989 |
+
version,
|
| 990 |
+
quiet,
|
| 991 |
+
log,
|
| 992 |
+
no_input,
|
| 993 |
+
proxy,
|
| 994 |
+
retries,
|
| 995 |
+
timeout,
|
| 996 |
+
exists_action,
|
| 997 |
+
trusted_host,
|
| 998 |
+
cert,
|
| 999 |
+
client_cert,
|
| 1000 |
+
cache_dir,
|
| 1001 |
+
no_cache,
|
| 1002 |
+
disable_pip_version_check,
|
| 1003 |
+
no_color,
|
| 1004 |
+
no_python_version_warning,
|
| 1005 |
+
use_new_feature,
|
| 1006 |
+
use_deprecated_feature,
|
| 1007 |
+
],
|
| 1008 |
+
}
|
| 1009 |
+
|
| 1010 |
+
index_group: Dict[str, Any] = {
|
| 1011 |
+
"name": "Package Index Options",
|
| 1012 |
+
"options": [
|
| 1013 |
+
index_url,
|
| 1014 |
+
extra_index_url,
|
| 1015 |
+
no_index,
|
| 1016 |
+
find_links,
|
| 1017 |
+
],
|
| 1018 |
+
}
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/command_context.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from contextlib import ExitStack, contextmanager
|
| 2 |
+
from typing import ContextManager, Iterator, TypeVar
|
| 3 |
+
|
| 4 |
+
_T = TypeVar("_T", covariant=True)
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class CommandContextMixIn:
|
| 8 |
+
def __init__(self) -> None:
|
| 9 |
+
super().__init__()
|
| 10 |
+
self._in_main_context = False
|
| 11 |
+
self._main_context = ExitStack()
|
| 12 |
+
|
| 13 |
+
@contextmanager
|
| 14 |
+
def main_context(self) -> Iterator[None]:
|
| 15 |
+
assert not self._in_main_context
|
| 16 |
+
|
| 17 |
+
self._in_main_context = True
|
| 18 |
+
try:
|
| 19 |
+
with self._main_context:
|
| 20 |
+
yield
|
| 21 |
+
finally:
|
| 22 |
+
self._in_main_context = False
|
| 23 |
+
|
| 24 |
+
def enter_context(self, context_provider: ContextManager[_T]) -> _T:
|
| 25 |
+
assert self._in_main_context
|
| 26 |
+
|
| 27 |
+
return self._main_context.enter_context(context_provider)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/parser.py
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Base option parser setup"""
|
| 2 |
+
|
| 3 |
+
import logging
|
| 4 |
+
import optparse
|
| 5 |
+
import shutil
|
| 6 |
+
import sys
|
| 7 |
+
import textwrap
|
| 8 |
+
from contextlib import suppress
|
| 9 |
+
from typing import Any, Dict, Iterator, List, Tuple
|
| 10 |
+
|
| 11 |
+
from pip._internal.cli.status_codes import UNKNOWN_ERROR
|
| 12 |
+
from pip._internal.configuration import Configuration, ConfigurationError
|
| 13 |
+
from pip._internal.utils.misc import redact_auth_from_url, strtobool
|
| 14 |
+
|
| 15 |
+
logger = logging.getLogger(__name__)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class PrettyHelpFormatter(optparse.IndentedHelpFormatter):
|
| 19 |
+
"""A prettier/less verbose help formatter for optparse."""
|
| 20 |
+
|
| 21 |
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
| 22 |
+
# help position must be aligned with __init__.parseopts.description
|
| 23 |
+
kwargs["max_help_position"] = 30
|
| 24 |
+
kwargs["indent_increment"] = 1
|
| 25 |
+
kwargs["width"] = shutil.get_terminal_size()[0] - 2
|
| 26 |
+
super().__init__(*args, **kwargs)
|
| 27 |
+
|
| 28 |
+
def format_option_strings(self, option: optparse.Option) -> str:
|
| 29 |
+
return self._format_option_strings(option)
|
| 30 |
+
|
| 31 |
+
def _format_option_strings(
|
| 32 |
+
self, option: optparse.Option, mvarfmt: str = " <{}>", optsep: str = ", "
|
| 33 |
+
) -> str:
|
| 34 |
+
"""
|
| 35 |
+
Return a comma-separated list of option strings and metavars.
|
| 36 |
+
|
| 37 |
+
:param option: tuple of (short opt, long opt), e.g: ('-f', '--format')
|
| 38 |
+
:param mvarfmt: metavar format string
|
| 39 |
+
:param optsep: separator
|
| 40 |
+
"""
|
| 41 |
+
opts = []
|
| 42 |
+
|
| 43 |
+
if option._short_opts:
|
| 44 |
+
opts.append(option._short_opts[0])
|
| 45 |
+
if option._long_opts:
|
| 46 |
+
opts.append(option._long_opts[0])
|
| 47 |
+
if len(opts) > 1:
|
| 48 |
+
opts.insert(1, optsep)
|
| 49 |
+
|
| 50 |
+
if option.takes_value():
|
| 51 |
+
assert option.dest is not None
|
| 52 |
+
metavar = option.metavar or option.dest.lower()
|
| 53 |
+
opts.append(mvarfmt.format(metavar.lower()))
|
| 54 |
+
|
| 55 |
+
return "".join(opts)
|
| 56 |
+
|
| 57 |
+
def format_heading(self, heading: str) -> str:
|
| 58 |
+
if heading == "Options":
|
| 59 |
+
return ""
|
| 60 |
+
return heading + ":\n"
|
| 61 |
+
|
| 62 |
+
def format_usage(self, usage: str) -> str:
|
| 63 |
+
"""
|
| 64 |
+
Ensure there is only one newline between usage and the first heading
|
| 65 |
+
if there is no description.
|
| 66 |
+
"""
|
| 67 |
+
msg = "\nUsage: {}\n".format(self.indent_lines(textwrap.dedent(usage), " "))
|
| 68 |
+
return msg
|
| 69 |
+
|
| 70 |
+
def format_description(self, description: str) -> str:
|
| 71 |
+
# leave full control over description to us
|
| 72 |
+
if description:
|
| 73 |
+
if hasattr(self.parser, "main"):
|
| 74 |
+
label = "Commands"
|
| 75 |
+
else:
|
| 76 |
+
label = "Description"
|
| 77 |
+
# some doc strings have initial newlines, some don't
|
| 78 |
+
description = description.lstrip("\n")
|
| 79 |
+
# some doc strings have final newlines and spaces, some don't
|
| 80 |
+
description = description.rstrip()
|
| 81 |
+
# dedent, then reindent
|
| 82 |
+
description = self.indent_lines(textwrap.dedent(description), " ")
|
| 83 |
+
description = f"{label}:\n{description}\n"
|
| 84 |
+
return description
|
| 85 |
+
else:
|
| 86 |
+
return ""
|
| 87 |
+
|
| 88 |
+
def format_epilog(self, epilog: str) -> str:
|
| 89 |
+
# leave full control over epilog to us
|
| 90 |
+
if epilog:
|
| 91 |
+
return epilog
|
| 92 |
+
else:
|
| 93 |
+
return ""
|
| 94 |
+
|
| 95 |
+
def indent_lines(self, text: str, indent: str) -> str:
|
| 96 |
+
new_lines = [indent + line for line in text.split("\n")]
|
| 97 |
+
return "\n".join(new_lines)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
class UpdatingDefaultsHelpFormatter(PrettyHelpFormatter):
|
| 101 |
+
"""Custom help formatter for use in ConfigOptionParser.
|
| 102 |
+
|
| 103 |
+
This is updates the defaults before expanding them, allowing
|
| 104 |
+
them to show up correctly in the help listing.
|
| 105 |
+
|
| 106 |
+
Also redact auth from url type options
|
| 107 |
+
"""
|
| 108 |
+
|
| 109 |
+
def expand_default(self, option: optparse.Option) -> str:
|
| 110 |
+
default_values = None
|
| 111 |
+
if self.parser is not None:
|
| 112 |
+
assert isinstance(self.parser, ConfigOptionParser)
|
| 113 |
+
self.parser._update_defaults(self.parser.defaults)
|
| 114 |
+
assert option.dest is not None
|
| 115 |
+
default_values = self.parser.defaults.get(option.dest)
|
| 116 |
+
help_text = super().expand_default(option)
|
| 117 |
+
|
| 118 |
+
if default_values and option.metavar == "URL":
|
| 119 |
+
if isinstance(default_values, str):
|
| 120 |
+
default_values = [default_values]
|
| 121 |
+
|
| 122 |
+
# If its not a list, we should abort and just return the help text
|
| 123 |
+
if not isinstance(default_values, list):
|
| 124 |
+
default_values = []
|
| 125 |
+
|
| 126 |
+
for val in default_values:
|
| 127 |
+
help_text = help_text.replace(val, redact_auth_from_url(val))
|
| 128 |
+
|
| 129 |
+
return help_text
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
class CustomOptionParser(optparse.OptionParser):
|
| 133 |
+
def insert_option_group(
|
| 134 |
+
self, idx: int, *args: Any, **kwargs: Any
|
| 135 |
+
) -> optparse.OptionGroup:
|
| 136 |
+
"""Insert an OptionGroup at a given position."""
|
| 137 |
+
group = self.add_option_group(*args, **kwargs)
|
| 138 |
+
|
| 139 |
+
self.option_groups.pop()
|
| 140 |
+
self.option_groups.insert(idx, group)
|
| 141 |
+
|
| 142 |
+
return group
|
| 143 |
+
|
| 144 |
+
@property
|
| 145 |
+
def option_list_all(self) -> List[optparse.Option]:
|
| 146 |
+
"""Get a list of all options, including those in option groups."""
|
| 147 |
+
res = self.option_list[:]
|
| 148 |
+
for i in self.option_groups:
|
| 149 |
+
res.extend(i.option_list)
|
| 150 |
+
|
| 151 |
+
return res
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
class ConfigOptionParser(CustomOptionParser):
|
| 155 |
+
"""Custom option parser which updates its defaults by checking the
|
| 156 |
+
configuration files and environmental variables"""
|
| 157 |
+
|
| 158 |
+
def __init__(
|
| 159 |
+
self,
|
| 160 |
+
*args: Any,
|
| 161 |
+
name: str,
|
| 162 |
+
isolated: bool = False,
|
| 163 |
+
**kwargs: Any,
|
| 164 |
+
) -> None:
|
| 165 |
+
self.name = name
|
| 166 |
+
self.config = Configuration(isolated)
|
| 167 |
+
|
| 168 |
+
assert self.name
|
| 169 |
+
super().__init__(*args, **kwargs)
|
| 170 |
+
|
| 171 |
+
def check_default(self, option: optparse.Option, key: str, val: Any) -> Any:
|
| 172 |
+
try:
|
| 173 |
+
return option.check_value(key, val)
|
| 174 |
+
except optparse.OptionValueError as exc:
|
| 175 |
+
print(f"An error occurred during configuration: {exc}")
|
| 176 |
+
sys.exit(3)
|
| 177 |
+
|
| 178 |
+
def _get_ordered_configuration_items(self) -> Iterator[Tuple[str, Any]]:
|
| 179 |
+
# Configuration gives keys in an unordered manner. Order them.
|
| 180 |
+
override_order = ["global", self.name, ":env:"]
|
| 181 |
+
|
| 182 |
+
# Pool the options into different groups
|
| 183 |
+
section_items: Dict[str, List[Tuple[str, Any]]] = {
|
| 184 |
+
name: [] for name in override_order
|
| 185 |
+
}
|
| 186 |
+
for section_key, val in self.config.items():
|
| 187 |
+
# ignore empty values
|
| 188 |
+
if not val:
|
| 189 |
+
logger.debug(
|
| 190 |
+
"Ignoring configuration key '%s' as it's value is empty.",
|
| 191 |
+
section_key,
|
| 192 |
+
)
|
| 193 |
+
continue
|
| 194 |
+
|
| 195 |
+
section, key = section_key.split(".", 1)
|
| 196 |
+
if section in override_order:
|
| 197 |
+
section_items[section].append((key, val))
|
| 198 |
+
|
| 199 |
+
# Yield each group in their override order
|
| 200 |
+
for section in override_order:
|
| 201 |
+
for key, val in section_items[section]:
|
| 202 |
+
yield key, val
|
| 203 |
+
|
| 204 |
+
def _update_defaults(self, defaults: Dict[str, Any]) -> Dict[str, Any]:
|
| 205 |
+
"""Updates the given defaults with values from the config files and
|
| 206 |
+
the environ. Does a little special handling for certain types of
|
| 207 |
+
options (lists)."""
|
| 208 |
+
|
| 209 |
+
# Accumulate complex default state.
|
| 210 |
+
self.values = optparse.Values(self.defaults)
|
| 211 |
+
late_eval = set()
|
| 212 |
+
# Then set the options with those values
|
| 213 |
+
for key, val in self._get_ordered_configuration_items():
|
| 214 |
+
# '--' because configuration supports only long names
|
| 215 |
+
option = self.get_option("--" + key)
|
| 216 |
+
|
| 217 |
+
# Ignore options not present in this parser. E.g. non-globals put
|
| 218 |
+
# in [global] by users that want them to apply to all applicable
|
| 219 |
+
# commands.
|
| 220 |
+
if option is None:
|
| 221 |
+
continue
|
| 222 |
+
|
| 223 |
+
assert option.dest is not None
|
| 224 |
+
|
| 225 |
+
if option.action in ("store_true", "store_false"):
|
| 226 |
+
try:
|
| 227 |
+
val = strtobool(val)
|
| 228 |
+
except ValueError:
|
| 229 |
+
self.error(
|
| 230 |
+
"{} is not a valid value for {} option, " # noqa
|
| 231 |
+
"please specify a boolean value like yes/no, "
|
| 232 |
+
"true/false or 1/0 instead.".format(val, key)
|
| 233 |
+
)
|
| 234 |
+
elif option.action == "count":
|
| 235 |
+
with suppress(ValueError):
|
| 236 |
+
val = strtobool(val)
|
| 237 |
+
with suppress(ValueError):
|
| 238 |
+
val = int(val)
|
| 239 |
+
if not isinstance(val, int) or val < 0:
|
| 240 |
+
self.error(
|
| 241 |
+
"{} is not a valid value for {} option, " # noqa
|
| 242 |
+
"please instead specify either a non-negative integer "
|
| 243 |
+
"or a boolean value like yes/no or false/true "
|
| 244 |
+
"which is equivalent to 1/0.".format(val, key)
|
| 245 |
+
)
|
| 246 |
+
elif option.action == "append":
|
| 247 |
+
val = val.split()
|
| 248 |
+
val = [self.check_default(option, key, v) for v in val]
|
| 249 |
+
elif option.action == "callback":
|
| 250 |
+
assert option.callback is not None
|
| 251 |
+
late_eval.add(option.dest)
|
| 252 |
+
opt_str = option.get_opt_string()
|
| 253 |
+
val = option.convert_value(opt_str, val)
|
| 254 |
+
# From take_action
|
| 255 |
+
args = option.callback_args or ()
|
| 256 |
+
kwargs = option.callback_kwargs or {}
|
| 257 |
+
option.callback(option, opt_str, val, self, *args, **kwargs)
|
| 258 |
+
else:
|
| 259 |
+
val = self.check_default(option, key, val)
|
| 260 |
+
|
| 261 |
+
defaults[option.dest] = val
|
| 262 |
+
|
| 263 |
+
for key in late_eval:
|
| 264 |
+
defaults[key] = getattr(self.values, key)
|
| 265 |
+
self.values = None
|
| 266 |
+
return defaults
|
| 267 |
+
|
| 268 |
+
def get_default_values(self) -> optparse.Values:
|
| 269 |
+
"""Overriding to make updating the defaults after instantiation of
|
| 270 |
+
the option parser possible, _update_defaults() does the dirty work."""
|
| 271 |
+
if not self.process_default_values:
|
| 272 |
+
# Old, pre-Optik 1.5 behaviour.
|
| 273 |
+
return optparse.Values(self.defaults)
|
| 274 |
+
|
| 275 |
+
# Load the configuration, or error out in case of an error
|
| 276 |
+
try:
|
| 277 |
+
self.config.load()
|
| 278 |
+
except ConfigurationError as err:
|
| 279 |
+
self.exit(UNKNOWN_ERROR, str(err))
|
| 280 |
+
|
| 281 |
+
defaults = self._update_defaults(self.defaults.copy()) # ours
|
| 282 |
+
for option in self._get_all_options():
|
| 283 |
+
assert option.dest is not None
|
| 284 |
+
default = defaults.get(option.dest)
|
| 285 |
+
if isinstance(default, str):
|
| 286 |
+
opt_str = option.get_opt_string()
|
| 287 |
+
defaults[option.dest] = option.check_value(opt_str, default)
|
| 288 |
+
return optparse.Values(defaults)
|
| 289 |
+
|
| 290 |
+
def error(self, msg: str) -> None:
|
| 291 |
+
self.print_usage(sys.stderr)
|
| 292 |
+
self.exit(UNKNOWN_ERROR, f"{msg}\n")
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/cli/req_command.py
ADDED
|
@@ -0,0 +1,506 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Contains the Command base classes that depend on PipSession.
|
| 2 |
+
|
| 3 |
+
The classes in this module are in a separate module so the commands not
|
| 4 |
+
needing download / PackageFinder capability don't unnecessarily import the
|
| 5 |
+
PackageFinder machinery and all its vendored dependencies, etc.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import logging
|
| 9 |
+
import os
|
| 10 |
+
import sys
|
| 11 |
+
from functools import partial
|
| 12 |
+
from optparse import Values
|
| 13 |
+
from typing import Any, List, Optional, Tuple
|
| 14 |
+
|
| 15 |
+
from pip._internal.cache import WheelCache
|
| 16 |
+
from pip._internal.cli import cmdoptions
|
| 17 |
+
from pip._internal.cli.base_command import Command
|
| 18 |
+
from pip._internal.cli.command_context import CommandContextMixIn
|
| 19 |
+
from pip._internal.exceptions import CommandError, PreviousBuildDirError
|
| 20 |
+
from pip._internal.index.collector import LinkCollector
|
| 21 |
+
from pip._internal.index.package_finder import PackageFinder
|
| 22 |
+
from pip._internal.models.selection_prefs import SelectionPreferences
|
| 23 |
+
from pip._internal.models.target_python import TargetPython
|
| 24 |
+
from pip._internal.network.session import PipSession
|
| 25 |
+
from pip._internal.operations.prepare import RequirementPreparer
|
| 26 |
+
from pip._internal.req.constructors import (
|
| 27 |
+
install_req_from_editable,
|
| 28 |
+
install_req_from_line,
|
| 29 |
+
install_req_from_parsed_requirement,
|
| 30 |
+
install_req_from_req_string,
|
| 31 |
+
)
|
| 32 |
+
from pip._internal.req.req_file import parse_requirements
|
| 33 |
+
from pip._internal.req.req_install import InstallRequirement
|
| 34 |
+
from pip._internal.req.req_tracker import RequirementTracker
|
| 35 |
+
from pip._internal.resolution.base import BaseResolver
|
| 36 |
+
from pip._internal.self_outdated_check import pip_self_version_check
|
| 37 |
+
from pip._internal.utils.deprecation import deprecated
|
| 38 |
+
from pip._internal.utils.temp_dir import (
|
| 39 |
+
TempDirectory,
|
| 40 |
+
TempDirectoryTypeRegistry,
|
| 41 |
+
tempdir_kinds,
|
| 42 |
+
)
|
| 43 |
+
from pip._internal.utils.virtualenv import running_under_virtualenv
|
| 44 |
+
|
| 45 |
+
logger = logging.getLogger(__name__)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class SessionCommandMixin(CommandContextMixIn):
|
| 49 |
+
|
| 50 |
+
"""
|
| 51 |
+
A class mixin for command classes needing _build_session().
|
| 52 |
+
"""
|
| 53 |
+
|
| 54 |
+
def __init__(self) -> None:
|
| 55 |
+
super().__init__()
|
| 56 |
+
self._session: Optional[PipSession] = None
|
| 57 |
+
|
| 58 |
+
@classmethod
|
| 59 |
+
def _get_index_urls(cls, options: Values) -> Optional[List[str]]:
|
| 60 |
+
"""Return a list of index urls from user-provided options."""
|
| 61 |
+
index_urls = []
|
| 62 |
+
if not getattr(options, "no_index", False):
|
| 63 |
+
url = getattr(options, "index_url", None)
|
| 64 |
+
if url:
|
| 65 |
+
index_urls.append(url)
|
| 66 |
+
urls = getattr(options, "extra_index_urls", None)
|
| 67 |
+
if urls:
|
| 68 |
+
index_urls.extend(urls)
|
| 69 |
+
# Return None rather than an empty list
|
| 70 |
+
return index_urls or None
|
| 71 |
+
|
| 72 |
+
def get_default_session(self, options: Values) -> PipSession:
|
| 73 |
+
"""Get a default-managed session."""
|
| 74 |
+
if self._session is None:
|
| 75 |
+
self._session = self.enter_context(self._build_session(options))
|
| 76 |
+
# there's no type annotation on requests.Session, so it's
|
| 77 |
+
# automatically ContextManager[Any] and self._session becomes Any,
|
| 78 |
+
# then https://github.com/python/mypy/issues/7696 kicks in
|
| 79 |
+
assert self._session is not None
|
| 80 |
+
return self._session
|
| 81 |
+
|
| 82 |
+
def _build_session(
|
| 83 |
+
self,
|
| 84 |
+
options: Values,
|
| 85 |
+
retries: Optional[int] = None,
|
| 86 |
+
timeout: Optional[int] = None,
|
| 87 |
+
) -> PipSession:
|
| 88 |
+
assert not options.cache_dir or os.path.isabs(options.cache_dir)
|
| 89 |
+
session = PipSession(
|
| 90 |
+
cache=(
|
| 91 |
+
os.path.join(options.cache_dir, "http") if options.cache_dir else None
|
| 92 |
+
),
|
| 93 |
+
retries=retries if retries is not None else options.retries,
|
| 94 |
+
trusted_hosts=options.trusted_hosts,
|
| 95 |
+
index_urls=self._get_index_urls(options),
|
| 96 |
+
)
|
| 97 |
+
|
| 98 |
+
# Handle custom ca-bundles from the user
|
| 99 |
+
if options.cert:
|
| 100 |
+
session.verify = options.cert
|
| 101 |
+
|
| 102 |
+
# Handle SSL client certificate
|
| 103 |
+
if options.client_cert:
|
| 104 |
+
session.cert = options.client_cert
|
| 105 |
+
|
| 106 |
+
# Handle timeouts
|
| 107 |
+
if options.timeout or timeout:
|
| 108 |
+
session.timeout = timeout if timeout is not None else options.timeout
|
| 109 |
+
|
| 110 |
+
# Handle configured proxies
|
| 111 |
+
if options.proxy:
|
| 112 |
+
session.proxies = {
|
| 113 |
+
"http": options.proxy,
|
| 114 |
+
"https": options.proxy,
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
# Determine if we can prompt the user for authentication or not
|
| 118 |
+
session.auth.prompting = not options.no_input
|
| 119 |
+
|
| 120 |
+
return session
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
class IndexGroupCommand(Command, SessionCommandMixin):
|
| 124 |
+
|
| 125 |
+
"""
|
| 126 |
+
Abstract base class for commands with the index_group options.
|
| 127 |
+
|
| 128 |
+
This also corresponds to the commands that permit the pip version check.
|
| 129 |
+
"""
|
| 130 |
+
|
| 131 |
+
def handle_pip_version_check(self, options: Values) -> None:
|
| 132 |
+
"""
|
| 133 |
+
Do the pip version check if not disabled.
|
| 134 |
+
|
| 135 |
+
This overrides the default behavior of not doing the check.
|
| 136 |
+
"""
|
| 137 |
+
# Make sure the index_group options are present.
|
| 138 |
+
assert hasattr(options, "no_index")
|
| 139 |
+
|
| 140 |
+
if options.disable_pip_version_check or options.no_index:
|
| 141 |
+
return
|
| 142 |
+
|
| 143 |
+
# Otherwise, check if we're using the latest version of pip available.
|
| 144 |
+
session = self._build_session(
|
| 145 |
+
options, retries=0, timeout=min(5, options.timeout)
|
| 146 |
+
)
|
| 147 |
+
with session:
|
| 148 |
+
pip_self_version_check(session, options)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
KEEPABLE_TEMPDIR_TYPES = [
|
| 152 |
+
tempdir_kinds.BUILD_ENV,
|
| 153 |
+
tempdir_kinds.EPHEM_WHEEL_CACHE,
|
| 154 |
+
tempdir_kinds.REQ_BUILD,
|
| 155 |
+
]
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
def warn_if_run_as_root() -> None:
|
| 159 |
+
"""Output a warning for sudo users on Unix.
|
| 160 |
+
|
| 161 |
+
In a virtual environment, sudo pip still writes to virtualenv.
|
| 162 |
+
On Windows, users may run pip as Administrator without issues.
|
| 163 |
+
This warning only applies to Unix root users outside of virtualenv.
|
| 164 |
+
"""
|
| 165 |
+
if running_under_virtualenv():
|
| 166 |
+
return
|
| 167 |
+
if not hasattr(os, "getuid"):
|
| 168 |
+
return
|
| 169 |
+
# On Windows, there are no "system managed" Python packages. Installing as
|
| 170 |
+
# Administrator via pip is the correct way of updating system environments.
|
| 171 |
+
#
|
| 172 |
+
# We choose sys.platform over utils.compat.WINDOWS here to enable Mypy platform
|
| 173 |
+
# checks: https://mypy.readthedocs.io/en/stable/common_issues.html
|
| 174 |
+
if sys.platform == "win32" or sys.platform == "cygwin":
|
| 175 |
+
return
|
| 176 |
+
|
| 177 |
+
if os.getuid() != 0:
|
| 178 |
+
return
|
| 179 |
+
|
| 180 |
+
logger.warning(
|
| 181 |
+
"Running pip as the 'root' user can result in broken permissions and "
|
| 182 |
+
"conflicting behaviour with the system package manager. "
|
| 183 |
+
"It is recommended to use a virtual environment instead: "
|
| 184 |
+
"https://pip.pypa.io/warnings/venv"
|
| 185 |
+
)
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def with_cleanup(func: Any) -> Any:
|
| 189 |
+
"""Decorator for common logic related to managing temporary
|
| 190 |
+
directories.
|
| 191 |
+
"""
|
| 192 |
+
|
| 193 |
+
def configure_tempdir_registry(registry: TempDirectoryTypeRegistry) -> None:
|
| 194 |
+
for t in KEEPABLE_TEMPDIR_TYPES:
|
| 195 |
+
registry.set_delete(t, False)
|
| 196 |
+
|
| 197 |
+
def wrapper(
|
| 198 |
+
self: RequirementCommand, options: Values, args: List[Any]
|
| 199 |
+
) -> Optional[int]:
|
| 200 |
+
assert self.tempdir_registry is not None
|
| 201 |
+
if options.no_clean:
|
| 202 |
+
configure_tempdir_registry(self.tempdir_registry)
|
| 203 |
+
|
| 204 |
+
try:
|
| 205 |
+
return func(self, options, args)
|
| 206 |
+
except PreviousBuildDirError:
|
| 207 |
+
# This kind of conflict can occur when the user passes an explicit
|
| 208 |
+
# build directory with a pre-existing folder. In that case we do
|
| 209 |
+
# not want to accidentally remove it.
|
| 210 |
+
configure_tempdir_registry(self.tempdir_registry)
|
| 211 |
+
raise
|
| 212 |
+
|
| 213 |
+
return wrapper
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
class RequirementCommand(IndexGroupCommand):
|
| 217 |
+
def __init__(self, *args: Any, **kw: Any) -> None:
|
| 218 |
+
super().__init__(*args, **kw)
|
| 219 |
+
|
| 220 |
+
self.cmd_opts.add_option(cmdoptions.no_clean())
|
| 221 |
+
|
| 222 |
+
@staticmethod
|
| 223 |
+
def determine_resolver_variant(options: Values) -> str:
|
| 224 |
+
"""Determines which resolver should be used, based on the given options."""
|
| 225 |
+
if "legacy-resolver" in options.deprecated_features_enabled:
|
| 226 |
+
return "legacy"
|
| 227 |
+
|
| 228 |
+
return "2020-resolver"
|
| 229 |
+
|
| 230 |
+
@staticmethod
|
| 231 |
+
def determine_build_failure_suppression(options: Values) -> bool:
|
| 232 |
+
"""Determines whether build failures should be suppressed and backtracked on."""
|
| 233 |
+
if "backtrack-on-build-failures" not in options.deprecated_features_enabled:
|
| 234 |
+
return False
|
| 235 |
+
|
| 236 |
+
if "legacy-resolver" in options.deprecated_features_enabled:
|
| 237 |
+
raise CommandError("Cannot backtrack with legacy resolver.")
|
| 238 |
+
|
| 239 |
+
deprecated(
|
| 240 |
+
reason=(
|
| 241 |
+
"Backtracking on build failures can mask issues related to how "
|
| 242 |
+
"a package generates metadata or builds a wheel. This flag will "
|
| 243 |
+
"be removed in pip 22.2."
|
| 244 |
+
),
|
| 245 |
+
gone_in=None,
|
| 246 |
+
replacement=(
|
| 247 |
+
"avoiding known-bad versions by explicitly telling pip to ignore them "
|
| 248 |
+
"(either directly as requirements, or via a constraints file)"
|
| 249 |
+
),
|
| 250 |
+
feature_flag=None,
|
| 251 |
+
issue=10655,
|
| 252 |
+
)
|
| 253 |
+
return True
|
| 254 |
+
|
| 255 |
+
@classmethod
|
| 256 |
+
def make_requirement_preparer(
|
| 257 |
+
cls,
|
| 258 |
+
temp_build_dir: TempDirectory,
|
| 259 |
+
options: Values,
|
| 260 |
+
req_tracker: RequirementTracker,
|
| 261 |
+
session: PipSession,
|
| 262 |
+
finder: PackageFinder,
|
| 263 |
+
use_user_site: bool,
|
| 264 |
+
download_dir: Optional[str] = None,
|
| 265 |
+
verbosity: int = 0,
|
| 266 |
+
) -> RequirementPreparer:
|
| 267 |
+
"""
|
| 268 |
+
Create a RequirementPreparer instance for the given parameters.
|
| 269 |
+
"""
|
| 270 |
+
temp_build_dir_path = temp_build_dir.path
|
| 271 |
+
assert temp_build_dir_path is not None
|
| 272 |
+
|
| 273 |
+
resolver_variant = cls.determine_resolver_variant(options)
|
| 274 |
+
if resolver_variant == "2020-resolver":
|
| 275 |
+
lazy_wheel = "fast-deps" in options.features_enabled
|
| 276 |
+
if lazy_wheel:
|
| 277 |
+
logger.warning(
|
| 278 |
+
"pip is using lazily downloaded wheels using HTTP "
|
| 279 |
+
"range requests to obtain dependency information. "
|
| 280 |
+
"This experimental feature is enabled through "
|
| 281 |
+
"--use-feature=fast-deps and it is not ready for "
|
| 282 |
+
"production."
|
| 283 |
+
)
|
| 284 |
+
else:
|
| 285 |
+
lazy_wheel = False
|
| 286 |
+
if "fast-deps" in options.features_enabled:
|
| 287 |
+
logger.warning(
|
| 288 |
+
"fast-deps has no effect when used with the legacy resolver."
|
| 289 |
+
)
|
| 290 |
+
|
| 291 |
+
in_tree_build = "out-of-tree-build" not in options.deprecated_features_enabled
|
| 292 |
+
if "in-tree-build" in options.features_enabled:
|
| 293 |
+
deprecated(
|
| 294 |
+
reason="In-tree builds are now the default.",
|
| 295 |
+
replacement="to remove the --use-feature=in-tree-build flag",
|
| 296 |
+
gone_in="22.1",
|
| 297 |
+
)
|
| 298 |
+
if "out-of-tree-build" in options.deprecated_features_enabled:
|
| 299 |
+
deprecated(
|
| 300 |
+
reason="Out-of-tree builds are deprecated.",
|
| 301 |
+
replacement=None,
|
| 302 |
+
gone_in="22.1",
|
| 303 |
+
)
|
| 304 |
+
|
| 305 |
+
if options.progress_bar not in {"on", "off"}:
|
| 306 |
+
deprecated(
|
| 307 |
+
reason="Custom progress bar styles are deprecated",
|
| 308 |
+
replacement="to use the default progress bar style.",
|
| 309 |
+
gone_in="22.1",
|
| 310 |
+
)
|
| 311 |
+
|
| 312 |
+
return RequirementPreparer(
|
| 313 |
+
build_dir=temp_build_dir_path,
|
| 314 |
+
src_dir=options.src_dir,
|
| 315 |
+
download_dir=download_dir,
|
| 316 |
+
build_isolation=options.build_isolation,
|
| 317 |
+
req_tracker=req_tracker,
|
| 318 |
+
session=session,
|
| 319 |
+
progress_bar=options.progress_bar,
|
| 320 |
+
finder=finder,
|
| 321 |
+
require_hashes=options.require_hashes,
|
| 322 |
+
use_user_site=use_user_site,
|
| 323 |
+
lazy_wheel=lazy_wheel,
|
| 324 |
+
verbosity=verbosity,
|
| 325 |
+
in_tree_build=in_tree_build,
|
| 326 |
+
)
|
| 327 |
+
|
| 328 |
+
@classmethod
|
| 329 |
+
def make_resolver(
|
| 330 |
+
cls,
|
| 331 |
+
preparer: RequirementPreparer,
|
| 332 |
+
finder: PackageFinder,
|
| 333 |
+
options: Values,
|
| 334 |
+
wheel_cache: Optional[WheelCache] = None,
|
| 335 |
+
use_user_site: bool = False,
|
| 336 |
+
ignore_installed: bool = True,
|
| 337 |
+
ignore_requires_python: bool = False,
|
| 338 |
+
force_reinstall: bool = False,
|
| 339 |
+
upgrade_strategy: str = "to-satisfy-only",
|
| 340 |
+
use_pep517: Optional[bool] = None,
|
| 341 |
+
py_version_info: Optional[Tuple[int, ...]] = None,
|
| 342 |
+
) -> BaseResolver:
|
| 343 |
+
"""
|
| 344 |
+
Create a Resolver instance for the given parameters.
|
| 345 |
+
"""
|
| 346 |
+
make_install_req = partial(
|
| 347 |
+
install_req_from_req_string,
|
| 348 |
+
isolated=options.isolated_mode,
|
| 349 |
+
use_pep517=use_pep517,
|
| 350 |
+
)
|
| 351 |
+
suppress_build_failures = cls.determine_build_failure_suppression(options)
|
| 352 |
+
resolver_variant = cls.determine_resolver_variant(options)
|
| 353 |
+
# The long import name and duplicated invocation is needed to convince
|
| 354 |
+
# Mypy into correctly typechecking. Otherwise it would complain the
|
| 355 |
+
# "Resolver" class being redefined.
|
| 356 |
+
if resolver_variant == "2020-resolver":
|
| 357 |
+
import pip._internal.resolution.resolvelib.resolver
|
| 358 |
+
|
| 359 |
+
return pip._internal.resolution.resolvelib.resolver.Resolver(
|
| 360 |
+
preparer=preparer,
|
| 361 |
+
finder=finder,
|
| 362 |
+
wheel_cache=wheel_cache,
|
| 363 |
+
make_install_req=make_install_req,
|
| 364 |
+
use_user_site=use_user_site,
|
| 365 |
+
ignore_dependencies=options.ignore_dependencies,
|
| 366 |
+
ignore_installed=ignore_installed,
|
| 367 |
+
ignore_requires_python=ignore_requires_python,
|
| 368 |
+
force_reinstall=force_reinstall,
|
| 369 |
+
upgrade_strategy=upgrade_strategy,
|
| 370 |
+
py_version_info=py_version_info,
|
| 371 |
+
suppress_build_failures=suppress_build_failures,
|
| 372 |
+
)
|
| 373 |
+
import pip._internal.resolution.legacy.resolver
|
| 374 |
+
|
| 375 |
+
return pip._internal.resolution.legacy.resolver.Resolver(
|
| 376 |
+
preparer=preparer,
|
| 377 |
+
finder=finder,
|
| 378 |
+
wheel_cache=wheel_cache,
|
| 379 |
+
make_install_req=make_install_req,
|
| 380 |
+
use_user_site=use_user_site,
|
| 381 |
+
ignore_dependencies=options.ignore_dependencies,
|
| 382 |
+
ignore_installed=ignore_installed,
|
| 383 |
+
ignore_requires_python=ignore_requires_python,
|
| 384 |
+
force_reinstall=force_reinstall,
|
| 385 |
+
upgrade_strategy=upgrade_strategy,
|
| 386 |
+
py_version_info=py_version_info,
|
| 387 |
+
)
|
| 388 |
+
|
| 389 |
+
def get_requirements(
|
| 390 |
+
self,
|
| 391 |
+
args: List[str],
|
| 392 |
+
options: Values,
|
| 393 |
+
finder: PackageFinder,
|
| 394 |
+
session: PipSession,
|
| 395 |
+
) -> List[InstallRequirement]:
|
| 396 |
+
"""
|
| 397 |
+
Parse command-line arguments into the corresponding requirements.
|
| 398 |
+
"""
|
| 399 |
+
requirements: List[InstallRequirement] = []
|
| 400 |
+
for filename in options.constraints:
|
| 401 |
+
for parsed_req in parse_requirements(
|
| 402 |
+
filename,
|
| 403 |
+
constraint=True,
|
| 404 |
+
finder=finder,
|
| 405 |
+
options=options,
|
| 406 |
+
session=session,
|
| 407 |
+
):
|
| 408 |
+
req_to_add = install_req_from_parsed_requirement(
|
| 409 |
+
parsed_req,
|
| 410 |
+
isolated=options.isolated_mode,
|
| 411 |
+
user_supplied=False,
|
| 412 |
+
)
|
| 413 |
+
requirements.append(req_to_add)
|
| 414 |
+
|
| 415 |
+
for req in args:
|
| 416 |
+
req_to_add = install_req_from_line(
|
| 417 |
+
req,
|
| 418 |
+
None,
|
| 419 |
+
isolated=options.isolated_mode,
|
| 420 |
+
use_pep517=options.use_pep517,
|
| 421 |
+
user_supplied=True,
|
| 422 |
+
)
|
| 423 |
+
requirements.append(req_to_add)
|
| 424 |
+
|
| 425 |
+
for req in options.editables:
|
| 426 |
+
req_to_add = install_req_from_editable(
|
| 427 |
+
req,
|
| 428 |
+
user_supplied=True,
|
| 429 |
+
isolated=options.isolated_mode,
|
| 430 |
+
use_pep517=options.use_pep517,
|
| 431 |
+
)
|
| 432 |
+
requirements.append(req_to_add)
|
| 433 |
+
|
| 434 |
+
# NOTE: options.require_hashes may be set if --require-hashes is True
|
| 435 |
+
for filename in options.requirements:
|
| 436 |
+
for parsed_req in parse_requirements(
|
| 437 |
+
filename, finder=finder, options=options, session=session
|
| 438 |
+
):
|
| 439 |
+
req_to_add = install_req_from_parsed_requirement(
|
| 440 |
+
parsed_req,
|
| 441 |
+
isolated=options.isolated_mode,
|
| 442 |
+
use_pep517=options.use_pep517,
|
| 443 |
+
user_supplied=True,
|
| 444 |
+
)
|
| 445 |
+
requirements.append(req_to_add)
|
| 446 |
+
|
| 447 |
+
# If any requirement has hash options, enable hash checking.
|
| 448 |
+
if any(req.has_hash_options for req in requirements):
|
| 449 |
+
options.require_hashes = True
|
| 450 |
+
|
| 451 |
+
if not (args or options.editables or options.requirements):
|
| 452 |
+
opts = {"name": self.name}
|
| 453 |
+
if options.find_links:
|
| 454 |
+
raise CommandError(
|
| 455 |
+
"You must give at least one requirement to {name} "
|
| 456 |
+
'(maybe you meant "pip {name} {links}"?)'.format(
|
| 457 |
+
**dict(opts, links=" ".join(options.find_links))
|
| 458 |
+
)
|
| 459 |
+
)
|
| 460 |
+
else:
|
| 461 |
+
raise CommandError(
|
| 462 |
+
"You must give at least one requirement to {name} "
|
| 463 |
+
'(see "pip help {name}")'.format(**opts)
|
| 464 |
+
)
|
| 465 |
+
|
| 466 |
+
return requirements
|
| 467 |
+
|
| 468 |
+
@staticmethod
|
| 469 |
+
def trace_basic_info(finder: PackageFinder) -> None:
|
| 470 |
+
"""
|
| 471 |
+
Trace basic information about the provided objects.
|
| 472 |
+
"""
|
| 473 |
+
# Display where finder is looking for packages
|
| 474 |
+
search_scope = finder.search_scope
|
| 475 |
+
locations = search_scope.get_formatted_locations()
|
| 476 |
+
if locations:
|
| 477 |
+
logger.info(locations)
|
| 478 |
+
|
| 479 |
+
def _build_package_finder(
|
| 480 |
+
self,
|
| 481 |
+
options: Values,
|
| 482 |
+
session: PipSession,
|
| 483 |
+
target_python: Optional[TargetPython] = None,
|
| 484 |
+
ignore_requires_python: Optional[bool] = None,
|
| 485 |
+
) -> PackageFinder:
|
| 486 |
+
"""
|
| 487 |
+
Create a package finder appropriate to this requirement command.
|
| 488 |
+
|
| 489 |
+
:param ignore_requires_python: Whether to ignore incompatible
|
| 490 |
+
"Requires-Python" values in links. Defaults to False.
|
| 491 |
+
"""
|
| 492 |
+
link_collector = LinkCollector.create(session, options=options)
|
| 493 |
+
selection_prefs = SelectionPreferences(
|
| 494 |
+
allow_yanked=True,
|
| 495 |
+
format_control=options.format_control,
|
| 496 |
+
allow_all_prereleases=options.pre,
|
| 497 |
+
prefer_binary=options.prefer_binary,
|
| 498 |
+
ignore_requires_python=ignore_requires_python,
|
| 499 |
+
)
|
| 500 |
+
|
| 501 |
+
return PackageFinder.create(
|
| 502 |
+
link_collector=link_collector,
|
| 503 |
+
selection_prefs=selection_prefs,
|
| 504 |
+
target_python=target_python,
|
| 505 |
+
use_deprecated_html5lib="html5lib" in options.deprecated_features_enabled,
|
| 506 |
+
)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/check.cpython-310.pyc
ADDED
|
Binary file (1.62 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/completion.cpython-310.pyc
ADDED
|
Binary file (3.19 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/configuration.cpython-310.pyc
ADDED
|
Binary file (8.37 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/debug.cpython-310.pyc
ADDED
|
Binary file (6.72 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/download.cpython-310.pyc
ADDED
|
Binary file (4.03 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/index.cpython-310.pyc
ADDED
|
Binary file (4.68 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/install.cpython-310.pyc
ADDED
|
Binary file (17.8 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/list.cpython-310.pyc
ADDED
|
Binary file (10.4 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/show.cpython-310.pyc
ADDED
|
Binary file (6.17 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/commands/__pycache__/wheel.cpython-310.pyc
ADDED
|
Binary file (4.89 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/candidate.cpython-310.pyc
ADDED
|
Binary file (1.46 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/index.cpython-310.pyc
ADDED
|
Binary file (1.28 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/scheme.cpython-310.pyc
ADDED
|
Binary file (1.08 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/selection_prefs.cpython-310.pyc
ADDED
|
Binary file (1.74 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/target_python.cpython-310.pyc
ADDED
|
Binary file (3.49 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/__pycache__/wheel.cpython-310.pyc
ADDED
|
Binary file (4.41 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/candidate.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pip._vendor.packaging.version import parse as parse_version
|
| 2 |
+
|
| 3 |
+
from pip._internal.models.link import Link
|
| 4 |
+
from pip._internal.utils.models import KeyBasedCompareMixin
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class InstallationCandidate(KeyBasedCompareMixin):
|
| 8 |
+
"""Represents a potential "candidate" for installation."""
|
| 9 |
+
|
| 10 |
+
__slots__ = ["name", "version", "link"]
|
| 11 |
+
|
| 12 |
+
def __init__(self, name: str, version: str, link: Link) -> None:
|
| 13 |
+
self.name = name
|
| 14 |
+
self.version = parse_version(version)
|
| 15 |
+
self.link = link
|
| 16 |
+
|
| 17 |
+
super().__init__(
|
| 18 |
+
key=(self.name, self.version, self.link),
|
| 19 |
+
defining_class=InstallationCandidate,
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
def __repr__(self) -> str:
|
| 23 |
+
return "<InstallationCandidate({!r}, {!r}, {!r})>".format(
|
| 24 |
+
self.name,
|
| 25 |
+
self.version,
|
| 26 |
+
self.link,
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
def __str__(self) -> str:
|
| 30 |
+
return "{!r} candidate (version {} at {})".format(
|
| 31 |
+
self.name,
|
| 32 |
+
self.version,
|
| 33 |
+
self.link,
|
| 34 |
+
)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/link.py
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import functools
|
| 2 |
+
import logging
|
| 3 |
+
import os
|
| 4 |
+
import posixpath
|
| 5 |
+
import re
|
| 6 |
+
import urllib.parse
|
| 7 |
+
from typing import TYPE_CHECKING, Dict, List, NamedTuple, Optional, Tuple, Union
|
| 8 |
+
|
| 9 |
+
from pip._internal.utils.filetypes import WHEEL_EXTENSION
|
| 10 |
+
from pip._internal.utils.hashes import Hashes
|
| 11 |
+
from pip._internal.utils.misc import (
|
| 12 |
+
redact_auth_from_url,
|
| 13 |
+
split_auth_from_netloc,
|
| 14 |
+
splitext,
|
| 15 |
+
)
|
| 16 |
+
from pip._internal.utils.models import KeyBasedCompareMixin
|
| 17 |
+
from pip._internal.utils.urls import path_to_url, url_to_path
|
| 18 |
+
|
| 19 |
+
if TYPE_CHECKING:
|
| 20 |
+
from pip._internal.index.collector import HTMLPage
|
| 21 |
+
|
| 22 |
+
logger = logging.getLogger(__name__)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
_SUPPORTED_HASHES = ("sha1", "sha224", "sha384", "sha256", "sha512", "md5")
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class Link(KeyBasedCompareMixin):
|
| 29 |
+
"""Represents a parsed link from a Package Index's simple URL"""
|
| 30 |
+
|
| 31 |
+
__slots__ = [
|
| 32 |
+
"_parsed_url",
|
| 33 |
+
"_url",
|
| 34 |
+
"comes_from",
|
| 35 |
+
"requires_python",
|
| 36 |
+
"yanked_reason",
|
| 37 |
+
"cache_link_parsing",
|
| 38 |
+
]
|
| 39 |
+
|
| 40 |
+
def __init__(
|
| 41 |
+
self,
|
| 42 |
+
url: str,
|
| 43 |
+
comes_from: Optional[Union[str, "HTMLPage"]] = None,
|
| 44 |
+
requires_python: Optional[str] = None,
|
| 45 |
+
yanked_reason: Optional[str] = None,
|
| 46 |
+
cache_link_parsing: bool = True,
|
| 47 |
+
) -> None:
|
| 48 |
+
"""
|
| 49 |
+
:param url: url of the resource pointed to (href of the link)
|
| 50 |
+
:param comes_from: instance of HTMLPage where the link was found,
|
| 51 |
+
or string.
|
| 52 |
+
:param requires_python: String containing the `Requires-Python`
|
| 53 |
+
metadata field, specified in PEP 345. This may be specified by
|
| 54 |
+
a data-requires-python attribute in the HTML link tag, as
|
| 55 |
+
described in PEP 503.
|
| 56 |
+
:param yanked_reason: the reason the file has been yanked, if the
|
| 57 |
+
file has been yanked, or None if the file hasn't been yanked.
|
| 58 |
+
This is the value of the "data-yanked" attribute, if present, in
|
| 59 |
+
a simple repository HTML link. If the file has been yanked but
|
| 60 |
+
no reason was provided, this should be the empty string. See
|
| 61 |
+
PEP 592 for more information and the specification.
|
| 62 |
+
:param cache_link_parsing: A flag that is used elsewhere to determine
|
| 63 |
+
whether resources retrieved from this link
|
| 64 |
+
should be cached. PyPI index urls should
|
| 65 |
+
generally have this set to False, for
|
| 66 |
+
example.
|
| 67 |
+
"""
|
| 68 |
+
|
| 69 |
+
# url can be a UNC windows share
|
| 70 |
+
if url.startswith("\\\\"):
|
| 71 |
+
url = path_to_url(url)
|
| 72 |
+
|
| 73 |
+
self._parsed_url = urllib.parse.urlsplit(url)
|
| 74 |
+
# Store the url as a private attribute to prevent accidentally
|
| 75 |
+
# trying to set a new value.
|
| 76 |
+
self._url = url
|
| 77 |
+
|
| 78 |
+
self.comes_from = comes_from
|
| 79 |
+
self.requires_python = requires_python if requires_python else None
|
| 80 |
+
self.yanked_reason = yanked_reason
|
| 81 |
+
|
| 82 |
+
super().__init__(key=url, defining_class=Link)
|
| 83 |
+
|
| 84 |
+
self.cache_link_parsing = cache_link_parsing
|
| 85 |
+
|
| 86 |
+
def __str__(self) -> str:
|
| 87 |
+
if self.requires_python:
|
| 88 |
+
rp = f" (requires-python:{self.requires_python})"
|
| 89 |
+
else:
|
| 90 |
+
rp = ""
|
| 91 |
+
if self.comes_from:
|
| 92 |
+
return "{} (from {}){}".format(
|
| 93 |
+
redact_auth_from_url(self._url), self.comes_from, rp
|
| 94 |
+
)
|
| 95 |
+
else:
|
| 96 |
+
return redact_auth_from_url(str(self._url))
|
| 97 |
+
|
| 98 |
+
def __repr__(self) -> str:
|
| 99 |
+
return f"<Link {self}>"
|
| 100 |
+
|
| 101 |
+
@property
|
| 102 |
+
def url(self) -> str:
|
| 103 |
+
return self._url
|
| 104 |
+
|
| 105 |
+
@property
|
| 106 |
+
def filename(self) -> str:
|
| 107 |
+
path = self.path.rstrip("/")
|
| 108 |
+
name = posixpath.basename(path)
|
| 109 |
+
if not name:
|
| 110 |
+
# Make sure we don't leak auth information if the netloc
|
| 111 |
+
# includes a username and password.
|
| 112 |
+
netloc, user_pass = split_auth_from_netloc(self.netloc)
|
| 113 |
+
return netloc
|
| 114 |
+
|
| 115 |
+
name = urllib.parse.unquote(name)
|
| 116 |
+
assert name, f"URL {self._url!r} produced no filename"
|
| 117 |
+
return name
|
| 118 |
+
|
| 119 |
+
@property
|
| 120 |
+
def file_path(self) -> str:
|
| 121 |
+
return url_to_path(self.url)
|
| 122 |
+
|
| 123 |
+
@property
|
| 124 |
+
def scheme(self) -> str:
|
| 125 |
+
return self._parsed_url.scheme
|
| 126 |
+
|
| 127 |
+
@property
|
| 128 |
+
def netloc(self) -> str:
|
| 129 |
+
"""
|
| 130 |
+
This can contain auth information.
|
| 131 |
+
"""
|
| 132 |
+
return self._parsed_url.netloc
|
| 133 |
+
|
| 134 |
+
@property
|
| 135 |
+
def path(self) -> str:
|
| 136 |
+
return urllib.parse.unquote(self._parsed_url.path)
|
| 137 |
+
|
| 138 |
+
def splitext(self) -> Tuple[str, str]:
|
| 139 |
+
return splitext(posixpath.basename(self.path.rstrip("/")))
|
| 140 |
+
|
| 141 |
+
@property
|
| 142 |
+
def ext(self) -> str:
|
| 143 |
+
return self.splitext()[1]
|
| 144 |
+
|
| 145 |
+
@property
|
| 146 |
+
def url_without_fragment(self) -> str:
|
| 147 |
+
scheme, netloc, path, query, fragment = self._parsed_url
|
| 148 |
+
return urllib.parse.urlunsplit((scheme, netloc, path, query, ""))
|
| 149 |
+
|
| 150 |
+
_egg_fragment_re = re.compile(r"[#&]egg=([^&]*)")
|
| 151 |
+
|
| 152 |
+
@property
|
| 153 |
+
def egg_fragment(self) -> Optional[str]:
|
| 154 |
+
match = self._egg_fragment_re.search(self._url)
|
| 155 |
+
if not match:
|
| 156 |
+
return None
|
| 157 |
+
return match.group(1)
|
| 158 |
+
|
| 159 |
+
_subdirectory_fragment_re = re.compile(r"[#&]subdirectory=([^&]*)")
|
| 160 |
+
|
| 161 |
+
@property
|
| 162 |
+
def subdirectory_fragment(self) -> Optional[str]:
|
| 163 |
+
match = self._subdirectory_fragment_re.search(self._url)
|
| 164 |
+
if not match:
|
| 165 |
+
return None
|
| 166 |
+
return match.group(1)
|
| 167 |
+
|
| 168 |
+
_hash_re = re.compile(
|
| 169 |
+
r"({choices})=([a-f0-9]+)".format(choices="|".join(_SUPPORTED_HASHES))
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
@property
|
| 173 |
+
def hash(self) -> Optional[str]:
|
| 174 |
+
match = self._hash_re.search(self._url)
|
| 175 |
+
if match:
|
| 176 |
+
return match.group(2)
|
| 177 |
+
return None
|
| 178 |
+
|
| 179 |
+
@property
|
| 180 |
+
def hash_name(self) -> Optional[str]:
|
| 181 |
+
match = self._hash_re.search(self._url)
|
| 182 |
+
if match:
|
| 183 |
+
return match.group(1)
|
| 184 |
+
return None
|
| 185 |
+
|
| 186 |
+
@property
|
| 187 |
+
def show_url(self) -> str:
|
| 188 |
+
return posixpath.basename(self._url.split("#", 1)[0].split("?", 1)[0])
|
| 189 |
+
|
| 190 |
+
@property
|
| 191 |
+
def is_file(self) -> bool:
|
| 192 |
+
return self.scheme == "file"
|
| 193 |
+
|
| 194 |
+
def is_existing_dir(self) -> bool:
|
| 195 |
+
return self.is_file and os.path.isdir(self.file_path)
|
| 196 |
+
|
| 197 |
+
@property
|
| 198 |
+
def is_wheel(self) -> bool:
|
| 199 |
+
return self.ext == WHEEL_EXTENSION
|
| 200 |
+
|
| 201 |
+
@property
|
| 202 |
+
def is_vcs(self) -> bool:
|
| 203 |
+
from pip._internal.vcs import vcs
|
| 204 |
+
|
| 205 |
+
return self.scheme in vcs.all_schemes
|
| 206 |
+
|
| 207 |
+
@property
|
| 208 |
+
def is_yanked(self) -> bool:
|
| 209 |
+
return self.yanked_reason is not None
|
| 210 |
+
|
| 211 |
+
@property
|
| 212 |
+
def has_hash(self) -> bool:
|
| 213 |
+
return self.hash_name is not None
|
| 214 |
+
|
| 215 |
+
def is_hash_allowed(self, hashes: Optional[Hashes]) -> bool:
|
| 216 |
+
"""
|
| 217 |
+
Return True if the link has a hash and it is allowed.
|
| 218 |
+
"""
|
| 219 |
+
if hashes is None or not self.has_hash:
|
| 220 |
+
return False
|
| 221 |
+
# Assert non-None so mypy knows self.hash_name and self.hash are str.
|
| 222 |
+
assert self.hash_name is not None
|
| 223 |
+
assert self.hash is not None
|
| 224 |
+
|
| 225 |
+
return hashes.is_hash_allowed(self.hash_name, hex_digest=self.hash)
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
class _CleanResult(NamedTuple):
|
| 229 |
+
"""Convert link for equivalency check.
|
| 230 |
+
|
| 231 |
+
This is used in the resolver to check whether two URL-specified requirements
|
| 232 |
+
likely point to the same distribution and can be considered equivalent. This
|
| 233 |
+
equivalency logic avoids comparing URLs literally, which can be too strict
|
| 234 |
+
(e.g. "a=1&b=2" vs "b=2&a=1") and produce conflicts unexpecting to users.
|
| 235 |
+
|
| 236 |
+
Currently this does three things:
|
| 237 |
+
|
| 238 |
+
1. Drop the basic auth part. This is technically wrong since a server can
|
| 239 |
+
serve different content based on auth, but if it does that, it is even
|
| 240 |
+
impossible to guarantee two URLs without auth are equivalent, since
|
| 241 |
+
the user can input different auth information when prompted. So the
|
| 242 |
+
practical solution is to assume the auth doesn't affect the response.
|
| 243 |
+
2. Parse the query to avoid the ordering issue. Note that ordering under the
|
| 244 |
+
same key in the query are NOT cleaned; i.e. "a=1&a=2" and "a=2&a=1" are
|
| 245 |
+
still considered different.
|
| 246 |
+
3. Explicitly drop most of the fragment part, except ``subdirectory=`` and
|
| 247 |
+
hash values, since it should have no impact the downloaded content. Note
|
| 248 |
+
that this drops the "egg=" part historically used to denote the requested
|
| 249 |
+
project (and extras), which is wrong in the strictest sense, but too many
|
| 250 |
+
people are supplying it inconsistently to cause superfluous resolution
|
| 251 |
+
conflicts, so we choose to also ignore them.
|
| 252 |
+
"""
|
| 253 |
+
|
| 254 |
+
parsed: urllib.parse.SplitResult
|
| 255 |
+
query: Dict[str, List[str]]
|
| 256 |
+
subdirectory: str
|
| 257 |
+
hashes: Dict[str, str]
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def _clean_link(link: Link) -> _CleanResult:
|
| 261 |
+
parsed = link._parsed_url
|
| 262 |
+
netloc = parsed.netloc.rsplit("@", 1)[-1]
|
| 263 |
+
# According to RFC 8089, an empty host in file: means localhost.
|
| 264 |
+
if parsed.scheme == "file" and not netloc:
|
| 265 |
+
netloc = "localhost"
|
| 266 |
+
fragment = urllib.parse.parse_qs(parsed.fragment)
|
| 267 |
+
if "egg" in fragment:
|
| 268 |
+
logger.debug("Ignoring egg= fragment in %s", link)
|
| 269 |
+
try:
|
| 270 |
+
# If there are multiple subdirectory values, use the first one.
|
| 271 |
+
# This matches the behavior of Link.subdirectory_fragment.
|
| 272 |
+
subdirectory = fragment["subdirectory"][0]
|
| 273 |
+
except (IndexError, KeyError):
|
| 274 |
+
subdirectory = ""
|
| 275 |
+
# If there are multiple hash values under the same algorithm, use the
|
| 276 |
+
# first one. This matches the behavior of Link.hash_value.
|
| 277 |
+
hashes = {k: fragment[k][0] for k in _SUPPORTED_HASHES if k in fragment}
|
| 278 |
+
return _CleanResult(
|
| 279 |
+
parsed=parsed._replace(netloc=netloc, query="", fragment=""),
|
| 280 |
+
query=urllib.parse.parse_qs(parsed.query),
|
| 281 |
+
subdirectory=subdirectory,
|
| 282 |
+
hashes=hashes,
|
| 283 |
+
)
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
@functools.lru_cache(maxsize=None)
|
| 287 |
+
def links_equivalent(link1: Link, link2: Link) -> bool:
|
| 288 |
+
return _clean_link(link1) == _clean_link(link2)
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/scheme.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
For types associated with installation schemes.
|
| 3 |
+
|
| 4 |
+
For a general overview of available schemes and their context, see
|
| 5 |
+
https://docs.python.org/3/install/index.html#alternate-installation.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
SCHEME_KEYS = ["platlib", "purelib", "headers", "scripts", "data"]
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class Scheme:
|
| 13 |
+
"""A Scheme holds paths which are used as the base directories for
|
| 14 |
+
artifacts associated with a Python package.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
__slots__ = SCHEME_KEYS
|
| 18 |
+
|
| 19 |
+
def __init__(
|
| 20 |
+
self,
|
| 21 |
+
platlib: str,
|
| 22 |
+
purelib: str,
|
| 23 |
+
headers: str,
|
| 24 |
+
scripts: str,
|
| 25 |
+
data: str,
|
| 26 |
+
) -> None:
|
| 27 |
+
self.platlib = platlib
|
| 28 |
+
self.purelib = purelib
|
| 29 |
+
self.headers = headers
|
| 30 |
+
self.scripts = scripts
|
| 31 |
+
self.data = data
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/models/search_scope.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import itertools
|
| 2 |
+
import logging
|
| 3 |
+
import os
|
| 4 |
+
import posixpath
|
| 5 |
+
import urllib.parse
|
| 6 |
+
from typing import List
|
| 7 |
+
|
| 8 |
+
from pip._vendor.packaging.utils import canonicalize_name
|
| 9 |
+
|
| 10 |
+
from pip._internal.models.index import PyPI
|
| 11 |
+
from pip._internal.utils.compat import has_tls
|
| 12 |
+
from pip._internal.utils.misc import normalize_path, redact_auth_from_url
|
| 13 |
+
|
| 14 |
+
logger = logging.getLogger(__name__)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class SearchScope:
|
| 18 |
+
|
| 19 |
+
"""
|
| 20 |
+
Encapsulates the locations that pip is configured to search.
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
__slots__ = ["find_links", "index_urls"]
|
| 24 |
+
|
| 25 |
+
@classmethod
|
| 26 |
+
def create(
|
| 27 |
+
cls,
|
| 28 |
+
find_links: List[str],
|
| 29 |
+
index_urls: List[str],
|
| 30 |
+
) -> "SearchScope":
|
| 31 |
+
"""
|
| 32 |
+
Create a SearchScope object after normalizing the `find_links`.
|
| 33 |
+
"""
|
| 34 |
+
# Build find_links. If an argument starts with ~, it may be
|
| 35 |
+
# a local file relative to a home directory. So try normalizing
|
| 36 |
+
# it and if it exists, use the normalized version.
|
| 37 |
+
# This is deliberately conservative - it might be fine just to
|
| 38 |
+
# blindly normalize anything starting with a ~...
|
| 39 |
+
built_find_links: List[str] = []
|
| 40 |
+
for link in find_links:
|
| 41 |
+
if link.startswith("~"):
|
| 42 |
+
new_link = normalize_path(link)
|
| 43 |
+
if os.path.exists(new_link):
|
| 44 |
+
link = new_link
|
| 45 |
+
built_find_links.append(link)
|
| 46 |
+
|
| 47 |
+
# If we don't have TLS enabled, then WARN if anyplace we're looking
|
| 48 |
+
# relies on TLS.
|
| 49 |
+
if not has_tls():
|
| 50 |
+
for link in itertools.chain(index_urls, built_find_links):
|
| 51 |
+
parsed = urllib.parse.urlparse(link)
|
| 52 |
+
if parsed.scheme == "https":
|
| 53 |
+
logger.warning(
|
| 54 |
+
"pip is configured with locations that require "
|
| 55 |
+
"TLS/SSL, however the ssl module in Python is not "
|
| 56 |
+
"available."
|
| 57 |
+
)
|
| 58 |
+
break
|
| 59 |
+
|
| 60 |
+
return cls(
|
| 61 |
+
find_links=built_find_links,
|
| 62 |
+
index_urls=index_urls,
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
def __init__(
|
| 66 |
+
self,
|
| 67 |
+
find_links: List[str],
|
| 68 |
+
index_urls: List[str],
|
| 69 |
+
) -> None:
|
| 70 |
+
self.find_links = find_links
|
| 71 |
+
self.index_urls = index_urls
|
| 72 |
+
|
| 73 |
+
def get_formatted_locations(self) -> str:
|
| 74 |
+
lines = []
|
| 75 |
+
redacted_index_urls = []
|
| 76 |
+
if self.index_urls and self.index_urls != [PyPI.simple_url]:
|
| 77 |
+
for url in self.index_urls:
|
| 78 |
+
|
| 79 |
+
redacted_index_url = redact_auth_from_url(url)
|
| 80 |
+
|
| 81 |
+
# Parse the URL
|
| 82 |
+
purl = urllib.parse.urlsplit(redacted_index_url)
|
| 83 |
+
|
| 84 |
+
# URL is generally invalid if scheme and netloc is missing
|
| 85 |
+
# there are issues with Python and URL parsing, so this test
|
| 86 |
+
# is a bit crude. See bpo-20271, bpo-23505. Python doesn't
|
| 87 |
+
# always parse invalid URLs correctly - it should raise
|
| 88 |
+
# exceptions for malformed URLs
|
| 89 |
+
if not purl.scheme and not purl.netloc:
|
| 90 |
+
logger.warning(
|
| 91 |
+
'The index url "%s" seems invalid, please provide a scheme.',
|
| 92 |
+
redacted_index_url,
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
redacted_index_urls.append(redacted_index_url)
|
| 96 |
+
|
| 97 |
+
lines.append(
|
| 98 |
+
"Looking in indexes: {}".format(", ".join(redacted_index_urls))
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
if self.find_links:
|
| 102 |
+
lines.append(
|
| 103 |
+
"Looking in links: {}".format(
|
| 104 |
+
", ".join(redact_auth_from_url(url) for url in self.find_links)
|
| 105 |
+
)
|
| 106 |
+
)
|
| 107 |
+
return "\n".join(lines)
|
| 108 |
+
|
| 109 |
+
def get_index_urls_locations(self, project_name: str) -> List[str]:
|
| 110 |
+
"""Returns the locations found via self.index_urls
|
| 111 |
+
|
| 112 |
+
Checks the url_name on the main (first in the list) index and
|
| 113 |
+
use this url_name to produce all locations
|
| 114 |
+
"""
|
| 115 |
+
|
| 116 |
+
def mkurl_pypi_url(url: str) -> str:
|
| 117 |
+
loc = posixpath.join(
|
| 118 |
+
url, urllib.parse.quote(canonicalize_name(project_name))
|
| 119 |
+
)
|
| 120 |
+
# For maximum compatibility with easy_install, ensure the path
|
| 121 |
+
# ends in a trailing slash. Although this isn't in the spec
|
| 122 |
+
# (and PyPI can handle it without the slash) some other index
|
| 123 |
+
# implementations might break if they relied on easy_install's
|
| 124 |
+
# behavior.
|
| 125 |
+
if not loc.endswith("/"):
|
| 126 |
+
loc = loc + "/"
|
| 127 |
+
return loc
|
| 128 |
+
|
| 129 |
+
return [mkurl_pypi_url(url) for url in self.index_urls]
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/network/__pycache__/lazy_wheel.cpython-310.pyc
ADDED
|
Binary file (8.45 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/network/__pycache__/session.cpython-310.pyc
ADDED
|
Binary file (10.8 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (247 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/__pycache__/check.cpython-310.pyc
ADDED
|
Binary file (4.06 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/__pycache__/freeze.cpython-310.pyc
ADDED
|
Binary file (6.25 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/__pycache__/prepare.cpython-310.pyc
ADDED
|
Binary file (14.9 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__init__.py
ADDED
|
File without changes
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (253 Bytes). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/metadata_legacy.cpython-310.pyc
ADDED
|
Binary file (2.43 kB). View file
|
|
|
material/dataset/xpsdeeplearning/.venv/lib/python3.10/site-packages/pip/_internal/operations/build/__pycache__/wheel_editable.cpython-310.pyc
ADDED
|
Binary file (1.49 kB). View file
|
|
|