From bb9d8ff32262e9dd2cb33a2181a457e3288c0c24 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Wed, 19 Apr 2023 06:41:01 -0400 Subject: [PATCH 1/2] Vendor in lateest requirementslib. --- pipenv/vendor/requirementslib/__init__.py | 2 +- .../requirementslib/models/old_pip_utils.py | 75 ++----------------- .../requirementslib/models/setup_info.py | 27 ++++--- pipenv/vendor/vendor.txt | 2 +- 4 files changed, 24 insertions(+), 82 deletions(-) diff --git a/pipenv/vendor/requirementslib/__init__.py b/pipenv/vendor/requirementslib/__init__.py index f0f834cb30..752a3cd10b 100644 --- a/pipenv/vendor/requirementslib/__init__.py +++ b/pipenv/vendor/requirementslib/__init__.py @@ -5,7 +5,7 @@ from .models.pipfile import Pipfile from .models.requirements import Requirement -__version__ = "2.2.4" +__version__ = "2.2.5" logger = logging.getLogger(__name__) diff --git a/pipenv/vendor/requirementslib/models/old_pip_utils.py b/pipenv/vendor/requirementslib/models/old_pip_utils.py index ca46c69faf..8f51e6af51 100644 --- a/pipenv/vendor/requirementslib/models/old_pip_utils.py +++ b/pipenv/vendor/requirementslib/models/old_pip_utils.py @@ -11,32 +11,19 @@ import shutil import stat -from pipenv.vendor.vistir.path import rmtree - logger = logging.getLogger(__name__) -from typing import Dict, Iterable, List, Optional - -from pipenv.patched.pip._internal.models.link import Link -from pipenv.patched.pip._internal.network.download import Downloader -from pipenv.patched.pip._internal.operations.prepare import ( - File, - get_file_url, - get_http_url, - unpack_vcs_link, -) -from pipenv.patched.pip._internal.utils.hashes import Hashes -from pipenv.patched.pip._internal.utils.unpacking import unpack_file +from typing import Dict, Iterable, List -def is_socket(path): - # type: (str) -> bool +# This can be removed once this pr is merged +# https://github.com/python/cpython/pull/16575 +def is_socket(path: str) -> bool: return stat.S_ISSOCK(os.lstat(path).st_mode) -def copy2_fixed(src, dest): - # type: (str, str) -> None +def copy2_fixed(src: str, dest: str) -> None: """Wrap shutil.copy2() but map errors copying socket files to SpecialFileError as expected. @@ -108,55 +95,3 @@ def ignore(d: str, names: List[str]) -> List[str]: symlinks=True, copy_function=_copy2_ignoring_special_files, ) - - -def old_unpack_url( - link: Link, - location: str, - download: Downloader, - verbosity: int, - download_dir: Optional[str] = None, - hashes: Optional[Hashes] = None, -) -> Optional[File]: - """Unpack link into location, downloading if required. - - :param hashes: A Hashes object, one of whose embedded hashes must match, - or HashMismatch will be raised. If the Hashes is empty, no matches are - required, and unhashable types of requirements (like VCS ones, which - would ordinarily raise HashUnsupported) are allowed. - """ - # non-editable vcs urls - if link.is_vcs: - unpack_vcs_link(link, location, verbosity=verbosity) - return None - - # Once out-of-tree-builds are no longer supported, could potentially - # replace the below condition with `assert not link.is_existing_dir` - # - unpack_url does not need to be called for in-tree-builds. - # - # As further cleanup, _copy_source_tree and accompanying tests can - # be removed. - # - # TODO when use-deprecated=out-of-tree-build is removed - if link.is_existing_dir(): - if os.path.isdir(location): - rmtree(location) - _copy_source_tree(link.file_path, location) - return None - - # file urls - if link.is_file: - file = get_file_url(link, download_dir, hashes=hashes) - # http urls - else: - file = get_http_url( - link, - download, - download_dir, - hashes=hashes, - ) - # unpack the archive to the build dir location. even when only downloading - # archives, they have to be unpacked to parse dependencies, except wheels - if not link.is_wheel: - unpack_file(file.path, location, file.content_type) - return file diff --git a/pipenv/vendor/requirementslib/models/setup_info.py b/pipenv/vendor/requirementslib/models/setup_info.py index 5670924284..96d978af2f 100644 --- a/pipenv/vendor/requirementslib/models/setup_info.py +++ b/pipenv/vendor/requirementslib/models/setup_info.py @@ -18,6 +18,7 @@ from pipenv.patched.pip._vendor.distlib.wheel import Wheel from pipenv.vendor.pep517 import envbuild, wrappers from pipenv.patched.pip._internal.network.download import Downloader +from pipenv.patched.pip._internal.operations.prepare import unpack_url from pipenv.patched.pip._internal.utils.temp_dir import global_tempdir_manager from pipenv.patched.pip._internal.utils.urls import url_to_path from pipenv.patched.pip._vendor.packaging.markers import Marker @@ -36,7 +37,7 @@ from ..environment import MYPY_RUNNING from ..exceptions import RequirementError from ..utils import get_pip_command -from .old_pip_utils import old_unpack_url +from .old_pip_utils import _copy_source_tree from .utils import ( get_default_pyproject_backend, get_name_variants, @@ -1514,16 +1515,22 @@ def from_ireq(cls, ireq, subdir=None, finder=None, session=None): build_location_func(**build_kwargs) ireq.ensure_has_source_dir(kwargs["src_dir"]) location = None - if getattr(ireq, "source_dir", None): + if ireq.source_dir: location = ireq.source_dir - old_unpack_url( - link=ireq.link, - location=location, - download=Downloader(session, "off"), - verbosity=1, - download_dir=download_dir, - hashes=ireq.hashes(True), - ) + + if ireq.link.is_existing_dir(): + if os.path.isdir(location): + rmtree(location) + _copy_source_tree(ireq.link.file_path, location) + else: + unpack_url( + link=ireq.link, + location=location, + download=Downloader(session, "off"), + verbosity=1, + download_dir=download_dir, + hashes=ireq.hashes(True), + ) created = cls.create( ireq.source_dir, subdirectory=subdir, ireq=ireq, kwargs=kwargs, stack=stack ) diff --git a/pipenv/vendor/vendor.txt b/pipenv/vendor/vendor.txt index bd69d20b47..a9c3419d4e 100644 --- a/pipenv/vendor/vendor.txt +++ b/pipenv/vendor/vendor.txt @@ -12,7 +12,7 @@ plette[validation]==0.4.4 ptyprocess==0.7.0 python-dotenv==1.0.0 pythonfinder==1.3.2 -requirementslib==2.2.4 +requirementslib==2.2.5 ruamel.yaml==0.17.21 shellingham==1.5.0.post1 toml==0.10.2 From a5d135de4837aed75a92c4dd11a127ab9be56370 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Wed, 19 Apr 2023 06:43:35 -0400 Subject: [PATCH 2/2] add news fragment --- news/5659.vendor.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/5659.vendor.rst diff --git a/news/5659.vendor.rst b/news/5659.vendor.rst new file mode 100644 index 0000000000..25cdcedeb8 --- /dev/null +++ b/news/5659.vendor.rst @@ -0,0 +1 @@ +Vendor in latest ``requirementslib==2.2.5`` which includes updates for pip 23.1