Skip to content

Commit 45e5768

Browse files
mayeutjoerick
andauthored
feat: include size in the final printout (#975)
* feat: include size in the final printout Co-authored-by: Joe Rickerby <[email protected]>
1 parent 18ba770 commit 45e5768

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

cibuildwheel/util.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from enum import Enum
1313
from pathlib import Path
1414
from time import sleep
15-
from typing import Any, Dict, Iterable, Iterator, List, Optional, TextIO
15+
from typing import Any, Dict, Iterable, Iterator, List, NamedTuple, Optional, TextIO
1616

1717
import bracex
1818
import certifi
@@ -352,11 +352,27 @@ def print_new_wheels(msg: str, output_dir: Path) -> Iterator[None]:
352352
existing_contents = set(output_dir.iterdir())
353353
yield
354354
final_contents = set(output_dir.iterdir())
355-
new_contents = final_contents - existing_contents
355+
356+
class FileReport(NamedTuple):
357+
name: str
358+
size: str
359+
360+
new_contents = [
361+
FileReport(wheel.name, f"{(wheel.stat().st_size + 1023) // 1024:,d}")
362+
for wheel in final_contents - existing_contents
363+
]
364+
max_name_len = max(len(f.name) for f in new_contents)
365+
max_size_len = max(len(f.size) for f in new_contents)
356366
n = len(new_contents)
357367
s = time.time() - start_time
358368
m = s / 60
359-
print(msg.format(n=n, s=s, m=m), *sorted(f" {f.name}" for f in new_contents), sep="\n")
369+
print(
370+
msg.format(n=n, s=s, m=m),
371+
*sorted(
372+
f" {f.name:<{max_name_len}s} {f.size:>{max_size_len}s} kB" for f in new_contents
373+
),
374+
sep="\n",
375+
)
360376

361377

362378
def get_pip_version(env: Dict[str, str]) -> str:

unit_test/wheel_print_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
def test_printout_wheels(tmp_path, capsys):
77
tmp_path.joinpath("example.0").touch()
88
with print_new_wheels("TEST_MSG: {n}", tmp_path):
9-
tmp_path.joinpath("example.1").touch()
10-
tmp_path.joinpath("example.2").touch()
9+
tmp_path.joinpath("example.1").write_bytes(b"0" * 1023)
10+
tmp_path.joinpath("example.2").write_bytes(b"0" * 1025)
1111

1212
captured = capsys.readouterr()
1313
assert captured.err == ""
1414

1515
assert "example.0" not in captured.out
16-
assert "example.1\n" in captured.out
17-
assert "example.2\n" in captured.out
16+
assert "example.1 1 kB\n" in captured.out
17+
assert "example.2 2 kB\n" in captured.out
1818
assert "TEST_MSG:" in captured.out
1919
assert "TEST_MSG: 2\n" in captured.out
2020

0 commit comments

Comments
 (0)