Skip to content

Commit 8a190f4

Browse files
committed
fix: try making the warnings once per Options
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 2a25c6d commit 8a190f4

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

cibuildwheel/logger.py

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

6766

68-
@dataclasses.dataclass
6967
class Logger:
70-
fold_mode: str = "disabled"
71-
colors_enabled: bool = False
72-
unicode_enabled: bool = False
68+
fold_mode: str
69+
colors_enabled: bool
70+
unicode_enabled: bool
7371
active_build_identifier: str | None = None
7472
build_start_time: float | None = None
7573
step_start_time: float | None = None
7674
active_fold_group_name: str | None = None
77-
deduplicate: set[str] = dataclasses.field(default_factory=set)
7875

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

10198
elif ci_provider == CIProvider.appveyor:
99+
self.fold_mode = "disabled"
102100
self.colors_enabled = True
103101

104102
else:
103+
self.fold_mode = "disabled"
105104
self.colors_enabled = file_supports_color(sys.stdout)
106105

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

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

cibuildwheel/options.py

+13-7
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ def __init__(
576576
self.command_line_arguments = command_line_arguments
577577
self.env = env
578578
self._defaults = defaults
579+
self._image_warnings = set[str]()
579580

580581
self.reader = OptionsReader(
581582
None if defaults else self.config_file_path,
@@ -775,19 +776,24 @@ def _compute_build_options(self, identifier: str | None) -> BuildOptions:
775776
# default to manylinux2014
776777
image = pinned_images["manylinux2014"]
777778
elif config_value in pinned_images:
778-
if config_value in {
779-
"manylinux1",
780-
"manylinux2010",
781-
"manylinux_2_24",
782-
"musllinux_1_1",
783-
}:
779+
if (
780+
config_value
781+
in {
782+
"manylinux1",
783+
"manylinux2010",
784+
"manylinux_2_24",
785+
"musllinux_1_1",
786+
}
787+
and config_value not in self._image_warnings
788+
):
789+
self._image_warnings.add(config_value)
784790
msg = (
785791
f"Deprecated image {config_value!r}. This value will not work"
786792
" in a future version of cibuildwheel. Either upgrade to a supported"
787793
" image or continue using the deprecated image by pinning directly"
788794
f" to {pinned_images[config_value]!r}."
789795
)
790-
log.warning(msg, deduplicate=True)
796+
log.warning(msg)
791797
image = pinned_images[config_value]
792798
else:
793799
image = config_value

0 commit comments

Comments
 (0)