8000 [WheelVariant] `variants.json` support prototype by mgorny · Pull Request #2 · wheelnext/pip · GitHub
[go: up one dir, main page]

Skip to content

[WheelVariant] variants.json support prototype #2

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

Conversation

mgorny
Copy link
@mgorny mgorny commented Mar 3, 2025

Quite hacky, but I think that's the simplest way of injecting it. Basically:

  1. Add need_variants and variants_json argument that are passed transitively to `get_supported():
    1. If we have variants.json, we use the fast path to generate supported tags from specified variants.
    2. If we don't have variants.json and none of the wheels include a variant hash, we don't include variants in supported tags, so we don't introduce slowdown for non-variant packages.
    3. IF we don't have variants.json and at least one includes a variant hash, we use the previous logic of generating all variants.
  2. The index lookup logic considers variants.json file first, so that we have it processed before processing the first wheel. Since the code apparently processes the index multiple times, I've added caching to avoid refetching it.
  3. The JSON from variants.json is wrapped into thin VariantJson class that adds a __hash__() method, so that it can trivially work with @cache.

Requires wheelnext/variantlib#2

mgorny added 5 commits March 2, 2025 15:51
Add parameters to include variant hashes in supported tag list only
if any wheels found have variant hashes.  Fix supported tag list caching
to keep separate caches per parameters.  Start preparing for
`variants.json` support.

The design is aimed at supporting three scenarios:

1. Package version has no variant hashes -- we do not fetch
   `variants.json` and want tags without variants (much faster).

2. Package version has variant hashes -- we try to fetch
   `variants.json`, if we have it, then we want tags with these variants
   (faster).

3. Package version has variant hashes but no `variants.json` -- fallback
   to full list of tags with all possible variants (slow).

Currently only 1. and 3. are implemented.
Add initial support for fetching and passing `variants.json`.  The file
is currently fetched (and cached), and passed to construct tags.
However, variant hashes are neither filtered nor sorted yet.

For the time being, I had to remove `@cache`, since it's incompatible
with dict parameters.
@mgorny mgorny requested a review from DEKHTIARJonathan March 3, 2025 19:45
@DEKHTIARJonathan DEKHTIARJonathan added the tracked Tracked on WheelNext Board label Mar 3, 2025
@DEKHTIARJonathan DEKHTIARJonathan changed the title variants.json support prototype [WheelVariant] variants.json support prototype Mar 4, 2025
@DEKHTIARJonathan DEKHTIARJonathan moved this from Backlog to In progress in WheelNext - Project Tracker Mar 18, 2025
@DEKHTIARJonathan DEKHTIARJonathan changed the base branch from pep-xxx-wheel-variants to pep-xxx-wheel-variants-variants-json March 19, 2025 18:46
@DEKHTIARJonathan DEKHTIARJonathan merged commit 7fbb325 into wheelnext:pep-xxx-wheel-variants-variants-json Mar 19, 2025
3 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tracked Tracked on WheelNext Board
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

2 participants
0