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 latest requirementslib. #5659

Merged
merged 2 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions news/5659.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Vendor in latest ``requirementslib==2.2.5`` which includes updates for pip 23.1
2 changes: 1 addition & 1 deletion pipenv/vendor/requirementslib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
75 changes: 5 additions & 70 deletions pipenv/vendor/requirementslib/models/old_pip_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
27 changes: 17 additions & 10 deletions pipenv/vendor/requirementslib/models/setup_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down