Maj pip
This commit is contained in:
@@ -13,10 +13,10 @@ class Wheel:
|
||||
"""A wheel file"""
|
||||
|
||||
wheel_file_re = re.compile(
|
||||
r"""^(?P<namever>(?P<name>.+?)-(?P<ver>.*?))
|
||||
((-(?P<build>\d[^-]*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
|
||||
r"""^(?P<namever>(?P<name>[^\s-]+?)-(?P<ver>[^\s-]*?))
|
||||
((-(?P<build>\d[^-]*?))?-(?P<pyver>[^\s-]+?)-(?P<abi>[^\s-]+?)-(?P<plat>[^\s-]+?)
|
||||
\.whl|\.dist-info)$""",
|
||||
re.VERBOSE
|
||||
re.VERBOSE,
|
||||
)
|
||||
|
||||
def __init__(self, filename: str) -> None:
|
||||
@@ -25,23 +25,20 @@ class Wheel:
|
||||
"""
|
||||
wheel_info = self.wheel_file_re.match(filename)
|
||||
if not wheel_info:
|
||||
raise InvalidWheelFilename(
|
||||
f"{filename} is not a valid wheel filename."
|
||||
)
|
||||
raise InvalidWheelFilename(f"{filename} is not a valid wheel filename.")
|
||||
self.filename = filename
|
||||
self.name = wheel_info.group('name').replace('_', '-')
|
||||
self.name = wheel_info.group("name").replace("_", "-")
|
||||
# we'll assume "_" means "-" due to wheel naming scheme
|
||||
# (https://github.com/pypa/pip/issues/1150)
|
||||
self.version = wheel_info.group('ver').replace('_', '-')
|
||||
self.build_tag = wheel_info.group('build')
|
||||
self.pyversions = wheel_info.group('pyver').split('.')
|
||||
self.abis = wheel_info.group('abi').split('.')
|
||||
self.plats = wheel_info.group('plat').split('.')
|
||||
self.version = wheel_info.group("ver").replace("_", "-")
|
||||
self.build_tag = wheel_info.group("build")
|
||||
self.pyversions = wheel_info.group("pyver").split(".")
|
||||
self.abis = wheel_info.group("abi").split(".")
|
||||
self.plats = wheel_info.group("plat").split(".")
|
||||
|
||||
# All the tag combinations from this file
|
||||
self.file_tags = {
|
||||
Tag(x, y, z) for x in self.pyversions
|
||||
for y in self.abis for z in self.plats
|
||||
Tag(x, y, z) for x in self.pyversions for y in self.abis for z in self.plats
|
||||
}
|
||||
|
||||
def get_formatted_file_tags(self) -> List[str]:
|
||||
@@ -61,7 +58,10 @@ class Wheel:
|
||||
:raises ValueError: If none of the wheel's file tags match one of
|
||||
the supported tags.
|
||||
"""
|
||||
return min(tags.index(tag) for tag in self.file_tags if tag in tags)
|
||||
try:
|
||||
return next(i for i, t in enumerate(tags) if t in self.file_tags)
|
||||
except StopIteration:
|
||||
raise ValueError()
|
||||
|
||||
def find_most_preferred_tag(
|
||||
self, tags: List[Tag], tag_to_priority: Dict[Tag, int]
|
||||
|
Reference in New Issue
Block a user