-
Notifications
You must be signed in to change notification settings - Fork 5
fix(packaging): keep release artifacts below PyPI limit #1235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1ed753c
fix(packaging): omit superseded 3.2 prerelease schemas
bokelley 7968afc
test(packaging): use external historical schema fixtures
bokelley f361e38
test(packaging): reject retired bundles in release archives
bokelley 05bd7c1
fix(packaging): retain only current prerelease schemas
bokelley eab7e44
fix(packaging): exclude retired release metadata
bokelley e4c394c
test(packaging): use shipped rc7 compliance in installed validation
bokelley adbcfde
test(packaging): avoid retired rc6 fixture import
bokelley 5e2fac9
fix(compat): preserve unbundled v2.5 purchase continuation
bokelley c65e0a6
fix(compat): reject unvalidated v2.5 result shapes
bokelley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| """Fail a release build before upload if either distribution approaches PyPI's limit.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import sys | ||
| import tarfile | ||
| import zipfile | ||
| from pathlib import Path | ||
|
|
||
| MAX_BYTES = 90_000_000 | ||
| RETIRED_BUNDLES = {"2.5", "3.2.0-beta.6", "3.2.0-rc.3", "3.2.0-rc.6"} | ||
|
|
||
|
|
||
| def check_distribution_size(directory: Path) -> tuple[Path, Path]: | ||
| """Require one wheel and one sdist, each below the release budget.""" | ||
| artifacts = [] | ||
| for pattern in ("*.whl", "*.tar.gz"): | ||
| found = sorted(directory.glob(pattern)) | ||
| if len(found) != 1: | ||
| raise ValueError(f"expected one {pattern} in {directory}, found {len(found)}") | ||
| artifacts.append(found[0]) | ||
| for artifact in artifacts: | ||
| size = artifact.stat().st_size | ||
| if size > MAX_BYTES: | ||
| raise ValueError(f"{artifact.name} is {size} bytes; limit is {MAX_BYTES} bytes") | ||
| print(f"{artifact.name}: {size} bytes (limit {MAX_BYTES})") | ||
| return artifacts[0], artifacts[1] | ||
|
|
||
|
|
||
| def check_retired_schema_bundles(wheel: Path, source: Path) -> None: | ||
| """Reject superseded schema directories in either release artifact.""" | ||
| with zipfile.ZipFile(wheel) as archive: | ||
| wheel_members = archive.namelist() | ||
| with tarfile.open(source) as archive: | ||
| source_members = archive.getnames() | ||
| for artifact, members in ((wheel, wheel_members), (source, source_members)): | ||
| for name in members: | ||
| path = Path(name) | ||
| retired = RETIRED_BUNDLES.intersection((*path.parts, path.stem)) | ||
| if retired: | ||
| raise ValueError( | ||
| f"{artifact.name} contains retired schema bundle {sorted(retired)[0]}" | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| try: | ||
| wheel, source = check_distribution_size( | ||
| Path(sys.argv[1]) if len(sys.argv) == 2 else Path("dist") | ||
| ) | ||
| check_retired_schema_bundles(wheel, source) | ||
| except ValueError as exc: | ||
| raise SystemExit(str(exc)) from exc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.