Voice et bot modif
This commit is contained in:
parent
189d56026b
commit
7333a22bcd
10774 changed files with 634644 additions and 933308 deletions
|
|
@ -9,16 +9,15 @@ pass on state. To be consistent, all options will follow this design.
|
|||
|
||||
# The following comment should be removed at some point in the future.
|
||||
# mypy: strict-optional=False
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
import textwrap
|
||||
from functools import partial
|
||||
from optparse import SUPPRESS_HELP, Option, OptionGroup, OptionParser, Values
|
||||
from textwrap import dedent
|
||||
from typing import Any, Callable
|
||||
from typing import Any, Callable, Dict, Optional, Tuple
|
||||
|
||||
from pip._vendor.packaging.utils import canonicalize_name
|
||||
|
||||
|
|
@ -48,7 +47,7 @@ def raise_option_error(parser: OptionParser, option: Option, msg: str) -> None:
|
|||
parser.error(msg)
|
||||
|
||||
|
||||
def make_option_group(group: dict[str, Any], parser: ConfigOptionParser) -> OptionGroup:
|
||||
def make_option_group(group: Dict[str, Any], parser: ConfigOptionParser) -> OptionGroup:
|
||||
"""
|
||||
Return an OptionGroup object
|
||||
group -- assumed to be dict with 'name' and 'options' keys
|
||||
|
|
@ -100,29 +99,6 @@ def check_dist_restriction(options: Values, check_target: bool = False) -> None:
|
|||
)
|
||||
|
||||
|
||||
def check_build_constraints(options: Values) -> None:
|
||||
"""Function for validating build constraints options.
|
||||
|
||||
:param options: The OptionParser options.
|
||||
"""
|
||||
if hasattr(options, "build_constraints") and options.build_constraints:
|
||||
if not options.build_isolation:
|
||||
raise CommandError(
|
||||
"--build-constraint cannot be used with --no-build-isolation."
|
||||
)
|
||||
|
||||
# Import here to avoid circular imports
|
||||
from pip._internal.network.session import PipSession
|
||||
from pip._internal.req.req_file import get_file_content
|
||||
|
||||
# Eagerly check build constraints file contents
|
||||
# is valid so that we don't fail in when trying
|
||||
# to check constraints in isolated build process
|
||||
with PipSession() as session:
|
||||
for constraint_file in options.build_constraints:
|
||||
get_file_content(constraint_file, session)
|
||||
|
||||
|
||||
def _path_option_check(option: Option, opt: str, value: str) -> str:
|
||||
return os.path.expanduser(value)
|
||||
|
||||
|
|
@ -183,7 +159,8 @@ require_virtualenv: Callable[..., Option] = partial(
|
|||
action="store_true",
|
||||
default=False,
|
||||
help=(
|
||||
"Allow pip to only run in a virtual environment; exit with an error otherwise."
|
||||
"Allow pip to only run in a virtual environment; "
|
||||
"exit with an error otherwise."
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -249,13 +226,9 @@ progress_bar: Callable[..., Option] = partial(
|
|||
"--progress-bar",
|
||||
dest="progress_bar",
|
||||
type="choice",
|
||||
choices=["auto", "on", "off", "raw"],
|
||||
default="auto",
|
||||
help=(
|
||||
"Specify whether the progress bar should be used. In 'auto'"
|
||||
" mode, --quiet will suppress all progress bars."
|
||||
" [auto, on, off, raw] (default: auto)"
|
||||
),
|
||||
choices=["on", "off"],
|
||||
default="on",
|
||||
help="Specify whether the progress bar should be used [on, off] (default: on)",
|
||||
)
|
||||
|
||||
log: Callable[..., Option] = partial(
|
||||
|
|
@ -287,8 +260,8 @@ keyring_provider: Callable[..., Option] = partial(
|
|||
default="auto",
|
||||
help=(
|
||||
"Enable the credential lookup via the keyring library if user input is allowed."
|
||||
" Specify which mechanism to use [auto, disabled, import, subprocess]."
|
||||
" (default: %default)"
|
||||
" Specify which mechanism to use [disabled, import, subprocess]."
|
||||
" (default: disabled)"
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -307,17 +280,8 @@ retries: Callable[..., Option] = partial(
|
|||
dest="retries",
|
||||
type="int",
|
||||
default=5,
|
||||
help="Maximum attempts to establish a new HTTP connection. (default: %default)",
|
||||
)
|
||||
|
||||
resume_retries: Callable[..., Option] = partial(
|
||||
Option,
|
||||
"--resume-retries",
|
||||
dest="resume_retries",
|
||||
type="int",
|
||||
default=5,
|
||||
help="Maximum attempts to resume or restart an incomplete download. "
|
||||
"(default: %default)",
|
||||
help="Maximum number of retries each connection should attempt "
|
||||
"(default %default times).",
|
||||
)
|
||||
|
||||
timeout: Callable[..., Option] = partial(
|
||||
|
|
@ -451,21 +415,6 @@ def constraints() -> Option:
|
|||
)
|
||||
|
||||
|
||||
def build_constraints() -> Option:
|
||||
return Option(
|
||||
"--build-constraint",
|
||||
dest="build_constraints",
|
||||
action="append",
|
||||
type="str",
|
||||
default=[],
|
||||
metavar="file",
|
||||
help=(
|
||||
"Constrain build dependencies using the given constraints file. "
|
||||
"This option can be used multiple times."
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def requirements() -> Option:
|
||||
return Option(
|
||||
"-r",
|
||||
|
|
@ -596,7 +545,7 @@ platforms: Callable[..., Option] = partial(
|
|||
|
||||
|
||||
# This was made a separate function for unit-testing purposes.
|
||||
def _convert_python_version(value: str) -> tuple[tuple[int, ...], str | None]:
|
||||
def _convert_python_version(value: str) -> Tuple[Tuple[int, ...], Optional[str]]:
|
||||
"""
|
||||
Convert a version string like "3", "37", or "3.7.3" into a tuple of ints.
|
||||
|
||||
|
|
@ -784,46 +733,6 @@ no_deps: Callable[..., Option] = partial(
|
|||
help="Don't install package dependencies.",
|
||||
)
|
||||
|
||||
|
||||
def _handle_dependency_group(
|
||||
option: Option, opt: str, value: str, parser: OptionParser
|
||||
) -> None:
|
||||
"""
|
||||
Process a value provided for the --group option.
|
||||
|
||||
Splits on the rightmost ":", and validates that the path (if present) ends
|
||||
in `pyproject.toml`. Defaults the path to `pyproject.toml` when one is not given.
|
||||
|
||||
`:` cannot appear in dependency group names, so this is a safe and simple parse.
|
||||
|
||||
This is an optparse.Option callback for the dependency_groups option.
|
||||
"""
|
||||
path, sep, groupname = value.rpartition(":")
|
||||
if not sep:
|
||||
path = "pyproject.toml"
|
||||
else:
|
||||
# check for 'pyproject.toml' filenames using pathlib
|
||||
if pathlib.PurePath(path).name != "pyproject.toml":
|
||||
msg = "group paths use 'pyproject.toml' filenames"
|
||||
raise_option_error(parser, option=option, msg=msg)
|
||||
|
||||
parser.values.dependency_groups.append((path, groupname))
|
||||
|
||||
|
||||
dependency_groups: Callable[..., Option] = partial(
|
||||
Option,
|
||||
"--group",
|
||||
dest="dependency_groups",
|
||||
default=[],
|
||||
type=str,
|
||||
action="callback",
|
||||
callback=_handle_dependency_group,
|
||||
metavar="[path:]group",
|
||||
help='Install a named dependency-group from a "pyproject.toml" file. '
|
||||
'If a path is given, the name of the file must be "pyproject.toml". '
|
||||
'Defaults to using "pyproject.toml" in the current directory.',
|
||||
)
|
||||
|
||||
ignore_requires_python: Callable[..., Option] = partial(
|
||||
Option,
|
||||
"--ignore-requires-python",
|
||||
|
|
@ -849,16 +758,62 @@ check_build_deps: Callable[..., Option] = partial(
|
|||
dest="check_build_deps",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Check the build dependencies.",
|
||||
help="Check the build dependencies when PEP517 is used.",
|
||||
)
|
||||
|
||||
|
||||
def _handle_no_use_pep517(
|
||||
option: Option, opt: str, value: str, parser: OptionParser
|
||||
) -> None:
|
||||
"""
|
||||
Process a value provided for the --no-use-pep517 option.
|
||||
|
||||
This is an optparse.Option callback for the no_use_pep517 option.
|
||||
"""
|
||||
# Since --no-use-pep517 doesn't accept arguments, the value argument
|
||||
# will be None if --no-use-pep517 is passed via the command-line.
|
||||
# However, the value can be non-None if the option is triggered e.g.
|
||||
# by an environment variable, for example "PIP_NO_USE_PEP517=true".
|
||||
if value is not None:
|
||||
msg = """A value was passed for --no-use-pep517,
|
||||
probably using either the PIP_NO_USE_PEP517 environment variable
|
||||
or the "no-use-pep517" config file option. Use an appropriate value
|
||||
of the PIP_USE_PEP517 environment variable or the "use-pep517"
|
||||
config file option instead.
|
||||
"""
|
||||
raise_option_error(parser, option=option, msg=msg)
|
||||
|
||||
# If user doesn't wish to use pep517, we check if setuptools and wheel are installed
|
||||
# and raise error if it is not.
|
||||
packages = ("setuptools", "wheel")
|
||||
if not all(importlib.util.find_spec(package) for package in packages):
|
||||
msg = (
|
||||
f"It is not possible to use --no-use-pep517 "
|
||||
f"without {' and '.join(packages)} installed."
|
||||
)
|
||||
raise_option_error(parser, option=option, msg=msg)
|
||||
|
||||
# Otherwise, --no-use-pep517 was passed via the command-line.
|
||||
parser.values.use_pep517 = False
|
||||
|
||||
|
||||
use_pep517: Any = partial(
|
||||
Option,
|
||||
"--use-pep517",
|
||||
dest="use_pep517",
|
||||
action="store_true",
|
||||
default=True,
|
||||
default=None,
|
||||
help="Use PEP 517 for building source distributions "
|
||||
"(use --no-use-pep517 to force legacy behaviour).",
|
||||
)
|
||||
|
||||
no_use_pep517: Any = partial(
|
||||
Option,
|
||||
"--no-use-pep517",
|
||||
dest="use_pep517",
|
||||
action="callback",
|
||||
callback=_handle_no_use_pep517,
|
||||
default=None,
|
||||
help=SUPPRESS_HELP,
|
||||
)
|
||||
|
||||
|
|
@ -891,11 +846,30 @@ config_settings: Callable[..., Option] = partial(
|
|||
action="callback",
|
||||
callback=_handle_config_settings,
|
||||
metavar="settings",
|
||||
help="Configuration settings to be passed to the build backend. "
|
||||
help="Configuration settings to be passed to the PEP 517 build backend. "
|
||||
"Settings take the form KEY=VALUE. Use multiple --config-settings options "
|
||||
"to pass multiple keys to the backend.",
|
||||
)
|
||||
|
||||
build_options: Callable[..., Option] = partial(
|
||||
Option,
|
||||
"--build-option",
|
||||
dest="build_options",
|
||||
metavar="options",
|
||||
action="append",
|
||||
help="Extra arguments to be supplied to 'setup.py bdist_wheel'.",
|
||||
)
|
||||
|
||||
global_options: Callable[..., Option] = partial(
|
||||
Option,
|
||||
"--global-option",
|
||||
dest="global_options",
|
||||
action="append",
|
||||
metavar="options",
|
||||
help="Extra global options to be supplied to the setup.py "
|
||||
"call before the install or bdist_wheel command.",
|
||||
)
|
||||
|
||||
no_clean: Callable[..., Option] = partial(
|
||||
Option,
|
||||
"--no-clean",
|
||||
|
|
@ -913,20 +887,12 @@ pre: Callable[..., Option] = partial(
|
|||
"pip only finds stable versions.",
|
||||
)
|
||||
|
||||
json: Callable[..., Option] = partial(
|
||||
Option,
|
||||
"--json",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help="Output data in a machine-readable JSON format.",
|
||||
)
|
||||
|
||||
disable_pip_version_check: Callable[..., Option] = partial(
|
||||
Option,
|
||||
"--disable-pip-version-check",
|
||||
dest="disable_pip_version_check",
|
||||
action="store_true",
|
||||
default=False,
|
||||
default=True,
|
||||
help="Don't periodically check PyPI to determine whether a new version "
|
||||
"of pip is available for download. Implied with --no-index.",
|
||||
)
|
||||
|
|
@ -937,7 +903,7 @@ root_user_action: Callable[..., Option] = partial(
|
|||
dest="root_user_action",
|
||||
default="warn",
|
||||
choices=["warn", "ignore"],
|
||||
help="Action if pip is run as a root user [warn, ignore] (default: warn)",
|
||||
help="Action if pip is run as a root user. By default, a warning message is shown.",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -1024,13 +990,12 @@ no_python_version_warning: Callable[..., Option] = partial(
|
|||
dest="no_python_version_warning",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help=SUPPRESS_HELP, # No-op, a hold-over from the Python 2->3 transition.
|
||||
help="Silence deprecation warnings for upcoming unsupported Pythons.",
|
||||
)
|
||||
|
||||
|
||||
# Features that are now always on. A warning is printed if they are used.
|
||||
ALWAYS_ENABLED_FEATURES = [
|
||||
"truststore", # always on since 24.2
|
||||
"no-binary-enable-wheel-cache", # always on since 23.1
|
||||
]
|
||||
|
||||
|
|
@ -1043,7 +1008,7 @@ use_new_feature: Callable[..., Option] = partial(
|
|||
default=[],
|
||||
choices=[
|
||||
"fast-deps",
|
||||
"build-constraint",
|
||||
"truststore",
|
||||
]
|
||||
+ ALWAYS_ENABLED_FEATURES,
|
||||
help="Enable new functionality, that may be backward incompatible.",
|
||||
|
|
@ -1058,16 +1023,16 @@ use_deprecated_feature: Callable[..., Option] = partial(
|
|||
default=[],
|
||||
choices=[
|
||||
"legacy-resolver",
|
||||
"legacy-certs",
|
||||
],
|
||||
help=("Enable deprecated functionality, that will be removed in the future."),
|
||||
)
|
||||
|
||||
|
||||
##########
|
||||
# groups #
|
||||
##########
|
||||
|
||||
general_group: dict[str, Any] = {
|
||||
general_group: Dict[str, Any] = {
|
||||
"name": "General Options",
|
||||
"options": [
|
||||
help_,
|
||||
|
|
@ -1095,11 +1060,10 @@ general_group: dict[str, Any] = {
|
|||
no_python_version_warning,
|
||||
use_new_feature,
|
||||
use_deprecated_feature,
|
||||
resume_retries,
|
||||
],
|
||||
}
|
||||
|
||||
index_group: dict[str, Any] = {
|
||||
index_group: Dict[str, Any] = {
|
||||
"name": "Package Index Options",
|
||||
"options": [
|
||||
index_url,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue