mirror of
https://github.com/lancedb/lancedb.git
synced 2026-12-03 07:45:17 +00:00
The [0.42.1 CLI publish run](https://github.com/lancedb/lancedb/actions/runs/46743361906/job/143030097235) uploaded all four distributions, then failed verification because the first PyPI metadata response listed only some of the files. The workflow fetched that response once and stopped at the first missing filename. This change gives PyPI time to list every expected file while still rejecting a published checksum mismatch immediately. This was accomplished with the following changes: - Fetch release metadata up to eight times, with a 15-second request timeout and 15 seconds between attempts. Report any filenames still missing when retries run out. - Compare every listed distribution against its local SHA-256 on each attempt, even when a different wheel or the source archive is missing. ### Testing Five regression tests passed, covering complete metadata, delayed files, persistent omissions, a mismatched digest in a partial listing, and a transient request error. The existing stable publishing checks also passed.
65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
|
|
"""Verify uploaded CLI distributions against the version-specific PyPI metadata."""
|
|
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
MAX_ATTEMPTS = 8
|
|
RETRY_DELAY = 15
|
|
|
|
|
|
def fetch_metadata(version):
|
|
url = f"https://pypi.org/pypi/lancedb-tools/{version}/json"
|
|
return json.loads(
|
|
subprocess.check_output(["curl", "-fsS", "--max-time", "15", url])
|
|
)
|
|
|
|
|
|
def verify(version, expected):
|
|
for attempt in range(1, MAX_ATTEMPTS + 1):
|
|
try:
|
|
metadata = fetch_metadata(version)
|
|
except subprocess.CalledProcessError as exc:
|
|
reason = f"metadata request failed (curl exit {exc.returncode})"
|
|
else:
|
|
missing = set(expected)
|
|
for entry in metadata["urls"]:
|
|
name = entry["filename"]
|
|
if name in expected:
|
|
published = entry["digests"]["sha256"]
|
|
if published != expected[name]:
|
|
raise SystemExit(
|
|
f"{name}: SHA-256 mismatch "
|
|
f"(local {expected[name]}, PyPI {published})"
|
|
)
|
|
missing.discard(name)
|
|
if not missing:
|
|
print(f"Verified all {len(expected)} distribution checksums on PyPI.")
|
|
return
|
|
reason = f"missing from PyPI: {', '.join(sorted(missing))}"
|
|
|
|
print(f"Attempt {attempt}/{MAX_ATTEMPTS}: {reason}", flush=True)
|
|
if attempt == MAX_ATTEMPTS:
|
|
raise SystemExit(f"Could not verify lancedb-tools {version}: {reason}")
|
|
time.sleep(RETRY_DELAY)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
version, directory = sys.argv[1:]
|
|
dist = Path(directory)
|
|
wheels = sorted(dist.glob("*.whl"))
|
|
sources = sorted(dist.glob("*.tar.gz"))
|
|
if not wheels or not sources:
|
|
raise SystemExit(f"Expected wheels and a source archive in {dist}")
|
|
expected = {}
|
|
for path in wheels + sources:
|
|
with path.open("rb") as stream:
|
|
expected[path.name] = hashlib.file_digest(stream, "sha256").hexdigest()
|
|
verify(version, expected)
|