Skip to content

Commit d39843a

Browse files
committed
fix: handle repeated warning messages
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 9fa0075 commit d39843a

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

cibuildwheel/logger.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import codecs
2+
import dataclasses
23
import os
34
import re
45
import sys
@@ -64,16 +65,18 @@ def __init__(self, *, unicode: bool) -> None:
6465
self.error = "✕" if unicode else "failed"
6566

6667

68+
@dataclasses.dataclass
6769
class Logger:
68-
fold_mode: str
69-
colors_enabled: bool
70-
unicode_enabled: bool
70+
fold_mode: str = "disabled"
71+
colors_enabled: bool = False
72+
unicode_enabled: bool = False
7173
active_build_identifier: str | None = None
7274
build_start_time: float | None = None
7375
step_start_time: float | None = None
7476
active_fold_group_name: str | None = None
77+
dedupiclate: set[str] = dataclasses.field(default_factory=set)
7578

76-
def __init__(self) -> None:
79+
def __post_init__(self) -> None:
7780
if sys.platform == "win32" and hasattr(sys.stdout, "reconfigure"):
7881
# the encoding on Windows can be a 1-byte charmap, but all CIs
7982
# support utf8, so we hardcode that
@@ -96,11 +99,9 @@ def __init__(self) -> None:
9699
self.colors_enabled = True
97100

98101
elif ci_provider == CIProvider.appveyor:
99-
self.fold_mode = "disabled"
100102
self.colors_enabled = True
101103

102104
else:
103-
self.fold_mode = "disabled"
104105
self.colors_enabled = file_supports_color(sys.stdout)
105106

106107
def build_start(self, identifier: str) -> None:
@@ -164,7 +165,11 @@ def notice(self, message: str) -> None:
164165
c = self.colors
165166
print(f"cibuildwheel: {c.bold}note{c.end}: {message}\n", file=sys.stderr)
166167

167-
def warning(self, message: str) -> None:
168+
def warning(self, message: str, *, deduplicate: bool = False) -> None:
169+
if deduplicate and message in self.dedupiclate:
170+
return
171+
self.dedupiclate.add(message)
172+
168173
if self.fold_mode == "github":
169174
print(f"::warning::cibuildwheel: {message}\n", file=sys.stderr)
170175
else:

cibuildwheel/options.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,13 @@ def _compute_build_options(self, identifier: str | None) -> BuildOptions:
781781
"manylinux_2_24",
782782
"musllinux_1_1",
783783
}:
784-
msg = f"Unmaintained image, either upgrade to a supported image or pin directly to {pinned_images[config_value]!r}"
785-
log.warning(msg)
784+
msg = (
785+
f"Deprecated image {config_value!r}. This value will not work"
786+
" in a future version of cibuildwheel. Either upgrade to a supported"
787+
" image or continue using the deprecated image by pinning directly"
788+
f" to {pinned_images[config_value]!r}."
789+
)
790+
log.warning(msg, deduplicate=True)
786791
image = pinned_images[config_value]
787792
else:
788793
image = config_value

0 commit comments

Comments
 (0)