|
9 | 9 | from dataclasses import dataclass
|
10 | 10 | from typing import TYPE_CHECKING, FrozenSet, Iterable, List, Optional, Set, Tuple, Union
|
11 | 11 |
|
| 12 | +from variantlib.variants_json import VariantsJson |
| 13 | + |
12 | 14 | from pip._vendor.packaging import specifiers
|
13 | 15 | from pip._vendor.packaging.tags import Tag
|
14 | 16 | from pip._vendor.packaging.utils import canonicalize_name
|
|
43 | 45 | get_variants_json_filename,
|
44 | 46 | )
|
45 | 47 |
|
46 |
| -from variantlib.variants_json import VariantsJson |
47 |
| - |
48 | 48 | if TYPE_CHECKING:
|
49 | 49 | from pip._vendor.typing_extensions import TypeGuard
|
50 | 50 |
|
@@ -225,9 +225,7 @@ def evaluate_link(self, link: Link) -> Tuple[LinkType, str, Optional[str]]:
|
225 | 225 |
|
226 | 226 | supported_variants = set(
|
227 | 227 | get_cached_variant_hashes_by_priority(
|
228 |
| - self.variants_json.get( |
229 |
| - get_variants_json_filename(wheel) |
230 |
| - ) |
| 228 | + self.variants_json.get(get_variants_json_filename(wheel)) |
231 | 229 | )
|
232 | 230 | )
|
233 | 231 | if wheel.variant_hash not in supported_variants:
|
@@ -536,9 +534,7 @@ def _sort_key(self, candidate: InstallationCandidate) -> CandidateSortingKey:
|
536 | 534 | wheel = Wheel(link.filename)
|
537 | 535 |
|
538 | 536 | supported_variants = get_cached_variant_hashes_by_priority(
|
539 |
| - self._variants_json.get( |
540 |
| - get_variants_json_filename(wheel) |
541 |
| - ) |
| 537 | + self._variants_json.get(get_variants_json_filename(wheel)) |
542 | 538 | )
|
543 | 539 |
|
544 | 540 | try:
|
@@ -598,21 +594,33 @@ def compute_best_candidate(
|
598 | 594 | applicable_candidates = self.get_applicable_candidates(candidates)
|
599 | 595 |
|
600 | 596 | best_candidate = self.sort_best_candidate(applicable_candidates)
|
601 |
| - if best_candidate.variant_hash is not None: |
| 597 | + if best_candidate is not None and best_candidate.variant_hash is not None: |
602 | 598 | variants_json = VariantsJson(
|
603 | 599 | self._variants_json.get(
|
604 |
| - f"{best_candidate.name}-{best_candidate.version}-variants.json" |
| 600 | + f"{best_candidate.name.replace('-', '_')}-" |
| 601 | + f"{best_candidate.version}-variants.json" |
605 | 602 | ).json()
|
606 | 603 | )
|
607 | 604 | 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 |
| - }) |
| 605 | + |
| 606 | + header_str = ( |
| 607 | + f"{best_candidate.name}=={best_candidate.version}; " |
| 608 | + f"variant_hash={best_candidate.variant_hash}" |
| 609 | + ) |
| 610 | + header_offset, right_extra = divmod((80 - len(header_str) - 2), 2) |
| 611 | + |
| 612 | + logger.info( |
| 613 | + "\n%(left)s %(center)s %(right)s", |
| 614 | + { |
| 615 | + "left": "#" * header_offset, |
| 616 | + "center": header_str, |
| 617 | + "right": "#" * (header_offset + right_extra), |
| 618 | + }, |
| 619 | + ) |
614 | 620 | for vprop in vdesc.properties:
|
615 |
| - logger.info(" %(vprop)s", {"vprop": vprop.to_str()}) |
| 621 | + logger.info("Variant-property: %(vprop)s", {"vprop": vprop.to_str()}) |
| 622 | + |
| 623 | + logger.info("%s\n", "#" * 80) |
616 | 624 |
|
617 | 625 | return BestCandidateResult(
|
618 | 626 | candidates,
|
|
0 commit comments