Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Resolver unstability with extras: Use InstallRequirement.extras for the diff in the Resolver. #566

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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