Skip to content

Commit c6e149f

Browse files
committed
Merge pull request #2665 from rbtcollins/broken-out
Fix only-download use in req_set.
2 parents 92ea085 + ed511fa commit c6e149f

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

pip/req/req_set.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -440,18 +440,27 @@ def _prepare_file(self, finder, req_to_install):
440440
# otherwise a result is guaranteed.
441441
assert req_to_install.link
442442
try:
443-
if req_to_install.link.is_wheel and \
444-
self.wheel_download_dir:
445-
# when doing 'pip wheel`
443+
download_dir = self.download_dir
444+
# We always delete unpacked sdists after pip ran.
445+
autodelete_unpacked = True
446+
if req_to_install.link.is_wheel \
447+
and self.wheel_download_dir:
448+
# when doing 'pip wheel` we download wheels to a
449+
# dedicated dir.
446450
download_dir = self.wheel_download_dir
447-
do_download = True
448-
else:
449-
download_dir = self.download_dir
450-
do_download = self.is_download
451+
if req_to_install.link.is_wheel:
452+
if download_dir:
453+
# When downloading, we only unpack wheels to get
454+
# metadata.
455+
autodelete_unpacked = True
456+
else:
457+
# When installing a wheel, we use the unpacked
458+
# wheel.
459+
autodelete_unpacked = False
451460
unpack_url(
452461
req_to_install.link, req_to_install.source_dir,
453-
download_dir, do_download, session=self.session,
454-
)
462+
download_dir, autodelete_unpacked,
463+
session=self.session)
455464
except requests.HTTPError as exc:
456465
logger.critical(
457466
'Could not install requirement %s because '

0 commit comments

Comments
 (0)