Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
Wheel Class Reference

Public Member Functions

None __init__ (self, str filename)
 
List[str] get_formatted_file_tags (self)
 
int support_index_min (self, List[Tag] tags)
 
int find_most_preferred_tag (self, List[Tag] tags, Dict[Tag, int] tag_to_priority)
 
bool supported (self, Iterable[Tag] tags)
 

Data Fields

 filename
 
 name
 
 version
 
 build_tag
 
 pyversions
 
 abis
 
 plats
 
 file_tags
 

Static Public Attributes

 wheel_file_re
 

Detailed Description

A wheel file

Definition at line 12 of file wheel.py.

Constructor & Destructor Documentation

◆ __init__()

None __init__ (   self,
str  filename 
)
:raises InvalidWheelFilename: when the filename is invalid for a wheel

Definition at line 22 of file wheel.py.

22 def __init__(self, filename: str) -> None:
23 """
24 :raises InvalidWheelFilename: when the filename is invalid for a wheel
25 """
26 wheel_info = self.wheel_file_re.match(filename)
27 if not wheel_info:
28 raise InvalidWheelFilename(f"{filename} is not a valid wheel filename.")
29 self.filename = filename
30 self.name = wheel_info.group("name").replace("_", "-")
31 # we'll assume "_" means "-" due to wheel naming scheme
32 # (https://github.com/pypa/pip/issues/1150)
33 self.version = wheel_info.group("ver").replace("_", "-")
34 self.build_tag = wheel_info.group("build")
35 self.pyversions = wheel_info.group("pyver").split(".")
36 self.abis = wheel_info.group("abi").split(".")
37 self.plats = wheel_info.group("plat").split(".")
38
39 # All the tag combinations from this file
40 self.file_tags = {
41 Tag(x, y, z) for x in self.pyversions for y in self.abis for z in self.plats
42 }
43
for i

References Wheel.wheel_file_re.

Referenced by Protocol.__init_subclass__().

Here is the caller graph for this function:

Member Function Documentation

◆ find_most_preferred_tag()

int find_most_preferred_tag (   self,
List[Tag tags,
Dict[Tag, int]   tag_to_priority 
)
Return the priority of the most preferred tag that one of the wheel's file
tag combinations achieves in the given list of supported tags using the given
tag_to_priority mapping, where lower priorities are more-preferred.

This is used in place of support_index_min in some cases in order to avoid
an expensive linear scan of a large list of tags.

:param tags: the PEP 425 tags to check the wheel against.
:param tag_to_priority: a mapping from tag to priority of that tag, where
    lower is more preferred.

:raises ValueError: If none of the wheel's file tags match one of
    the supported tags.

Definition at line 66 of file wheel.py.

68 ) -> int:
69 """Return the priority of the most preferred tag that one of the wheel's file
70 tag combinations achieves in the given list of supported tags using the given
71 tag_to_priority mapping, where lower priorities are more-preferred.
72
73 This is used in place of support_index_min in some cases in order to avoid
74 an expensive linear scan of a large list of tags.
75
76 :param tags: the PEP 425 tags to check the wheel against.
77 :param tag_to_priority: a mapping from tag to priority of that tag, where
78 lower is more preferred.
79
80 :raises ValueError: If none of the wheel's file tags match one of
81 the supported tags.
82 """
83 return min(
84 tag_to_priority[tag] for tag in self.file_tags if tag in tag_to_priority
85 )
86

References Wheel.file_tags.

◆ get_formatted_file_tags()

List[str] get_formatted_file_tags (   self)
Return the wheel's tags as a sorted list of strings.

Definition at line 44 of file wheel.py.

44 def get_formatted_file_tags(self) -> List[str]:
45 """Return the wheel's tags as a sorted list of strings."""
46 return sorted(str(tag) for tag in self.file_tags)
47

References Wheel.file_tags.

◆ support_index_min()

