Skip to content

Version ranges: pick the newest release that supports each target's Python #84

Closed

Description

@patrickballard

Since 0.5.0, numpy>=1.26,<2 checks the newest release matching the range instead of the latest release. But the choice ignores each release's Requires-Python. With -p 3.9, wheelgap can pick a release that requires Python 3.10+, which pip would never install there, and report its (missing) cp39 wheels as gaps.

PyPI's JSON API includes requires_python on every file in releases. pip picks the newest release whose Requires-Python admits the interpreter.

Why it's help wanted: the choice depends on the Python, so one Package can resolve to different versions per target (e.g. 3.9 vs 3.13). Today a package has one version and one file list. Options:

  • Pick one version that satisfies every target Python (simple, but sometimes wrong).
  • Resolve per Python version and carry a version per target. This touches Package, fill() in src/wheelgap/pypi.py, the table (the version column) and --json.

Please sketch the design in a comment first. pypi.py changes always get a careful review.

Activity

  1. added
    bug
    help wanted
    on Nov 9, 2026
  2. patrickballard commented on Nov 9, 2026

    @patrickballard
    CollaboratorAuthor

    A good first step

    Fix the one-Python case first, which needs no new data model. When every target has the same major.minor (e.g. -p 3.9 alone), _newest_matching in src/wheelgap/pypi.py should skip releases where no non-yanked file's requires_python admits it, as pip does (a missing or invalid one admits everything). Thread an optional python through fill() and fill_all(), passed from main() in cli.py and from check_packages() / check_lockfile() in api.py only in that case.

    Not in this PR: several Pythons. That's the per-target design this issue still needs, so keep today's choice there.

    Tests in tests/test_pypi.py: add a package to FAKE_INDEX in tests/conftest.py whose newer release has "requires_python": ">=3.10" on its files (entries can already be dicts), then check that -p 3.9 picks the older release and -p 3.13 the newer one.

    (Reply assisted by Claude.)

  3. Swarneil1905 commented on Nov 10, 2026

    @Swarneil1905
    Contributor

    I’d like to take the one Python first step described above. I’ll pass an optional Python version through fill() and fill_all() from the CLI and Python API when all targets share the same major/minor version.

    For version ranges, _newest_matching will skip releases without a non-yanked file whose requires_python permits that Python, treating missing or invalid metadata as unrestricted. Runs targeting multiple Python versions will retain the existing behavior.

    I’ll add offline regression tests for older/newer Python selection, metadata edge cases, and the CLI/API paths. Could you assign this to me as well? Thank you!

  4. patrickballard commented on Nov 10, 2026

    @patrickballard
    CollaboratorAuthor

    Go for it, @Swarneil1905! I've assigned this to you, and your PR #156 already covers the one-Python first step, so the 18-hour hold is met. We're reviewing it now. The per-Python resolution for runs with several Pythons stays open here as the next step.

    (Reply assisted by Claude.)

  5. patrickballard commented on Nov 12, 2026

    @patrickballard
    CollaboratorAuthor

    Hi @Swarneil1905, are you still working on the rest of this? Your #156 covered the one-Python case; what's left is picking the newest release that supports each target's Python when several -p versions are checked. If we don't hear from you or see a PR by 18:00 UTC on Thursday 13 Nov, we'll finish it ourselves, with credit to you for the first step. No pressure either way.

    (Reply assisted by Claude.)

  6. Swarneil1905 commented on Nov 13, 2026

    @Swarneil1905
    Contributor

    Thanks for following up, @patrickballard . Yes, I’m finishing the multi-Python follow-up to #156.

    The implementation resolves each range separately for each target Python major/minor, using one shared index response. Distinct resolutions appear as separate report rows with their own version, eligible files, and errors. Targets using another resolution show n/a, preserving the existing JSON structure.

    The local test suite passes with 3,203 passed and 61 skipped. I’m reviewing the changes and will open a PR shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions