diff --git a/micropip/package_index.py b/micropip/package_index.py index f7cf02a..5889faf 100644 --- a/micropip/package_index.py +++ b/micropip/package_index.py @@ -157,6 +157,8 @@ def _compatible_wheels( # This key is not available in the Simple API HTML response, so this field may be None size = file.get("size") + yanked = file.get("yanked") + yield WheelInfo.from_package_index( name=name, filename=filename, @@ -164,6 +166,7 @@ def _compatible_wheels( version=version, sha256=sha256, size=size, + yanked=yanked, ) releases_compatible = { diff --git a/micropip/transaction.py b/micropip/transaction.py index 9d64a72..d2dfdbc 100644 --- a/micropip/transaction.py +++ b/micropip/transaction.py @@ -284,6 +284,8 @@ def find_wheel(metadata: ProjectInfo, req: Requirement) -> WheelInfo: wheels = releases[ver] for wheel in wheels: + if wheel.yanked: + continue tag_index = best_compatible_tag_index(wheel.tags) if tag_index is not None and tag_index < best_tag_index: best_wheel = wheel diff --git a/micropip/wheelinfo.py b/micropip/wheelinfo.py index c6d255f..7b0a53b 100644 --- a/micropip/wheelinfo.py +++ b/micropip/wheelinfo.py @@ -43,6 +43,7 @@ class WheelInfo: parsed_url: ParseResult sha256: str | None = None size: int | None = None # Size in bytes, if available (PEP 700) + yanked: bool | str | None = None # Yanked status, if available (PEP 592) # Fields below are only available after downloading the wheel, i.e. after calling `download()`. @@ -84,6 +85,7 @@ def from_package_index( version: Version, sha256: str | None, size: int | None, + yanked: bool | str | None, ) -> "WheelInfo": """Extract available metadata from response received from package index""" parsed_url = urlparse(url) @@ -99,6 +101,7 @@ def from_package_index( parsed_url=parsed_url, sha256=sha256, size=size, + yanked=yanked, ) async def install(self, target: Path) -> None: