Open asottile-sentry opened 4 months ago
Assuming you are trying to build watchdog binaries that work on macOS <10.13, this compiler error is absolutely finding a bug in watchdog where it is failing to conditionally guard symbols not available in older macOS versions!
On one hand I consider this a feature: we're preventing bugs!
On the other, we are inserting -Werror=unguarded-availability-new
into the compiler flags used to build CPython itself and CPython's build system exposes that as a CFLAG that should be used to compile extension modules. This propagation is definitely an unintended side-effect. (We added this compiler flag as a guardrail to help ensure our CPython builds don't reference symbols that aren't available in the target macOS version. This is a best practice when building portable macOS binaries. TBH I'm kind of surprised the CPython builds don't do this. I can make a case that extension module builds should be using this flag to prevent end-users from building wheels that don't conform to stated ABI compatibility.)
I think it is reasonable to strip this - and other custom - compiler flag from the sysconfig data to maintain compatibility with CPython.
Is this roughly: add some additional replacements to hack_sysconfig.py
(in build_cpython.sh
) to strip out -Werror=unguarded-availability-new
?
(Do we also need to strip from CPPFLAGS
?)
Yeah, this is a modification to hack_sysconfig.py
to strip flags/words from variables.
It looks like the flag is present in the following:
CFLAGS
CONFIGURE_CFLAGS
CONFIGURE_CPPFLAGS
CONFIG_ARGS
CPPFLAGS
PY_BUILTIN_MODULE_CFLAGS
PY_CFLAGS
PY_CORE_CFLAGS
PY_CPPFLAGS
PY_STDMODULE_CFLAGS
I'd have to look at which variables are used by Python build tools to propagate compiler flags: those are the ones we want to modify.
I'm hesitant to modify flags that denote how the Python distribution itself was built: that would constitute lying. But if a variable is overloaded to both reflect what was used and what to use, then I suppose we must modify it.
admittedly this is pointing out a real warning in
watchdog
-- but it makes it not installable using specifically these pythons:output:
a workaround is to remove that flag from
_sysconfigdata__darwin_darwin.py
after unpacking