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 pip>=19.1 compatibility #795

Merged
merged 1 commit into from
Apr 24, 2019
Merged
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
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