From 0c7bcb830073979a21a9ffcd257c2d002a205796 Mon Sep 17 00:00:00 2001 From: Patrick Ballard Date: Fri, 4 Dec 2026 01:24:12 +0000 Subject: [PATCH 1/2] Package pages: lead with the install error people search for A package that builds from source somewhere is titled "Failed building wheel for NAME?" (or "No matching distribution found for NAME?" where there's no sdist either), with a short answer above the table: why pip builds it, where it does for this package, the ways out, and the wheelgap command that finds which dependency failed in a whole install. Fully covered packages keep the wheel coverage title. Pyodide gaps don't count, since nobody's pip builds there. Co-Authored-By: Claude Opus 5.5 --- scripts/build_pages.py | 78 +++++++++++++++++++++++++++++++++--- tests/test_package_jsonld.py | 24 ++++++++++- 2 files changed, 95 insertions(+), 7 deletions(-) diff --git a/scripts/build_pages.py b/scripts/build_pages.py index 1b62d5c..8093b19 100644 --- a/scripts/build_pages.py +++ b/scripts/build_pages.py @@ -292,14 +292,60 @@ def note_text(text: str) -> str: ) -def gap_platforms(package: dict, targets: list[dict]) -> list[str]: - """Platforms where some target builds from source or can't install, in PLATFORM_NAMES order.""" +def gap_platforms(package: dict, targets: list[dict], statuses: tuple[str, ...] = GAP) -> list[str]: + """Platforms where some target builds from source or can't install (or has one of `statuses`), in PLATFORM_NAMES + order.""" if package.get("error"): return [] - found = {t["platform"] for t, r in zip(targets, package["results"]) if r in GAP} + found = {t["platform"] for t, r in zip(targets, package["results"]) if r in statuses} return [pl for pl in PLATFORM_NAMES if pl in found] +def answer_html(name: str, version: str, python: str, platforms: list[str], *, builds: bool) -> str: + """The short answer for someone who arrived with the install's error ("Failed building wheel for NAME", or pip's + "No matching distribution found" where there's no sdist to build): why it happens, where it does for this package, + the ways out, and the one command that finds which dependency failed in their own install.""" + e = html.escape + where = ", ".join(PLATFORM_NAMES[pl] for pl in platforms) + example = platforms[0] + if builds: + why = ( + f"pip and uv install a prebuilt wheel when one fits your platform and Python. Where none fits, they " + f"download {e(name)}'s source and build it on your machine, which needs a compiler and the libraries it " + f"links against, and stops with "Failed building wheel for {e(name)}" when they're missing. {e(name)} " + f"{e(version)} builds from source or can't install on: {e(where)} (the table shows which Python)." + ) + ways = ( + "The ways out, easiest first: use a Python and platform that has a wheel (the table); install a release " + "that has one (the table names it where there is one); or give the build what it needs." + ) + else: + why = ( + f"pip and uv install a prebuilt wheel when one fits your platform and Python, and build from source when " + f"none does. {e(name)} {e(version)} has no wheel that fits on {e(where)} and no source to build, so pip " + f"stops with "No matching distribution found for {e(name)}" (the table shows which Python)." + ) + ways = ( + "The ways out: use a Python and platform that has a wheel (the table), or a release that has one (the " + "table names it where there is one)." + ) + if builds: + tool_intro = "When a whole install fails, this finds which dependency it was and the release with a wheel:" + command = f"pip install -r requirements.txt 2>&1 | uvx wheelgap --from-log - -p {python} -t {example}" + else: + tool_intro = "To find every dependency like this before you install, on the platforms you ship to:" + command = f"uvx wheelgap requirements.txt -p {python} -t {example}" + return ( + '
\n' + "

Why the install fails, and the fix

\n" + f"

{why}

\n" + f"

{ways}

\n" + f"

{e(tool_intro)}

\n" + f"
{e(command)}
\n" + "
\n" + ) + + def add_note_url(name: str, platforms: list[str], today: str, exists: bool) -> str: """GitHub's new-file page for notes/.toml with a template, or its editor if the file exists.""" if exists: # GitHub can't create a file that's already there, and can't pre-fill the editor @@ -652,9 +698,29 @@ def page( if any((gap_wheels or {}).get((canonical(name), version, target)) == "yanked" for target in gap_targets) else "" ) - title = f"{name} wheel coverage: Linux, Alpine, macOS, Windows, ARM, Pyodide" url = f"{BASE_URL}p/{canonical(name)}/" summary = describe(package, columns, python, targets) + # A package that builds from source somewhere is searched for by its error, not by "wheel coverage": people (and + # their coding agents) paste "Failed building wheel for NAME" into a search box. + # Not Pyodide: nobody's pip builds there, and a browser gap isn't what someone searching an install error has. + builds_somewhere = [pl for pl in gap_platforms(package, targets, ("source",)) if pl != "pyodide"] + fails_somewhere = [pl for pl in gap_platforms(package, targets) if pl != "pyodide"] + if builds_somewhere: + title = f"Failed building wheel for {name}? Where pip builds it from source, and the fix" + heading = f"Failed building wheel for {name}?" + elif fails_somewhere: # no sdist either: pip says it can't find one, it never builds + title = f"No matching distribution found for {name}? Where pip can't install it, and the fix" + heading = f"No matching distribution found for {name}?" + else: + title = f"{name} wheel coverage: Linux, Alpine, macOS, Windows, ARM, Pyodide" + heading = f"{name} wheel coverage" + # The example command's Python: the one the summary above it answers for (a released one), else the newest. + example_python = install_results.install_python(package, targets) or python + answer = ( + answer_html(name, version, example_python, fails_somewhere, builds=bool(builds_somewhere)) + if fails_somewhere + else "" + ) campaign_links = [] for status, campaign in campaigns or []: link = f'{e(campaign["title"])}' @@ -770,10 +836,10 @@ def cell(py: str, pl: str) -> str: {build_campaigns.site_header("../../")}
-

{e(name)} wheel coverage

+

{e(heading)}

{e(summary)}

From the wheelgap {e(str(scan["wheelgap"]))} scan of {e(str(scan["generated"])[:10])}.

-
+{answer}

{e(name)} {e(version)} ยท {sub}

diff --git a/tests/test_package_jsonld.py b/tests/test_package_jsonld.py index 183c696..c4ac7c1 100644 --- a/tests/test_package_jsonld.py +++ b/tests/test_package_jsonld.py @@ -55,7 +55,8 @@ def meta(prefix, key): return match.group(1) assert meta("property", "og:type") == "website" - assert meta("property", "og:title") == "numpy wheel coverage: Linux, Alpine, macOS, Windows, ARM, Pyodide" + # The fixture builds from source on one platform, so the title is the error people search for. + assert meta("property", "og:title") == "Failed building wheel for numpy? Where pip builds it from source, and the fix" assert meta("property", "og:url") == "https://wheelgap.github.io/tracker/p/numpy/" assert meta("property", "og:image") == "https://wheelgap.github.io/tracker/og.png" assert meta("property", "og:image:width") == "1280" @@ -118,3 +119,24 @@ def test_one_heading_and_the_badge_folded(): assert '' in page assert '
\n

Badge for your README

' in page assert 'class="eyebrow"' not in page + + +def test_title_and_answer_follow_the_error_people_search_for(): + def page(results, platforms): + data = scan() + data["targets"] = [{"label": f"3.13 {pl}", "python": "3.13", "platform": pl} for pl in platforms] + data["packages"][0]["results"] = results + return build(data) + + built = page(["wheel", "source"], ["linux-x86_64", "win-arm64"]) + assert "

Failed building wheel for numpy?

" in built + assert "--from-log - -p 3.13 -t win-arm64" in built + + none_to_build = page(["wheel", "missing"], ["linux-x86_64", "win-arm64"]) + assert "

No matching distribution found for numpy?

" in none_to_build + assert "uvx wheelgap requirements.txt -p 3.13 -t win-arm64" in none_to_build + assert "--from-log" not in none_to_build + + covered = page(["wheel", "wheel"], ["linux-x86_64", "win-arm64"]) + assert "

numpy wheel coverage

" in covered + assert "why-it-fails" not in covered From 2d65af9af283a9418d13515880702284a699c606 Mon Sep 17 00:00:00 2001 From: Patrick Ballard Date: Fri, 4 Dec 2026 01:27:55 +0000 Subject: [PATCH 2/2] Package pages: the example names a Python and platform with the error The command used the first platform with a gap on any Python, with the summary's Python, so 252 pages named a pair that has a wheel. Pick the Python first (the summary's when it has the error, else the newest that does), then its first platform with that error. Free-threaded-only gaps keep the coverage title, since the summary under the heading is about regular Python. The no-sdist wording says an unpinned install falls back to an older release. Tests for each, and for escaping a name in the new section. Co-Authored-By: Claude Opus 5.5 --- scripts/build_pages.py | 54 ++++++++++++++++++++++++------------ tests/test_package_jsonld.py | 34 +++++++++++++++++++++++ 2 files changed, 70 insertions(+), 18 deletions(-) diff --git a/scripts/build_pages.py b/scripts/build_pages.py index 8093b19..6d8cf67 100644 --- a/scripts/build_pages.py +++ b/scripts/build_pages.py @@ -301,13 +301,15 @@ def gap_platforms(package: dict, targets: list[dict], statuses: tuple[str, ...] return [pl for pl in PLATFORM_NAMES if pl in found] -def answer_html(name: str, version: str, python: str, platforms: list[str], *, builds: bool) -> str: +def answer_html( + name: str, version: str, python: str, example: str, platforms: list[str], *, builds: bool +) -> str: """The short answer for someone who arrived with the install's error ("Failed building wheel for NAME", or pip's - "No matching distribution found" where there's no sdist to build): why it happens, where it does for this package, - the ways out, and the one command that finds which dependency failed in their own install.""" + "No matching distribution found" where there's no sdist to build): why it happens, where it does for this package + (`platforms`, on a regular Python), the ways out, and a command for `python` on `example`, a platform where that + Python has the error.""" e = html.escape where = ", ".join(PLATFORM_NAMES[pl] for pl in platforms) - example = platforms[0] if builds: why = ( f"pip and uv install a prebuilt wheel when one fits your platform and Python. Where none fits, they " @@ -322,8 +324,11 @@ def answer_html(name: str, version: str, python: str, platforms: list[str], *, b else: why = ( f"pip and uv install a prebuilt wheel when one fits your platform and Python, and build from source when " - f"none does. {e(name)} {e(version)} has no wheel that fits on {e(where)} and no source to build, so pip " - f"stops with "No matching distribution found for {e(name)}" (the table shows which Python)." + f"none does. {e(name)} {e(version)} has no wheel that fits on {e(where)} and no source to build (the " + f"table shows which Python). An unpinned install there falls back to an older release that has a file for " + f"it, which may build from source (the table names the last release with a wheel where there is one). With " + f"no such release, or with {e(name)}=={e(version)} pinned, pip stops with "No matching distribution " + f"found for {e(name)}"." ) ways = ( "The ways out: use a Python and platform that has a wheel (the table), or a release that has one (the " @@ -702,25 +707,38 @@ def page( summary = describe(package, columns, python, targets) # A package that builds from source somewhere is searched for by its error, not by "wheel coverage": people (and # their coding agents) paste "Failed building wheel for NAME" into a search box. - # Not Pyodide: nobody's pip builds there, and a browser gap isn't what someone searching an install error has. - builds_somewhere = [pl for pl in gap_platforms(package, targets, ("source",)) if pl != "pyodide"] - fails_somewhere = [pl for pl in gap_platforms(package, targets) if pl != "pyodide"] - if builds_somewhere: + # Only regular Pythons on native platforms count. Not Pyodide: nobody's pip builds there. Not free-threaded: a gap + # only on 3.14t would title the page with an error the summary under it (regular Python) says nobody gets. + cells = ( + [] + if package.get("error") + else [ + (t["python"], t["platform"], r) + for t, r in zip(targets, package["results"]) + if r in GAP and t["platform"] != "pyodide" and not t["python"].endswith("t") + ] + ) + builds = any(r == "source" for _, _, r in cells) + if builds: title = f"Failed building wheel for {name}? Where pip builds it from source, and the fix" heading = f"Failed building wheel for {name}?" - elif fails_somewhere: # no sdist either: pip says it can't find one, it never builds + elif cells: # no sdist either: pip never builds it title = f"No matching distribution found for {name}? Where pip can't install it, and the fix" heading = f"No matching distribution found for {name}?" else: title = f"{name} wheel coverage: Linux, Alpine, macOS, Windows, ARM, Pyodide" heading = f"{name} wheel coverage" - # The example command's Python: the one the summary above it answers for (a released one), else the newest. - example_python = install_results.install_python(package, targets) or python - answer = ( - answer_html(name, version, example_python, fails_somewhere, builds=bool(builds_somewhere)) - if fails_somewhere - else "" - ) + answer = "" + if cells: + # The example command names a Python and platform that really has the page's error: the Python the summary + # answers for when it has one, else the newest that does, and that Python's first such platform. + kind = [(py, pl) for py, pl, r in cells if r == ("source" if builds else "missing")] + preferred = install_results.install_python(package, targets) or python + pythons = {py for py, _ in kind} + example_python = preferred if preferred in pythons else max(pythons, key=install_results.python_key) + example_platform = next(pl for pl in PLATFORM_NAMES if (example_python, pl) in kind) + where = [pl for pl in PLATFORM_NAMES if any(p == pl for _, p, _ in cells)] + answer = answer_html(name, version, example_python, example_platform, where, builds=builds) campaign_links = [] for status, campaign in campaigns or []: link = f'{e(campaign["title"])}' diff --git a/tests/test_package_jsonld.py b/tests/test_package_jsonld.py index c4ac7c1..1c9877f 100644 --- a/tests/test_package_jsonld.py +++ b/tests/test_package_jsonld.py @@ -140,3 +140,37 @@ def page(results, platforms): covered = page(["wheel", "wheel"], ["linux-x86_64", "win-arm64"]) assert "

numpy wheel coverage

" in covered assert "why-it-fails" not in covered + + +def _page(results, labels, name="numpy", version="2.3.1"): + data = scan(name, version) + data["targets"] = [{"label": label, "python": label.split()[0], "platform": label.split()[1]} for label in labels] + data["packages"][0]["results"] = results + return build(data) + + +def test_the_example_command_names_a_python_and_platform_with_the_error(): + # linux-x86_64's gap is free-threaded only; 3.13's own gap is on win-arm64, so that's the command. + built = _page(["source", "wheel", "source"], ["3.13t linux-x86_64", "3.13 linux-x86_64", "3.13 win-arm64"]) + assert "--from-log - -p 3.13 -t win-arm64" in built + assert "Windows ARM64" in built and "Linux x86_64 (the table" not in built + + +def test_gaps_only_on_free_threaded_or_pyodide_keep_the_coverage_title(): + free_threaded = _page(["source", "wheel"], ["3.13t linux-x86_64", "3.13 linux-x86_64"]) + assert "

numpy wheel coverage

" in free_threaded and "why-it-fails" not in free_threaded + pyodide = _page(["source", "wheel"], ["3.13 pyodide", "3.13 linux-x86_64"]) + assert "

numpy wheel coverage

" in pyodide and "why-it-fails" not in pyodide + + +def test_no_matching_distribution_mentions_the_fallback_to_an_older_release(): + built = _page(["wheel", "missing"], ["3.13 linux-x86_64", "3.13 win-arm64"]) + assert "falls back to an older release" in built + assert "numpy==2.3.1 pinned" in built + + +def test_the_answer_escapes_the_package_name_once(): + built = _page(["wheel", "source"], ["3.13 linux-x86_64", "3.13 win-arm64"], name="a&b", version="1&2") + assert "

Failed building wheel for a&b<x>?

" in built + assert "Failed building wheel for a&b<x>"" in built + assert "&amp;" not in built and "" not in built