skip complex comparison for constraints without markers

We're seeing parse errors on constraints with no markers, possibly
related to a unicode issue (it only seems to happen when the empty
marker string is a unicode string). There isn't any point in doing an
expensive comparison when there are no markers for the constraint, so
skip them in that part of the search loop.

Change-Id: I2a700fb8f3e776faf6123c9924d87add12324ef2
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-04-03 13:21:39 -04:00
parent ca6eef59c1
commit 51a60d2180

View File

@ -204,6 +204,13 @@ def _find_constraint(req, constraints):
for constraint_setting, _ in constraints:
if constraint_setting.markers == req.markers:
return constraint_setting
if not constraint_setting.markers:
# There is no point in performing the complex
# comparison for a constraint that has no markers, so
# we skip it here. If we find no closer match then the
# loop at the end of the function will look for a
# constraint without a marker and use that.
continue
# NOTE(dhellmann): This is a very naive attempt to check
# marker compatibility that relies on internal
# implementation details of the packaging library. The