mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Clean up code style and internal interface
Co-Authored-By: Pradyun Gedam <pradyunsg@gmail.com> Co-Authored-By: Chris Hunt <chrahunt@gmail.com>
This commit is contained in:
parent
078e0effb7
commit
39d296eeb8
|
@ -164,11 +164,14 @@ class Downloader(object):
|
|||
raise
|
||||
|
||||
filename = _get_http_response_filename(resp, link)
|
||||
filepath = os.path.join(location, filename)
|
||||
|
||||
chunks = _prepare_download(resp, link, self._progress_bar)
|
||||
with open(os.path.join(location, filename), 'wb') as content_file:
|
||||
with open(filepath, 'wb') as content_file:
|
||||
for chunk in chunks:
|
||||
content_file.write(chunk)
|
||||
return content_file.name, resp.headers.get('Content-Type', '')
|
||||
content_type = resp.headers.get('Content-Type', '')
|
||||
return filepath, content_type
|
||||
|
||||
def download_many(self, links, location):
|
||||
# type: (Iterable[Link], str) -> Iterable[Tuple[str, Tuple[str, str]]]
|
||||
|
|
|
@ -45,7 +45,7 @@ from pip._internal.utils.unpacking import unpack_file
|
|||
from pip._internal.vcs import vcs
|
||||
|
||||
if MYPY_CHECK_RUNNING:
|
||||
from typing import Callable, Dict, List, Optional, Tuple
|
||||
from typing import Callable, Dict, Iterable, List, Optional, Tuple
|
||||
|
||||
from mypy_extensions import TypedDict
|
||||
from pip._vendor.pkg_resources import Distribution
|
||||
|
@ -484,8 +484,10 @@ class RequirementPreparer(object):
|
|||
return self._prepare_linked_requirement(req, parallel_builds)
|
||||
|
||||
def prepare_linked_requirements_more(self, reqs, parallel_builds=False):
|
||||
# type: (List[InstallRequirement], bool) -> None
|
||||
# type: (Iterable[InstallRequirement], bool) -> None
|
||||
"""Prepare a linked requirement more, if needed."""
|
||||
reqs = [req for req in reqs if req.needs_more_preparation]
|
||||
|
||||
# Let's download to a temporary directory.
|
||||
tmpdir = TempDirectory(kind="unpack", globally_managed=True).path
|
||||
links = (req.link for req in reqs)
|
||||
|
@ -505,9 +507,7 @@ class RequirementPreparer(object):
|
|||
|
||||
with indent_log():
|
||||
self._ensure_link_req_src_dir(req, download_dir, parallel_builds)
|
||||
if link.url in self._downloaded:
|
||||
local_file = File(*self._downloaded[link.url])
|
||||
else:
|
||||
if link.url not in self._downloaded:
|
||||
try:
|
||||
local_file = unpack_url(
|
||||
link, req.source_dir, self.downloader, download_dir,
|
||||
|
@ -518,6 +518,8 @@ class RequirementPreparer(object):
|
|||
'Could not install requirement {} because of HTTP '
|
||||
'error {} for URL {}'.format(req, exc, link)
|
||||
)
|
||||
else:
|
||||
local_file = File(*self._downloaded[link.url])
|
||||
|
||||
# For use in later processing, preserve the file path on the
|
||||
# requirement.
|
||||
|
|
|
@ -160,11 +160,8 @@ class Resolver(BaseResolver):
|
|||
|
||||
req_set.add_named_requirement(ireq)
|
||||
|
||||
self.factory.preparer.prepare_linked_requirements_more([
|
||||
req for req in req_set.all_requirements
|
||||
if req.needs_more_preparation
|
||||
])
|
||||
|
||||
reqs = req_set.all_requirements
|
||||
self.factory.preparer.prepare_linked_requirements_more(reqs)
|
||||
return req_set
|
||||
|
||||
def get_installation_order(self, req_set):
|
||||
|
|
Loading…
Reference in a new issue