(path: Path, package: str, pyproject: dict[str, Any], committed: dict[str, Committed])
| 209 | |
| 210 | |
| 211 | def check_wheel(path: Path, package: str, pyproject: dict[str, Any], committed: dict[str, Committed]) -> bytes: |
| 212 | info = f"{package}.dist-info/" |
| 213 | metadata, tags, record = info + "METADATA", info + "WHEEL", info + "RECORD" |
| 214 | folders = tuple(f"{folder}/" for folder in pyproject["tool"]["hatch"]["build"]["targets"]["wheel"]["packages"]) |
| 215 | allowed = {name.removeprefix("src/"): name for name in committed if name.startswith(folders)} |
| 216 | allowed |= {f"{info}licenses/{name}": name for name in committed if re.fullmatch(LICENSE, name)} |
| 217 | contents = check_files(path.name, read_wheel(path), committed, allowed, {*allowed, metadata, tags, record}) |
| 218 | |
| 219 | (hatchling,) = (dep for dep in pyproject["build-system"]["requires"] if dep.startswith("hatchling==")) |
| 220 | generator = hatchling.replace("==", " ") |
| 221 | expected_tags = f"Wheel-Version: 1.0\nGenerator: {generator}\nRoot-Is-Purelib: true\nTag: py3-none-any\n" |
| 222 | if contents.get(tags) != expected_tags.encode(): |
| 223 | problems.append(f"{path.name}: {tags} is not what {generator} writes") |
| 224 | |
| 225 | lines = [f"{record},,", ""] |
| 226 | for name, data in contents.items(): |
| 227 | if name != record: |
| 228 | digest = base64.urlsafe_b64encode(hashlib.sha256(data).digest()).rstrip(b"=").decode() |
| 229 | lines.append(f"{name},sha256={digest},{len(data)}") |
| 230 | if sorted(contents.get(record, b"").decode().split("\n")) != sorted(lines): |
| 231 | problems.append(f"{path.name}: {record} does not describe its files") |
| 232 | |
| 233 | return contents.get(metadata, b"") |
| 234 | |
| 235 | |
| 236 | def check_sdist(path: Path, package: str, committed: dict[str, Committed]) -> bytes: |
no test coverage detected