From 0052372fa307a269cf4145f6ba143da23965bdeb Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Sun, 14 Sep 2025 08:05:11 +0300 Subject: [PATCH] Explicitly include Homebrew at /usr/local/include if passing -isysroot Apple CLang excludes it if -isysroot is passed --- plugins/python-build/bin/python-build | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 67191cd2..0e47c7f3 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1508,7 +1508,9 @@ use_homebrew() { if command -v brew &>/dev/null; then local brew_prefix="$(brew --prefix 2>/dev/null || true)" # /usr/local/lib:/usr/lib is the default library search path - if [[ -n $brew_prefix && $brew_prefix != "/usr" && $brew_prefix != "/usr/local" ]]; then + if [[ -n $brew_prefix && ( ( $brew_prefix != "/usr" && $brew_prefix != "/usr/local" ) + #when -isysroot is passed to Apple CLang, /usr/(local) are excluded from the default search path + || ( is_mac && osx_using_default_compiler && $CFLAGS =~ (^|\ )-isysroot\ ) ) ]]; then export CPPFLAGS="${CPPFLAGS:+$CPPFLAGS }-I${brew_prefix}/include" append_ldflags_libs "-L${brew_prefix}/lib -Wl,-rpath,${brew_prefix}/lib" lock_in homebrew @@ -1842,7 +1844,7 @@ use_homebrew_zlib() { use_xcode_sdk_zlib() { # If a custom compiler is used, including XCode SDK will likely break it - [[ "${CC:-clang}" != "clang" || "$(command -v clang 2>/dev/null || true)" != "/usr/bin/clang" ]] && return 1 + osx_using_default_compiler || return 1 local sdkroot="$(xcrun --sdk macosx --show-sdk-path 2>/dev/null || true)" [[ -z ${sdkroot} || ! -d ${sdkroot} ]] && return 1 @@ -1862,6 +1864,10 @@ use_xcode_sdk_zlib() { return 0 } +osx_using_default_compiler() { + [[ "${CC:-clang}" == "clang" && "$(command -v clang 2>/dev/null || true)" == "/usr/bin/clang" ]] +} + use_macports_zlib() { can_use_macports || return 1 if [[ $(port -q installed zlib | awk '{print $3}') == "(active)" ]]; then