Minimize scope of try block
This more clearly separates the flow control in the function, which will
make refactoring easier.
@@ -435,20 +435,14 @@ class InstallRequirement(object):
"""
if self.req is None:
return False
- try:
# get_distribution() will resolve the entire list of requirements
# anyway, and we've already determined that we need the requirement
# in question, so strip the marker so that we don't try to
# evaluate it.
no_marker = Requirement(str(self.req))
no_marker.marker = None
+ try:
self.satisfied_by = pkg_resources.get_distribution(str(no_marker))
- if self.editable and self.satisfied_by:
- self.conflicts_with = self.satisfied_by
- # when installing editables, nothing pre-existing should ever
- # satisfy
- self.satisfied_by = None
- return True
except pkg_resources.DistributionNotFound:
return False
except pkg_resources.VersionConflict:
@@ -467,6 +461,13 @@ class InstallRequirement(object):
)
else:
self.conflicts_with = existing_dist
+ else:
+ if self.editable and self.satisfied_by:
+ self.conflicts_with = self.satisfied_by
+ # when installing editables, nothing pre-existing should ever
+ # satisfy
+ self.satisfied_by = None
+ return True
return True
# Things valid for wheels
