Skip to content

Commit

Permalink
Merge pull request #10346 from jdufresne/simplify-prepare
Browse files Browse the repository at this point in the history
Simplify RequirementPreparer._downloaded data structure
  • Loading branch information
pradyunsg committed Aug 12, 2021
2 parents 29121df + 61333f5 commit 8bfb6b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit 8bfb6b5

Please sign in to comment.