Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendor in pip 22.1.2 #5166

Merged
merged 4 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pipenv/patched/notpip/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List, Optional

__version__ = "22.0.4"
__version__ = "22.1.2"


def main(args: Optional[List[str]] = None) -> int:
Expand Down
18 changes: 13 additions & 5 deletions pipenv/patched/notpip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from collections import OrderedDict
from sysconfig import get_paths
from types import TracebackType
from typing import TYPE_CHECKING, Iterable, Iterator, List, Optional, Set, Tuple, Type
from typing import TYPE_CHECKING, Generator, Iterable, List, Optional, Set, Tuple, Type

from pipenv.patched.notpip._vendor.certifi import where
from pipenv.patched.notpip._vendor.packaging.requirements import Requirement
Expand All @@ -20,7 +20,7 @@
from pip import __file__ as pip_location
from pipenv.patched.notpip._internal.cli.spinners import open_spinner
from pipenv.patched.notpip._internal.locations import get_platlib, get_prefixed_libs, get_purelib
from pipenv.patched.notpip._internal.metadata import get_environment
from pipenv.patched.notpip._internal.metadata import get_default_environment, get_environment
from pipenv.patched.notpip._internal.utils.subprocess import call_subprocess
from pipenv.patched.notpip._internal.utils.temp_dir import TempDirectory, tempdir_kinds

Expand All @@ -42,7 +42,7 @@ def __init__(self, path: str) -> None:


@contextlib.contextmanager
def _create_standalone_pip() -> Iterator[str]:
def _create_standalone_pip() -> Generator[str, None, None]:
"""Create a "standalone pip" zip file.

The zip file's content is identical to the currently-running pip.
Expand Down Expand Up @@ -168,9 +168,17 @@ def check_requirements(
missing = set()
conflicting = set()
if reqs:
env = get_environment(self._lib_dirs)
env = (
get_environment(self._lib_dirs)
if hasattr(self, "_lib_dirs")
else get_default_environment()
)
for req_str in reqs:
req = Requirement(req_str)
# We're explicitly evaluating with an empty extra value, since build
# environments are not provided any mechanism to select specific extras.
if req.marker is not None and not req.marker.evaluate({"extra": ""}):
continue
dist = env.get_distribution(req.name)
if not dist:
missing.add(req_str)
Expand All @@ -179,7 +187,7 @@ def check_requirements(
installed_req_str = f"{req.name}=={dist.version}"
else:
installed_req_str = f"{req.name}==={dist.version}"
if dist.version not in req.specifier:
if not req.specifier.contains(dist.version, prereleases=True):
conflicting.add((installed_req_str, req_str))
# FIXME: Consider direct URL?
return conflicting, missing
Expand Down
2 changes: 1 addition & 1 deletion pipenv/patched/notpip/_internal/cli/base_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def exc_logging_wrapper(*args: Any) -> int:
assert isinstance(status, int)
return status
except DiagnosticPipError as exc:
logger.error("[present-diagnostic] %s", exc)
logger.error("[present-rich] %s", exc)
logger.debug("Exception information:", exc_info=True)

return ERROR
Expand Down
66 changes: 56 additions & 10 deletions pipenv/patched/notpip/_internal/cli/cmdoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# The following comment should be removed at some point in the future.
# mypy: strict-optional=False

import importlib.util
import logging
import os
import textwrap
Expand All @@ -21,7 +22,6 @@
from pipenv.patched.notpip._vendor.packaging.utils import canonicalize_name

from pipenv.patched.notpip._internal.cli.parser import ConfigOptionParser
from pipenv.patched.notpip._internal.cli.progress_bars import BAR_TYPES
from pipenv.patched.notpip._internal.exceptions import CommandError
from pipenv.patched.notpip._internal.locations import USER_CACHE_DIR, get_src_prefix
from pipenv.patched.notpip._internal.models.format_control import FormatControl
Expand Down Expand Up @@ -236,13 +236,9 @@ class PipOption(Option):
"--progress-bar",
dest="progress_bar",
type="choice",
choices=list(BAR_TYPES.keys()),
choices=["on", "off"],
default="on",
help=(
"Specify type of progress to be displayed ["
+ "|".join(BAR_TYPES.keys())
+ "] (default: %default)"
),
help="Specify whether the progress bar should be used [on, off] (default: on)",
)

log: Callable[..., Option] = partial(
Expand Down Expand Up @@ -272,7 +268,7 @@ class PipOption(Option):
dest="proxy",
type="str",
default="",
help="Specify a proxy in the form [user:passwd@]proxy.server:port.",
help="Specify a proxy in the form scheme://[user:passwd@]proxy.server:port.",
)

retries: Callable[..., Option] = partial(
Expand Down Expand Up @@ -753,6 +749,15 @@ def _handle_no_cache_dir(
"if this option is used.",
)

check_build_deps: Callable[..., Option] = partial(
Option,
"--check-build-dependencies",
dest="check_build_deps",
action="store_true",
default=False,
help="Check the build dependencies when PEP517 is used.",
)


def _handle_no_use_pep517(
option: Option, opt: str, value: str, parser: OptionParser
Expand All @@ -775,6 +780,12 @@ def _handle_no_use_pep517(
"""
raise_option_error(parser, option=option, msg=msg)

