|
6 | 6 | from pathlib import Path |
7 | 7 |
|
8 | 8 |
|
9 | | -def retag(path: Path, dest_dir: Path = None) -> Path: |
| 9 | +def retag(path: Path) -> Path: |
10 | 10 | # Extract platform tag from filename: name-ver-pytag-abi-platform.whl |
11 | 11 | parts = path.stem.split("-") |
12 | 12 | platform = parts[-1] |
13 | 13 | 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) |
19 | 15 |
|
20 | 16 | with zipfile.ZipFile(path, "r") as zin, zipfile.ZipFile( |
21 | 17 | out, "w", compression=zipfile.ZIP_DEFLATED |
@@ -46,16 +42,20 @@ def retag(path: Path, dest_dir: Path = None) -> Path: |
46 | 42 |
|
47 | 43 | def main() -> None: |
48 | 44 | 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") |
51 | 46 | args = parser.parse_args() |
52 | 47 |
|
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 |
55 | 55 |
|
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}") |
59 | 59 |
|
60 | 60 |
|
61 | 61 | if __name__ == "__main__": |
|
0 commit comments