From cf4adb61460764d2f1eeaf1e4057ea8ac81a8bd2 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Thu, 7 Jul 2022 06:51:49 -0400 Subject: [PATCH] Add news fragment and fix rewrite import list to include requests. --- news/5147.vendor.rst | 1 + pipenv/patched/safety/safety.py | 2 +- pipenv/vendor/pip_shims/compat.py | 42 +++++++++++++++---------------- pipenv/vendor/pip_shims/models.py | 2 +- pipenv/vendor/pip_shims/shims.py | 2 +- pipenv/vendor/pip_shims/utils.py | 10 ++++---- tasks/vendoring/__init__.py | 1 + 7 files changed, 31 insertions(+), 29 deletions(-) create mode 100644 news/5147.vendor.rst diff --git a/news/5147.vendor.rst b/news/5147.vendor.rst new file mode 100644 index 00000000..1f4ebd6a --- /dev/null +++ b/news/5147.vendor.rst @@ -0,0 +1 @@ +Vendor in latest version of ``pip==22.1.2``. diff --git a/pipenv/patched/safety/safety.py b/pipenv/patched/safety/safety.py index 7002da2f..f846441f 100644 --- a/pipenv/patched/safety/safety.py +++ b/pipenv/patched/safety/safety.py @@ -5,7 +5,7 @@ import os import time from collections import namedtuple -import requests +import pipenv.patched.notpip._vendor.requests as requests from pipenv.vendor.packaging.specifiers import SpecifierSet from .constants import (API_MIRRORS, CACHE_FILE, CACHE_LICENSES_VALID_SECONDS, diff --git a/pipenv/vendor/pip_shims/compat.py b/pipenv/vendor/pip_shims/compat.py index fdc67aed..34722d71 100644 --- a/pipenv/vendor/pip_shims/compat.py +++ b/pipenv/vendor/pip_shims/compat.py @@ -11,7 +11,7 @@ import re import sys import types -from packaging import specifiers +from pipenv.vendor.packaging import specifiers from .environment import MYPY_RUNNING from .utils import ( @@ -48,7 +48,7 @@ if MYPY_RUNNING: Union, ) - from requests import Session + from pipenv.patched.notpip._vendor.requests import Session from .utils import TShim, TShimmedFunc, TShimmedPath @@ -380,7 +380,7 @@ def partial_command(shimmed_path, cmd_mapping=None): """ Maps a default set of arguments across all members of a :class:`~pip_shims.models.ShimmedPath` instance, specifically for - :class:`~pip._internal.command.Command` instances which need + :class:`~pipenv.patched.notpip._internal.command.Command` instances which need `summary` and `name` arguments. :param :class:`~pip_shims.models.ShimmedPath` shimmed_path: A @@ -506,7 +506,7 @@ def get_requirement_set( :param :class:`~pip_shims.models.ShimmedPathCollection` wheel_cache_provider: A context manager provider which resolves to a `WheelCache` instance - :param install_command: A :class:`~pip._internal.commands.install.InstallCommand` + :param install_command: A :class:`~pipenv.patched.notpip._internal.commands.install.InstallCommand` instance which is used to generate the finder. :param :class:`~pip_shims.models.ShimmedPathCollection` req_set_provider: A provider to build requirement set instances. @@ -543,7 +543,7 @@ def get_requirement_set( :param install_cmd_provider: A shim for providing new install command instances. :type install_cmd_provider: :class:`~pip_shims.models.ShimmedPathCollection` :return: A new requirement set instance - :rtype: :class:`~pip._internal.req.req_set.RequirementSet` + :rtype: :class:`~pipenv.patched.notpip._internal.req.req_set.RequirementSet` """ wheel_cache_provider = resolve_possible_shim(wheel_cache_provider) req_set_provider = resolve_possible_shim(req_set_provider) @@ -598,13 +598,13 @@ def get_package_finder( # type: (...) -> TFinder """Shim for compatibility to generate package finders. - Build and return a :class:`~pip._internal.index.package_finder.PackageFinder` - instance using the :class:`~pip._internal.commands.install.InstallCommand` helper + Build and return a :class:`~pipenv.patched.notpip._internal.index.package_finder.PackageFinder` + instance using the :class:`~pipenv.patched.notpip._internal.commands.install.InstallCommand` helper method to construct the finder, shimmed with backports as needed for compatibility. :param install_cmd_provider: A shim for providing new install command instances. :type install_cmd_provider: :class:`~pip_shims.models.ShimmedPathCollection` - :param install_cmd: A :class:`~pip._internal.commands.install.InstallCommand` + :param install_cmd: A :class:`~pipenv.patched.notpip._internal.commands.install.InstallCommand` instance which is used to generate the finder. :param optparse.Values options: An optional :class:`optparse.Values` instance generated by calling `install_cmd.parser.parse_args()` typically. @@ -615,15 +615,15 @@ def get_package_finder( :param Optional[str] abi: The target abi to support, e.g. "cp38" :param Optional[str] implementation: An optional implementation string for limiting searches to a specific implementation, e.g. "cp" or "py" - :param target_python: A :class:`~pip._internal.models.target_python.TargetPython` + :param target_python: A :class:`~pipenv.patched.notpip._internal.models.target_python.TargetPython` instance (will be translated to alternate arguments if necessary on incompatible pip versions). :param Optional[bool] ignore_requires_python: Whether to ignore `requires_python` on resulting candidates, only valid after pip version 19.3.1 :param target_python_builder: A 'TargetPython' builder (e.g. the class itself, uninstantiated) - :return: A :class:`pip._internal.index.package_finder.PackageFinder` instance - :rtype: :class:`pip._internal.index.package_finder.PackageFinder` + :return: A :class:`pipenv.patched.notpip._internal.index.package_finder.PackageFinder` instance + :rtype: :class:`pipenv.patched.notpip._internal.index.package_finder.PackageFinder` :Example: @@ -719,7 +719,7 @@ def shim_unpack( # (...) -> None """ Accepts all parameters that have been valid to pass - to :func:`pip._internal.download.unpack_url` and selects or + to :func:`pipenv.patched.notpip._internal.download.unpack_url` and selects or drops parameters as needed before invoking the provided callable. @@ -728,9 +728,9 @@ def shim_unpack( :param str download_dir: The directory to download the file to :param TShimmedFunc tempdir_manager_provider: A callable or shim referring to `global_tempdir_manager` function from pip or a shimmed no-op context manager - :param Optional[:class:`~pip._internal.req.req_install.InstallRequirement`] ireq: + :param Optional[:class:`~pipenv.patched.notpip._internal.req.req_install.InstallRequirement`] ireq: an Install Requirement instance, defaults to None - :param Optional[:class:`~pip._internal.models.link.Link`] link: A Link instance, + :param Optional[:class:`~pipenv.patched.notpip._internal.models.link.Link`] link: A Link instance, defaults to None. :param Optional[str] location: A location or source directory if the target is a VCS url, defaults to None. @@ -872,7 +872,7 @@ def make_preparer( the finder, session, and options if needed, defaults to None :param Optional[TShimmedFunc] finder_provider: A package finder provider :yield: A new requirement preparer instance - :rtype: ContextManager[:class:`~pip._internal.operations.prepare.RequirementPreparer`] + :rtype: ContextManager[:class:`~pipenv.patched.notpip._internal.operations.prepare.RequirementPreparer`] :Example: @@ -889,7 +889,7 @@ def make_preparer( ... options=pip_options, finder=finder, session=session, install_cmd=ic ... ) as preparer: ... print(preparer) - + """ preparer_fn = resolve_possible_shim(preparer_fn) downloader_provider = resolve_possible_shim(downloader_provider) @@ -1068,7 +1068,7 @@ def get_resolver( the finder, session, and options if needed, defaults to None. :param bool use_pep517: Whether to use the pep517 build process. :return: A new resolver instance. - :rtype: :class:`~pip._internal.legacy_resolve.Resolver` + :rtype: :class:`~pipenv.patched.notpip._internal.legacy_resolve.Resolver` :Example: @@ -1217,7 +1217,7 @@ def resolve( # noqa:C901 Maps a dictionary of names to corresponding ``InstallRequirement`` values. - :param :class:`~pip._internal.req.req_install.InstallRequirement` ireq: An + :param :class:`~pipenv.patched.notpip._internal.req.req_install.InstallRequirement` ireq: An InstallRequirement to initiate the resolution process :param :class:`~pip_shims.models.ShimmedPathCollection` reqset_provider: A provider to build requirement set instances. @@ -1241,7 +1241,7 @@ def resolve( # noqa:C901 :param Optional[Values] options: Pip options to use if needed, defaults to None :param Optional[TSession] session: Existing session to use for getting requirements, defaults to None - :param :class:`~pip._internal.legacy_resolve.Resolver` resolver: A pre-existing + :param :class:`~pipenv.patched.notpip._internal.legacy_resolve.Resolver` resolver: A pre-existing resolver instance to use for resolution :param Optional[TFinder] finder: The package finder to use during resolution, defaults to None. @@ -1274,8 +1274,8 @@ def resolve( # noqa:C901 :param bool check_supported_wheels: Whether to check support of wheels before including them in resolution. :return: A dictionary mapping requirements to corresponding - :class:`~pip._internal.req.req_install.InstallRequirement`s - :rtype: :class:`~pip._internal.req.req_install.InstallRequirement` + :class:`~pipenv.patched.notpip._internal.req.req_install.InstallRequirement`s + :rtype: :class:`~pipenv.patched.notpip._internal.req.req_install.InstallRequirement` :Example: diff --git a/pipenv/vendor/pip_shims/models.py b/pipenv/vendor/pip_shims/models.py index 0ed63c38..049e385c 100644 --- a/pipenv/vendor/pip_shims/models.py +++ b/pipenv/vendor/pip_shims/models.py @@ -76,7 +76,7 @@ class PipVersion(Sequence): version, round_prereleases_up=True, base_import_path=None, - vendor_import_path="pip._vendor", + vendor_import_path="pipenv.patched.notpip._vendor", ): # type: (str, bool, Optional[str], str) -> None self.version = version diff --git a/pipenv/vendor/pip_shims/shims.py b/pipenv/vendor/pip_shims/shims.py index fb029378..48f6c432 100644 --- a/pipenv/vendor/pip_shims/shims.py +++ b/pipenv/vendor/pip_shims/shims.py @@ -7,7 +7,7 @@ from __future__ import absolute_import import sys import types -from packaging.version import parse as parse_version +from pipenv.vendor.packaging.version import parse as parse_version from .models import ( ShimmedPathCollection, diff --git a/pipenv/vendor/pip_shims/utils.py b/pipenv/vendor/pip_shims/utils.py index ec32082d..2a31a4df 100644 --- a/pipenv/vendor/pip_shims/utils.py +++ b/pipenv/vendor/pip_shims/utils.py @@ -130,10 +130,10 @@ def split_package(module, subimport=None): :Example: >>> from pip_shims.utils import split_package - >>> split_package("pip._internal.req.req_install", subimport="InstallRequirement") - ("pip._internal.req.req_install", "InstallRequirement") - >>> split_package("pip._internal.cli.base_command") - ("pip._internal.cli", "base_command") + >>> split_package("pipenv.patched.notpip._internal.req.req_install", subimport="InstallRequirement") + ("pipenv.patched.notpip._internal.req.req_install", "InstallRequirement") + >>> split_package("pipenv.patched.notpip._internal.cli.base_command") + ("pipenv.patched.notpip._internal.cli", "base_command") """ package = None if subimport: @@ -387,7 +387,7 @@ def get_allowed_args(fn_or_class): try: signature = inspect.signature(fn_or_class) except AttributeError: - import funcsigs + import pipenv.vendor.funcsigs as funcsigs signature = funcsigs.signature(fn_or_class) args = [] diff --git a/tasks/vendoring/__init__.py b/tasks/vendoring/__init__.py index ba8d49d9..063b2bf6 100644 --- a/tasks/vendoring/__init__.py +++ b/tasks/vendoring/__init__.py @@ -68,6 +68,7 @@ PATCHED_RENAMES = {"pip": "notpip"} LIBRARY_RENAMES = { "pip": "pipenv.patched.notpip", "functools32": "pipenv.vendor.backports.functools_lru_cache", + "requests": "pipenv.patched.notpip._vendor.requests", } GLOBAL_REPLACEMENT = [