int support_index_min (   self,
List[Tag tags 
)
Return the lowest index that one of the wheel's file_tag combinations
achieves in the given list of supported tags.

For example, if there are 8 supported tags and one of the file tags
is first in the list, then return 0.

:param tags: the PEP 425 tags to check the wheel against, in order
    with most preferred first.

:raises ValueError: If none of the wheel's file tags match one of
    the supported tags.

Definition at line 48 of file wheel.py.

48 def support_index_min(self, tags: List[Tag]) -> int:
49 """Return the lowest index that one of the wheel's file_tag combinations
50 achieves in the given list of supported tags.
51
52 For example, if there are 8 supported tags and one of the file tags
53 is first in the list, then return 0.
54
55 :param tags: the PEP 425 tags to check the wheel against, in order
56 with most preferred first.
57
58 :raises ValueError: If none of the wheel's file tags match one of
59 the supported tags.
60 """
61 try:
62 return next(i for i, t in enumerate(tags) if t in self.file_tags)
63 except StopIteration:
64 raise ValueError()
65

References Wheel.file_tags, and i.

◆ supported()

bool supported (   self,
Iterable[Tag tags 
)
Return whether the wheel is compatible with one of the given tags.

:param tags: the PEP 425 tags to check the wheel against.

Definition at line 87 of file wheel.py.

87 def supported(self, tags: Iterable[Tag]) -> bool:
88 """Return whether the wheel is compatible with one of the given tags.
89
90 :param tags: the PEP 425 tags to check the wheel against.
91 """
92 return not self.file_tags.isdisjoint(tags)

References Wheel.file_tags, and i.

Field Documentation

◆ abis

abis

Definition at line 36 of file wheel.py.

Referenced by TargetPython.format_given(), and TargetPython.get_tags().

◆ build_tag

build_tag

Definition at line 34 of file wheel.py.

◆ file_tags

◆ filename

◆ name

name

Definition at line 30 of file wheel.py.

Referenced by AlreadyInstalledCandidate.__eq__(), Distribution.__eq__(), ExportEntry.__eq__(), _LazyDescr.__get__(), Distribution.__hash__(), ElementState.__init__(), Requirement.__init__(), LinkHash.__post_init__(), InstallationCandidate.__repr__(), Distribution.__repr__(), Metadata.__repr__(), ExportEntry.__repr__(), Encoding.__repr__(), Color.__rich_repr__(), Layout.__rich_repr__(), InstallationCandidate.__str__(), InstalledDistribution.__str__(), EggInfoDistribution.__str__(), Requirement.__str__(), ParserElement.__str__(), Tag.__str__(), _SixMetaPathImporter._add_module(), Matcher._check_compatible(), InstallRequirement._get_archive_name(), Wheel._get_extensions(), _SixMetaPathImporter._get_module(), ConfigOptionParser._get_ordered_configuration_items(), Distribution._get_requirements(), _Cache.add(), InstallRequirement.archive(), LinkHash.as_dict(), LinkHash.as_hashes(), Wheel.build(), _Cache.clear(), Wheel.filename(), Layout.get(), InstallRequirement.get_dist(), InstalledDistribution.get_distinfo_file(), RequirementCommand.get_requirements(), Wheel.get_wheel_metadata(), InstallRequirement.install(), Wheel.install(), SpecifierRequirement.is_satisfied_by(), LinuxDistribution.linux_distribution(), Wheel.metadata(), Distribution.name_and_version(), InstallRequirement.prepare_metadata(), Distribution.provides(), Metadata.provides(), VcsSupport.register(), VersionControl.run_command(), InstallRequirement.uninstall(), Wheel.update(), and Wheel.verify().

◆ plats

plats

Definition at line 37 of file wheel.py.

◆ pyversions

pyversions

Definition at line 35 of file wheel.py.

◆ version

◆ wheel_file_re

wheel_file_re
static
Initial value:

Definition at line 15 of file wheel.py.

Referenced by Wheel.__init__().


The documentation for this class was generated from the following file: