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

Simplify RequirementPreparer._downloaded data structure #10346

Merged
merged 1 commit into from
Aug 12, 2021
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
Empty file.
14 changes: 7 additions & 7 deletions src/pip/_internal/operations/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import mimetypes
import os
import shutil
from typing import Dict, Iterable, List, Optional, Tuple
from typing import Dict, Iterable, List, Optional

from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.pkg_resources import Distribution
Expand Down Expand Up @@ -319,8 +319,8 @@ def __init__(
# Should in-tree builds be used for local paths?
self.in_tree_build = in_tree_build

# Memoized downloaded files, as mapping of url: (path, mime type)
self._downloaded: Dict[str, Tuple[str, str]] = {}
# Memoized downloaded files, as mapping of url: path.
self._downloaded: Dict[str, str] = {}

# Previous "header" printed for a link-based InstallRequirement
self._previous_requirement_header = ("", "")
Expand Down Expand Up @@ -487,7 +487,7 @@ def prepare_linked_requirement(

if file_path is not None:
# The file is already available, so mark it as downloaded
self._downloaded[req.link.url] = file_path, None
self._downloaded[req.link.url] = file_path
else:
# The file is not available, attempt to fetch only metadata
wheel_dist = self._fetch_metadata_using_lazy_wheel(link)
Expand All @@ -509,7 +509,7 @@ def prepare_linked_requirements_more(
hashes = self._get_linked_req_hashes(req)
file_path = _check_download_dir(req.link, self.download_dir, hashes)
if file_path is not None:
self._downloaded[req.link.url] = file_path, None
self._downloaded[req.link.url] = file_path
req.needs_more_preparation = False

# Prepare requirements we found were already downloaded for some
Expand Down Expand Up @@ -550,10 +550,10 @@ def _prepare_linked_requirement(
'error {} for URL {}'.format(req, exc, link)
)
else:
file_path, content_type = self._downloaded[link.url]
file_path = self._downloaded[link.url]
if hashes:
hashes.check_against_path(file_path)
local_file = File(file_path, content_type)
local_file = File(file_path, content_type=None)

# For use in later processing,
# preserve the file path on the requirement.
Expand Down