|
1 | 1 | import codecs
|
| 2 | +import functools |
| 3 | +import io |
2 | 4 | import os
|
3 | 5 | import re
|
4 | 6 | import sys
|
@@ -197,20 +199,24 @@ def error(self, error: BaseException | str) -> None:
|
197 | 199 | print(f"cibuildwheel: {c.bright_red}error{c.end}: {error}\n", file=sys.stderr)
|
198 | 200 |
|
199 | 201 | def print_summary(self) -> None:
|
200 |
| - summary = "## 🎡: Wheels\n\n| Identifier | Wheel | Size | Time |\n|===|===|===|===|\n" |
| 202 | + string_io = io.StringIO() |
| 203 | + ioprint = functools.partial(print, file=string_io) |
| 204 | + ioprint("## 🎡: Wheels\n") |
| 205 | + ioprint("| Identifier | Wheel | Size | Time |") |
| 206 | + ioprint("|===|===|===|===|") |
201 | 207 | for ident, filename, duration in self.summary:
|
202 | 208 | if filename:
|
203 | 209 | size_mb = filename.stat().st_size / 1024**2
|
204 |
| - summary += f"| {ident} | {filename.name} | {size_mb:.2f} MB | {duration} |" |
| 210 | + ioprint(f"| {ident} | {filename.name} | {size_mb:.2f} MB | {duration} |") |
205 | 211 | else:
|
206 |
| - summary += f"| {ident} | test only | --- | {duration} |" |
| 212 | + ioprint(f"| {ident} | test only | --- | {duration} |") |
207 | 213 |
|
208 |
| - match self.summary_mode: |
209 |
| - case "github": |
210 |
| - Path(os.environ["GITHUB_STEP_SUMMARY"]).write_text(summary, encoding="utf-8") |
211 |
| - print(summary) |
212 |
| - case _: |
213 |
| - print(summary) |
| 214 | + if self.summary_mode == "github": |
| 215 | + Path(os.environ["GITHUB_STEP_SUMMARY"]).write_text( |
| 216 | + string_io.getvalue(), encoding="utf-8" |
| 217 | + ) |
| 218 | + |
| 219 | + print(string_io.getvalue()) |
214 | 220 |
|
215 | 221 | self.summary = []
|
216 | 222 |
|
|
0 commit comments