From addd3ca31a2cc7ff2d0b8f07613998595adb7db9 Mon Sep 17 00:00:00 2001 From: Danny McClanahan <1305167+cosmicexplorer@users.noreply.github.com> Date: Tue, 16 Jun 2020 13:44:03 -0700 Subject: [PATCH] avoid using shallow wheels for non-remote file paths --- src/pip/_internal/network/shallow/httpfile.py | 8 ++++++-- src/pip/_internal/operations/prepare.py | 3 ++- src/pip/_internal/req/req_set.py | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pip/_internal/network/shallow/httpfile.py b/src/pip/_internal/network/shallow/httpfile.py index 4bffed2ab9b..26407cece18 100644 --- a/src/pip/_internal/network/shallow/httpfile.py +++ b/src/pip/_internal/network/shallow/httpfile.py @@ -13,12 +13,16 @@ from typing import Any, Optional +def url_is_remote(url): + # type: (str) -> bool + return get_url_scheme(url) in ['http', 'https'] + + class Url(namedtuple('Url', ['url'])): def __new__(cls, url): # type: (str) -> Url - scheme = get_url_scheme(url) - assert scheme in ["http", "https"] + assert url_is_remote(url) return super(Url, cls).__new__(cls, url) diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py index f5c09e1109c..063b7c3c982 100644 --- a/src/pip/_internal/operations/prepare.py +++ b/src/pip/_internal/operations/prepare.py @@ -25,6 +25,7 @@ PreviousBuildDirError, VcsHashUnsupported, ) +from pip._internal.network.shallow.httpfile import url_is_remote from pip._internal.utils.filesystem import copy2_fixed from pip._internal.utils.hashes import MissingHashes from pip._internal.utils.logging import indent_log @@ -406,7 +407,7 @@ def prepare_linked_requirement( download_dir = self.wheel_download_dir if link.is_wheel: - if self.use_shallow_wheels: + if self.use_shallow_wheels and url_is_remote(link.url): return ShallowWheelDistribution( req, self.downloader, download_dir) if download_dir: diff --git a/src/pip/_internal/req/req_set.py b/src/pip/_internal/req/req_set.py index 4b959001492..b24f9663e0d 100644 --- a/src/pip/_internal/req/req_set.py +++ b/src/pip/_internal/req/req_set.py @@ -68,6 +68,7 @@ def perform_all_final_hydration(self): return exceptions = [] + def do_hydrate(dist): # type: (DistributionNeedingFinalHydration) -> None try: