Skip to content

Commit b3d580e

Browse files
authored
Handle removed is_rgb from fmt 11.2.0 (#3998)
1 parent 6adb2ea commit b3d580e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

libmambapy/src/libmambapy/bindings/utils.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@
1717

1818
namespace mambapy
1919
{
20+
// NOTE: These fmt "internals" are for internal use only.
21+
// External users should not use them in their projects.
22+
// Instead, rely on the public API or appropriate abstractions.
23+
// (not sure if they exist at the moment for this specific use case though)
24+
// cf. https://github.com/fmtlib/fmt/issues/4466
25+
bool fmt_is_rgb(const fmt::detail::color_type& color_type)
26+
{
27+
#if FMT_VERSION >= 110200
28+
return !color_type.is_terminal_color();
29+
#else
30+
return color_type.is_rgb;
31+
#endif
32+
}
33+
2034
void bind_submodule_utils(pybind11::module_ m)
2135
{
2236
namespace py = pybind11;
@@ -110,7 +124,7 @@ namespace mambapy
110124
return std::nullopt;
111125
}
112126
const auto fg = style.get_foreground();
113-
if (fg.is_rgb)
127+
if (fmt_is_rgb(fg))
114128
{
115129
return { { fmt::rgb(fg.value.rgb_color) } };
116130
}
@@ -126,7 +140,7 @@ namespace mambapy
126140
return std::nullopt;
127141
}
128142
const auto bg = style.get_background();
129-
if (bg.is_rgb)
143+
if (fmt_is_rgb(bg))
130144
{
131145
return { { fmt::rgb(bg.value.rgb_color) } };
132146
}

0 commit comments

Comments
 (0)