Skip to content

Commit

Permalink
Use InstallRequirement.extras for the diff in the Resolver.
Browse files Browse the repository at this point in the history
The extras are combined in the InstallRequirement.extras, not in the
Requirement.extras. Comparing the Requirement.extras could cause flakyness in
the Resolver stabilisation, as the list of extras would vary based on the
iteration order on the set of InstallRequirement.
  • Loading branch information
vphilippon committed Sep 25, 2017
1 parent 8c09d72 commit 08aed9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ when `--allow-unsafe` was not set. ([#517](https://github.com/jazzband/pip-tools
(thus losing their VCS directory) and `python setup.py egg_info` fails. ([#385](https://github.com/jazzband/pip-tools/pull/385#) and [#538](https://github.com/jazzband/pip-tools/pull/538)). Thanks @blueyed and @dfee
- Fixed bug where some primary dependencies were annotated with "via" info comments. ([#542](https://github.com/jazzband/pip-tools/pull/542)). Thanks @quantus
- Fixed bug where pkg-resources would be removed by pip-sync in Ubuntu. ([#555](https://github.com/jazzband/pip-tools/pull/555)). Thanks @cemsbr
- Fixed bug where the resolver would sometime not stabilize on requirements specifying extras. ([#566](https://github.com/jazzband/pip-tools/pull/566)). Thanks @vphilippon

# 1.9.0 (2017-04-12)

Expand Down
20 changes: 10 additions & 10 deletions piptools/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class RequirementSummary(object):
"""
Summary of a requirement's properties for comparison purposes.
"""
def __init__(self, req):
self.req = req
self.key = key_from_req(req)
self.extras = str(sorted(req.extras))
self.specifier = str(req.specifier)
def __init__(self, ireq):
self.req = ireq.req
self.key = key_from_req(ireq.req)
self.extras = str(sorted(ireq.extras))
self.specifier = str(ireq.specifier)

def __eq__(self, other):
return str(self) == str(other)
Expand Down Expand Up @@ -210,11 +210,11 @@ def _resolve_one_round(self):

# NOTE: We need to compare RequirementSummary objects, since
# InstallRequirement does not define equality
diff = {RequirementSummary(t.req) for t in theirs} - {RequirementSummary(t.req) for t in self.their_constraints}
removed = ({RequirementSummary(t.req) for t in self.their_constraints} -
{RequirementSummary(t.req) for t in theirs})
unsafe = ({RequirementSummary(t.req) for t in unsafe_constraints} -
{RequirementSummary(t.req) for t in self.unsafe_constraints})
diff = {RequirementSummary(t) for t in theirs} - {RequirementSummary(t) for t in self.their_constraints}
removed = ({RequirementSummary(t) for t in self.their_constraints} -
{RequirementSummary(t) for t in theirs})
unsafe = ({RequirementSummary(t) for t in unsafe_constraints} -
{RequirementSummary(t) for t in self.unsafe_constraints})

has_changed = len(diff) > 0 or len(removed) > 0 or len(unsafe) > 0
if has_changed:
Expand Down

0 comments on commit 08aed9d

Please sign in to comment.