feature: add support for ABI3 wheels
This commit is contained in:
+40
-1
@@ -13,7 +13,7 @@ import time
|
||||
import urllib.request
|
||||
from enum import Enum
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
from pathlib import Path, PurePath
|
||||
from time import sleep
|
||||
from typing import (
|
||||
Any,
|
||||
@@ -26,6 +26,7 @@ from typing import (
|
||||
Optional,
|
||||
Sequence,
|
||||
TextIO,
|
||||
TypeVar,
|
||||
cast,
|
||||
overload,
|
||||
)
|
||||
@@ -41,6 +42,7 @@ else:
|
||||
from filelock import FileLock
|
||||
from packaging.requirements import InvalidRequirement, Requirement
|
||||
from packaging.specifiers import SpecifierSet
|
||||
from packaging.utils import parse_wheel_filename
|
||||
from packaging.version import Version
|
||||
from platformdirs import user_cache_path
|
||||
|
||||
@@ -51,6 +53,7 @@ __all__ = [
|
||||
"MANYLINUX_ARCHS",
|
||||
"call",
|
||||
"shell",
|
||||
"find_compatible_abi3_wheel",
|
||||
"format_safe",
|
||||
"prepare_command",
|
||||
"get_build_verbosity_extra_flags",
|
||||
@@ -566,6 +569,42 @@ def virtualenv(
|
||||
return env
|
||||
|
||||
|
||||
T = TypeVar("T", bound=PurePath)
|
||||
|
||||
|
||||
def find_compatible_abi3_wheel(wheels: Sequence[T], identifier: str) -> Optional[T]:
|
||||
"""
|
||||
Finds an ABI3 wheel in `wheels` compatible with the Python interpreter
|
||||
specified by `identifier`.
|
||||
"""
|
||||
|
||||
interpreter, platform = identifier.split("-")
|
||||
if not interpreter.startswith("cp3"):
|
||||
return None
|
||||
for wheel in wheels:
|
||||
_, _, _, tags = parse_wheel_filename(wheel.name)
|
||||
for tag in tags:
|
||||
if tag.abi != "abi3":
|
||||
continue
|
||||
if not tag.interpreter.startswith("cp3"):
|
||||
continue
|
||||
if int(tag.interpreter[3:]) > int(interpreter[3:]):
|
||||
continue
|
||||
if platform.startswith(("manylinux", "musllinux", "macosx")):
|
||||
# Linux, macOS
|
||||
os_, arch = platform.split("_", 1)
|
||||
if not tag.platform.startswith(os_):
|
||||
continue
|
||||
if not tag.platform.endswith("_" + arch):
|
||||
continue
|
||||
else:
|
||||
# Windows
|
||||
if not tag.platform == platform:
|
||||
continue
|
||||
return wheel
|
||||
return None
|
||||
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from functools import cached_property
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user