From acf92c04e0619ca6d9f5f8b4e6a670f6f40f7c26 Mon Sep 17 00:00:00 2001 From: mayeut Date: Wed, 29 Dec 2021 17:34:02 +0100 Subject: [PATCH 1/4] feat: include size in the final printout --- cibuildwheel/util.py | 20 +++++++++++++++++--- unit_test/wheel_print_test.py | 8 ++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 2b1c28447..ffa12315b 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -12,7 +12,7 @@ from enum import Enum from pathlib import Path from time import sleep -from typing import Any, Dict, Iterable, Iterator, List, Optional, TextIO +from typing import Any, Dict, Iterable, Iterator, List, NamedTuple, Optional, TextIO import bracex import certifi @@ -352,11 +352,25 @@ def print_new_wheels(msg: str, output_dir: Path) -> Iterator[None]: existing_contents = set(output_dir.iterdir()) yield final_contents = set(output_dir.iterdir()) - new_contents = final_contents - existing_contents + + class FileReport(NamedTuple): + name: str + size: str + + new_contents = [ + FileReport(wheel.name, f"{(wheel.stat().st_size + 1023) // 1024:,d}") + for wheel in final_contents - existing_contents + ] + max_name_len = max(len(f.name) for f in new_contents) + max_size_len = max(len(f.size) for f in new_contents) n = len(new_contents) s = time.time() - start_time m = s / 60 - print(msg.format(n=n, s=s, m=m), *sorted(f" {f.name}" for f in new_contents), sep="\n") + print( + msg.format(n=n, s=s, m=m), + *sorted(f" {f.name:<{max_name_len}s} {f.size:>{max_size_len}s} kB" for f in new_contents), + sep="\n", + ) def get_pip_version(env: Dict[str, str]) -> str: diff --git a/unit_test/wheel_print_test.py b/unit_test/wheel_print_test.py index 35e1ce576..db62aa3e1 100644 --- a/unit_test/wheel_print_test.py +++ b/unit_test/wheel_print_test.py @@ -6,15 +6,15 @@ def test_printout_wheels(tmp_path, capsys): tmp_path.joinpath("example.0").touch() with print_new_wheels("TEST_MSG: {n}", tmp_path): - tmp_path.joinpath("example.1").touch() - tmp_path.joinpath("example.2").touch() + tmp_path.joinpath("example.1").write_bytes(b"0" * 1023) + tmp_path.joinpath("example.2").write_bytes(b"0" * 1025) captured = capsys.readouterr() assert captured.err == "" assert "example.0" not in captured.out - assert "example.1\n" in captured.out - assert "example.2\n" in captured.out + assert "example.1 1 kB\n" in captured.out + assert "example.2 2 kB\n" in captured.out assert "TEST_MSG:" in captured.out assert "TEST_MSG: 2\n" in captured.out From 1e37fff9acc31223acb95874e0b1472ecc3e64c9 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 30 Dec 2021 16:56:55 +0100 Subject: [PATCH 2/4] Update cibuildwheel/util.py Co-authored-by: Joe Rickerby --- cibuildwheel/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index ffa12315b..27dbc0a1e 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -368,7 +368,7 @@ class FileReport(NamedTuple): m = s / 60 print( msg.format(n=n, s=s, m=m), - *sorted(f" {f.name:<{max_name_len}s} {f.size:>{max_size_len}s} kB" for f in new_contents), + *sorted(f" {f.name:<{max_name_len}s} {f.size:>{max_size_len}s} kB" for f in new_contents), sep="\n", ) From 8eb14ebfa0f52e92c34ff4c36e01c4d8b10cf501 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 30 Dec 2021 16:57:00 +0100 Subject: [PATCH 3/4] Update unit_test/wheel_print_test.py Co-authored-by: Joe Rickerby --- unit_test/wheel_print_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unit_test/wheel_print_test.py b/unit_test/wheel_print_test.py index db62aa3e1..3fcadeb29 100644 --- a/unit_test/wheel_print_test.py +++ b/unit_test/wheel_print_test.py @@ -13,8 +13,8 @@ def test_printout_wheels(tmp_path, capsys): assert captured.err == "" assert "example.0" not in captured.out - assert "example.1 1 kB\n" in captured.out - assert "example.2 2 kB\n" in captured.out + assert "example.1 1 kB\n" in captured.out + assert "example.2 2 kB\n" in captured.out assert "TEST_MSG:" in captured.out assert "TEST_MSG: 2\n" in captured.out From d0235ab2e221b81b9a56de071daabde2d4f0998b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 30 Dec 2021 15:57:16 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- cibuildwheel/util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index 27dbc0a1e..36298c01c 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -368,7 +368,9 @@ class FileReport(NamedTuple): m = s / 60 print( msg.format(n=n, s=s, m=m), - *sorted(f" {f.name:<{max_name_len}s} {f.size:>{max_size_len}s} kB" for f in new_contents), + *sorted( + f" {f.name:<{max_name_len}s} {f.size:>{max_size_len}s} kB" for f in new_contents + ), sep="\n", )