Skip to content

Commit

Permalink
Tread carefully around DistributionNotFound.
Browse files Browse the repository at this point in the history
Old versions of pkg_resources do not populate the requirers argument
so make sure its present - carefully - before using it.

Testing Done:
CI went green here:
  https://travis-ci.org/pantsbuild/pex/builds/67608347

Bugs closed: 130, 131

Reviewed at https://rbcommons.com/s/twitter/r/2400/
  • Loading branch information
jsirois committed Jun 30, 2015
1 parent 844936f commit 03ef43d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pex/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ def _resolve(self, working_set, reqs):
except DistributionNotFound as e:
TRACER.log('Failed to resolve a requirement: %s' % e)
unresolved_reqs.add(e.args[0].project_name)
if e.args[1]:
# Older versions of pkg_resources just call `DistributionNotFound(req)` instead of the
# modern `DistributionNotFound(req, requirers)` and so we may not have the 2nd requirers
# slot at all.
if len(e.args) >= 2 and e.args[1]:
unresolved_reqs.update(e.args[1])

unresolved_reqs = set([req.lower() for req in unresolved_reqs])
Expand Down

0 comments on commit 03ef43d

Please sign in to comment.