Move non-throwing code outside try/except.
@@ -185,18 +185,29 @@ class RequirementPreparer(object):
# showing the user what the hash should be.
hashes = MissingHashes()
- try:
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:
unpack_url(
link, req.source_dir, download_dir,
session=session, hashes=hashes,
progress_bar=self.progress_bar
)
+ except requests.HTTPError as exc:
+ logger.critical(
+ 'Could not install requirement %s because of error %s',
+ req,
+ exc,
+ )
+ raise InstallationError(
+ 'Could not install requirement %s because of HTTP '
+ 'error %s for URL %s' %
+ (req, exc, link)
+ )
if link.is_wheel:
if download_dir:
@@ -213,18 +224,6 @@ class RequirementPreparer(object):
if autodelete_unpacked:
write_delete_marker_file(req.source_dir)
- except requests.HTTPError as exc:
- logger.critical(
- 'Could not install requirement %s because of error %s',
- req,
- exc,
- )
- raise InstallationError(
- 'Could not install requirement %s because of HTTP '
- 'error %s for URL %s' %
- (req, exc, link)
- )
-
abstract_dist = _get_prepared_distribution(
req, self.req_tracker, finder, self.build_isolation,
)
