From 08aed9d4627cf94cdfb63a8831ea9bc415ae4eb3 Mon Sep 17 00:00:00 2001 From: Vincent Philippon Date: Mon, 25 Sep 2017 11:01:44 -0400 Subject: [PATCH] Use InstallRequirement.extras for the diff in the Resolver. 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. --- CHANGELOG.md | 1 + piptools/resolver.py | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1de8180b7..599ab379c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/piptools/resolver.py b/piptools/resolver.py index 7ed8c5319..3995e66fa 100644 --- a/piptools/resolver.py +++ b/piptools/resolver.py @@ -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) @@ -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: