Calculate autodelete_unpacked earlier in prepare_linked_requirement
We want to use this value to determine whether a globally-managed
source_dir should delegate choosing deletion to the global tempdir
manager, so it needs to be above our call to
InstallRequirement.ensure_has_source_dir.
@@ -416,6 +416,25 @@ class RequirementPreparer(object):
else:
logger.info('Collecting %s', req.req or req)
+ download_dir = self.download_dir
+ if link.is_wheel and self.wheel_download_dir:
+ # when doing 'pip wheel` we download wheels to a
+ # dedicated dir.
+ download_dir = self.wheel_download_dir
+
+ if link.is_wheel:
+ if download_dir:
+ # When downloading, we only unpack wheels to get
+ # metadata.
+ autodelete_unpacked = True
+ else:
+ # When installing a wheel, we use the unpacked
+ # wheel.
+ autodelete_unpacked = False
+ else:
+ # We always delete unpacked sdists after pip runs.
+ autodelete_unpacked = True
+
with indent_log():
# @@ if filesystem packages are not marked
# editable in a req, a non deterministic error
@@ -471,12 +490,6 @@ class RequirementPreparer(object):
# showing the user what the hash should be.
hashes = MissingHashes()
- download_dir = self.download_dir
- if link.is_wheel and self.wheel_download_dir:
- # when doing 'pip wheel` we download wheels to a
- # dedicated dir.
- download_dir = self.wheel_download_dir
-
try:
local_file = unpack_url(
link, req.source_dir, self.downloader, download_dir,
@@ -498,18 +511,6 @@ class RequirementPreparer(object):
if local_file:
req.local_file_path = local_file.path
- if link.is_wheel:
- if download_dir:
- # When downloading, we only unpack wheels to get
- # metadata.
- autodelete_unpacked = True
- else:
- # When installing a wheel, we use the unpacked
- # wheel.
- autodelete_unpacked = False
- else:
- # We always delete unpacked sdists after pip runs.
- autodelete_unpacked = True
if autodelete_unpacked:
write_delete_marker_file(req.source_dir)
