Skip to content

Commit

Permalink
Fix pip>=19.1 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
atugushev committed Apr 24, 2019
1 parent 9d0a91a commit 69e8829
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion piptools/repositories/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,16 @@ def find_best_match(self, ireq, prereleases=None):
matching_candidates = [candidates_by_version[ver] for ver in matching_versions]
if not matching_candidates:
raise NoCandidateFound(ireq, all_candidates, self.finder)
best_candidate = max(matching_candidates, key=self.finder._candidate_sort_key)

# pip <= 19.0.3
if hasattr(self.finder, "_candidate_sort_key"):
best_candidate = max(
matching_candidates, key=self.finder._candidate_sort_key
)
# pip >= 19.1
else:
evaluator = self.finder.candidate_evaluator
best_candidate = evaluator.get_best_candidate(matching_candidates)

# Turn the candidate into a pinned InstallRequirement
return make_install_requirement(
Expand Down

0 comments on commit 69e8829

Please sign in to comment.