Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Handle yanked flag #148

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions micropip/package_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,16 @@ 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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say you could just do:

if file.get("yanked"):
    continue

here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this wouldn't allow for

unless they are the only file that matches a version specifier that “pins” to an exact version using either == (without any modifiers that make it a range, such as .*) or ===.

So maybe handling later is better.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think that rule would be implemented in find_wheel so the yanked value should be kept in WheelInfo and handled there.


yield WheelInfo.from_package_index(
name=name,
filename=filename,
url=file["url"],
version=version,
sha256=sha256,
size=size,
yanked=yanked,
)

releases_compatible = {
Expand Down
2 changes: 2 additions & 0 deletions micropip/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions micropip/wheelinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.

Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
Loading