mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
## Summary
Every `Deploy - Publish to PyPI` since v0.279.4 (about 10-22) has failed
with `400 File too large. Limit for project 'karaoke-gen' is 100 MB`.
The wheel had grown to 110 MB (105.1 MiB), so PyPI is still on 0.279.4.
Backend deploys were not affected. I found this while watching deploys
during an alerts-triage session.
In the wheel, 66 MB of the bundled Next.js export is RSC `.txt` payloads
(about 3 MB per locale × 33). The only thing that uses the export is the
CLI local-review server
(`karaoke_gen/lyrics_transcriber/review/server.py`). It mounts only
`/_next` and `/static`, and every other route returns an HTML entry
point. Next's RSC fetch paths (`/{locale}/app/.../index.txt`) already
get HTML from those routes, so the `.txt` files are never served.
- `make build-frontend` deletes `*.txt` from the copied export. On the
real CI wheel from run 40826404322 this takes it from 105.1 MiB to 41.1
MiB.
- `scripts/verify_wheel_frontend.py`, which already runs in both
package-build jobs, now fails above 95 MiB. Growth will show up on the
PR instead of as a failed publish after merge.
## Testing
- New `tests/unit/test_verify_wheel_frontend.py`: 5 tests covering the
pass case, missing entrypoint, too few files, the size guard, and
headroom below 100 MiB.
- Re-zipped the real 0.286.0 CI wheel without the `.txt` files: 41.1
MiB, and the verifier passes. The verifier rejects the original wheel
(105.1 MiB) with the new error.
- CodeRabbit: 1 finding ("deleting RSC payloads can break client
navigation"). Skipped, because the local server never serves those files
(see above), so it can't change runtime behaviour.
@coderabbitai ignore
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_012RYLVTiUPKxn3sQPyp3Teh
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
3.1 KiB
Python
85 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Verify a built karaoke-gen wheel actually bundles the Next.js frontend export.
|
|
|
|
The frontend static export (``karaoke_gen/nextjs_frontend/out``) is generated at
|
|
build time and gitignored (issue #876). It is pulled into the wheel via the
|
|
``include`` entry in ``pyproject.toml``. If the frontend build is skipped or
|
|
produces no output, poetry will still happily build a wheel — just without the
|
|
frontend — and the CLI local-review UI would silently break in production.
|
|
|
|
This script is the loud guard against that: it fails (non-zero exit) unless the
|
|
wheel contains a plausible frontend export. It also fails when the wheel is close
|
|
to PyPI's 100 MiB per-file limit, so growth shows up on the PR instead of as a
|
|
failed publish after merge (2026-10-27..29: 110 MB wheels, PyPI stuck at 0.279.4).
|
|
|
|
Usage:
|
|
python scripts/verify_wheel_frontend.py dist/karaoke_gen-*.whl
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import zipfile
|
|
from glob import glob
|
|
|
|
FRONTEND_PREFIX = "karaoke_gen/nextjs_frontend/out/"
|
|
# A real 33-locale export is thousands of files; require a sane floor plus the
|
|
# root entrypoint so an empty/partial copy can't sneak through.
|
|
MIN_FRONTEND_FILES = 50
|
|
REQUIRED_ENTRY = FRONTEND_PREFIX + "index.html"
|
|
# PyPI rejects files over 100 MiB; leave headroom so we fail before publish does.
|
|
MAX_WHEEL_BYTES = 95 * 1024 * 1024
|
|
|
|
|
|
def resolve_wheel(patterns: list[str]) -> str:
|
|
matches: list[str] = []
|
|
for pattern in patterns:
|
|
matches.extend(glob(pattern))
|
|
if not matches:
|
|
print(f"::error::No wheel found matching: {' '.join(patterns)}")
|
|
sys.exit(1)
|
|
if len(matches) > 1:
|
|
print(f"::error::Expected exactly one wheel, found {len(matches)}: {matches}")
|
|
sys.exit(1)
|
|
return matches[0]
|
|
|
|
|
|
def main() -> None:
|
|
if len(sys.argv) < 2:
|
|
print("usage: verify_wheel_frontend.py <wheel-path-or-glob> [...]")
|
|
sys.exit(2)
|
|
|
|
wheel = resolve_wheel(sys.argv[1:])
|
|
with zipfile.ZipFile(wheel) as zf:
|
|
names = zf.namelist()
|
|
|
|
frontend_files = [n for n in names if n.startswith(FRONTEND_PREFIX) and not n.endswith("/")]
|
|
count = len(frontend_files)
|
|
|
|
if REQUIRED_ENTRY not in names:
|
|
print(f"::error::{wheel} is missing the frontend entrypoint '{REQUIRED_ENTRY}'.")
|
|
print("The frontend was not built into the package before 'poetry build'.")
|
|
sys.exit(1)
|
|
|
|
if count < MIN_FRONTEND_FILES:
|
|
print(
|
|
f"::error::{wheel} bundles only {count} frontend files under "
|
|
f"'{FRONTEND_PREFIX}' (expected >= {MIN_FRONTEND_FILES}). "
|
|
"The frontend export looks empty or partial."
|
|
)
|
|
sys.exit(1)
|
|
|
|
size = os.path.getsize(wheel)
|
|
if size > MAX_WHEEL_BYTES:
|
|
print(
|
|
f"::error::{wheel} is {size / 1024 / 1024:.1f} MiB, over the "
|
|
f"{MAX_WHEEL_BYTES // 1024 // 1024} MiB guard (PyPI's per-file limit is 100 MiB). "
|
|
"Trim what the wheel bundles (see `make build-frontend`)."
|
|
)
|
|
sys.exit(1)
|
|
|
|
print(f"✅ {wheel} bundles {count} frontend files (entrypoint present), {size / 1024 / 1024:.1f} MiB.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|