Skip to content

Commit 5d5e2c0

Browse files
committed
Fix retagging
1 parent 940c327 commit 5d5e2c0

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
CIBW_BUILD_VERBOSITY: 1
4747

4848
# Retag to py3-none-<platform>
49-
CIBW_REPAIR_WHEEL_COMMAND: "python tools/retag_wheel_py3-none.py -w {dest_dir} {wheel}"
49+
CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair -w {dest_dir} {wheel} && python tools/retag_wheel_py3-none.py {dest_dir}"
5050
with:
5151
output-dir: wheelhouse
5252

tools/retag_wheel_py3-none.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@
66
from pathlib import Path
77

88

9-
def retag(path: Path, dest_dir: Path = None) -> Path:
9+
def retag(path: Path) -> Path:
1010
# Extract platform tag from filename: name-ver-pytag-abi-platform.whl
1111
parts = path.stem.split("-")
1212
platform = parts[-1]
1313
new_name = "-".join(parts[:-3] + ["py3", "none", platform]) + ".whl"
14-
15-
if dest_dir:
16-
out = dest_dir / new_name
17-
else:
18-
out = path.with_name(new_name)
14+
out = path.with_name(new_name)
1915

2016
with zipfile.ZipFile(path, "r") as zin, zipfile.ZipFile(
2117
out, "w", compression=zipfile.ZIP_DEFLATED
@@ -46,16 +42,20 @@ def retag(path: Path, dest_dir: Path = None) -> Path:
4642

4743
def main() -> None:
4844
parser = argparse.ArgumentParser()
49-
parser.add_argument("wheel", nargs="+")
50-
parser.add_argument("-w", dest="dest_dir", type=Path, help="Destination directory for retagged wheels")
45+
parser.add_argument("dest_dir", type=Path, help="Directory containing wheels to retag")
5146
args = parser.parse_args()
5247

53-
if args.dest_dir:
54-
args.dest_dir.mkdir(parents=True, exist_ok=True)
48+
if not args.dest_dir.is_dir():
49+
raise ValueError(f"Directory not found: {args.dest_dir}")
50+
51+
wheels = list(args.dest_dir.glob("*.whl"))
52+
if not wheels:
53+
print(f"No wheels found in {args.dest_dir}")
54+
return
5555

56-
for w in args.wheel:
57-
out = retag(Path(w), args.dest_dir)
58-
print(f"Retagged: {w} -> {out}")
56+
for wheel in wheels:
57+
out = retag(wheel)
58+
print(f"Retagged: {wheel.name} -> {out.name}")
5959

6060

6161
if __name__ == "__main__":

0 commit comments

Comments
 (0)