Skip to content

Commit 02fd8a5

Browse files
committed
Filter out wasm32 wheel in upload-pypi.py (#14035)
Tried to make it in a way such that we can add more rules for platforms we want to filter out in the future. Tested it with `python3 misc/upload-pypi.py --dry-run 0.990` Fixes #14026
1 parent 131c8d7 commit 02fd8a5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

misc/upload-pypi.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ def is_whl_or_tar(name: str) -> bool:
2929
return name.endswith(".tar.gz") or name.endswith(".whl")
3030

3131

32+
def item_ok_for_pypi(name: str) -> bool:
33+
if not is_whl_or_tar(name):
34+
return False
35+
36+
if name.endswith(".tar.gz"):
37+
name = name[:-7]
38+
if name.endswith(".whl"):
39+
name = name[:-4]
40+
41+
if name.endswith("wasm32"):
42+
return False
43+
44+
return True
45+
46+
3247
def get_release_for_tag(tag: str) -> dict[str, Any]:
3348
with urlopen(f"{BASE}/{REPO}/releases/tags/{tag}") as f:
3449
data = json.load(f)
@@ -75,7 +90,7 @@ def check_sdist(dist: Path, version: str) -> None:
7590

7691

7792
def spot_check_dist(dist: Path, version: str) -> None:
78-
items = [item for item in dist.iterdir() if is_whl_or_tar(item.name) and 'wasm' not in item.name]
93+
items = [item for item in dist.iterdir() if item_ok_for_pypi(item.name)]
7994
assert len(items) > 10
8095
assert all(version in item.name for item in items)
8196
assert any(item.name.endswith("py3-none-any.whl") for item in items)
@@ -93,7 +108,7 @@ def tmp_twine() -> Iterator[Path]:
93108

94109
def upload_dist(dist: Path, dry_run: bool = True) -> None:
95110
with tmp_twine() as twine:
96-
files = [item for item in dist.iterdir() if is_whl_or_tar(item.name) and 'wasm' not in item.name]
111+
files = [item for item in dist.iterdir() if item_ok_for_pypi(item.name)]
97112
cmd: list[Any] = [twine, "upload"]
98113
cmd += files
99114
if dry_run:

0 commit comments

Comments
 (0)