Skip to content

Commit 2a96184

Browse files
Bug Fix + Cosmetics
1 parent 1e26b59 commit 2a96184

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/pip/_internal/index/package_finder.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -598,21 +598,33 @@ def compute_best_candidate(
598598
applicable_candidates = self.get_applicable_candidates(candidates)
599599

600600
best_candidate = self.sort_best_candidate(applicable_candidates)
601-
if best_candidate.variant_hash is not None:
601+
if best_candidate is not None and best_candidate.variant_hash is not None:
602602
variants_json = VariantsJson(
603603
self._variants_json.get(
604-
f"{best_candidate.name}-{best_candidate.version}-variants.json"
604+
f"{best_candidate.name.replace('-', '_')}-"
605+
f"{best_candidate.version}-variants.json"
605606
).json()
606607
)
607608
vdesc = variants_json.variants[best_candidate.variant_hash]
608-
logger.info("%(name)s %(version)s; selected variant: %(variant_hash)s",
609-
{
610-
"name": best_candidate.name,
611-
"version": best_candidate.version,
612-
"variant_hash": best_candidate.variant_hash,
613-
})
609+
610+
header_str = (
611+
f"{best_candidate.name}=={best_candidate.version}; "
612+
f"variant_hash={best_candidate.variant_hash}"
613+
)
614+
header_offset, right_extra = divmod((80 - len(header_str) - 2), 2)
615+
616+
logger.info(
617+
"%(left)s %(center)s %(right)s\n",
618+
{
619+
"left": "#" * header_offset,
620+
"center": header_str,
621+
"right": "#" * (header_offset + right_extra),
622+
},
623+
)
614624
for vprop in vdesc.properties:
615-
logger.info(" %(vprop)s", {"vprop": vprop.to_str()})
625+
logger.info("Variant-property: %(vprop)s", {"vprop": vprop.to_str()})
626+
627+
logger.info("%s\n", "#" * 80)
616628

617629
return BestCandidateResult(
618630
candidates,

0 commit comments

Comments
 (0)