# If user doesn't wish to use pep517, we check if setuptools is installed
# and raise error if it is not.
if not importlib.util.find_spec("setuptools"):
msg = "It is not possible to use --no-use-pep517 without setuptools installed."
raise_option_error(parser, option=option, msg=msg)

# Otherwise, --no-use-pep517 was passed via the command-line.
parser.values.use_pep517 = False

Expand All @@ -799,6 +810,33 @@ def _handle_no_use_pep517(
help=SUPPRESS_HELP,
)


def _handle_config_settings(
option: Option, opt_str: str, value: str, parser: OptionParser
) -> None:
key, sep, val = value.partition("=")
if sep != "=":
parser.error(f"Arguments to {opt_str} must be of the form KEY=VAL") # noqa
dest = getattr(parser.values, option.dest)
if dest is None:
dest = {}
setattr(parser.values, option.dest, dest)
dest[key] = val


config_settings: Callable[..., Option] = partial(
Option,
"--config-settings",
dest="config_settings",
type=str,
action="callback",
callback=_handle_config_settings,
metavar="settings",
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.",
)

install_options: Callable[..., Option] = partial(
Option,
"--install-option",
Expand Down Expand Up @@ -858,6 +896,15 @@ def _handle_no_use_pep517(
"of pip is available for download. Implied with --no-index.",
)

root_user_action: Callable[..., Option] = partial(
Option,
"--root-user-action",
dest="root_user_action",
default="warn",
choices=["warn", "ignore"],
help="Action if pip is run as a root user. By default, a warning message is shown.",
)


def _handle_merge_hash(
option: Option, opt_str: str, value: str, parser: OptionParser
Expand Down Expand Up @@ -953,7 +1000,7 @@ def check_list_path_option(options: Values) -> None:
metavar="feature",
action="append",
default=[],
choices=["2020-resolver", "fast-deps", "in-tree-build"],
choices=["2020-resolver", "fast-deps"],
help="Enable new functionality, that may be backward incompatible.",
)

Expand All @@ -966,7 +1013,6 @@ def check_list_path_option(options: Values) -> None:
default=[],
choices=[
"legacy-resolver",
"out-of-tree-build",
"backtrack-on-build-failures",
"html5lib",
],
Expand Down
4 changes: 2 additions & 2 deletions pipenv/patched/notpip/_internal/cli/command_context.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from contextlib import ExitStack, contextmanager
from typing import ContextManager, Iterator, TypeVar
from typing import ContextManager, Generator, TypeVar

_T = TypeVar("_T", covariant=True)

Expand All @@ -11,7 +11,7 @@ def __init__(self) -> None:
self._main_context = ExitStack()

@contextmanager
def main_context(self) -> Iterator[None]:
def main_context(self) -> Generator[None, None, None]:
assert not self._in_main_context

self._in_main_context = True
Expand Down
6 changes: 4 additions & 2 deletions pipenv/patched/notpip/_internal/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
import textwrap
from contextlib import suppress
from typing import Any, Dict, Iterator, List, Tuple
from typing import Any, Dict, Generator, List, Tuple

from pipenv.patched.notpip._internal.cli.status_codes import UNKNOWN_ERROR
from pipenv.patched.notpip._internal.configuration import Configuration, ConfigurationError
Expand Down Expand Up @@ -175,7 +175,9 @@ def check_default(self, option: optparse.Option, key: str, val: Any) -> Any:
print(f"An error occurred during configuration: {exc}")
sys.exit(3)

def _get_ordered_configuration_items(self) -> Iterator[Tuple[str, Any]]:
def _get_ordered_configuration_items(
self,
) -> Generator[Tuple[str, Any], None, None]:
# Configuration gives keys in an unordered manner. Order them.
override_order = ["global", self.name, ":env:"]

Expand Down
Loading