Fix linking against Homebrew's Tcl/Tk 8.6.13 in MacOS (#2820)

Headers have been moved to the 'tcl-tk' subdir
This was causing Tcl/Tk 8.5 from XCode SDK to be silently picked instead
This commit is contained in:
startergo 2023-10-15 10:17:22 -04:00 committed by GitHub
parent 709534c21f
commit d25cd0d0f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1629,6 +1629,9 @@ use_xcode_sdk_zlib() {
local xc_sdk_path="$(xcrun --show-sdk-path 2>/dev/null || true)" local xc_sdk_path="$(xcrun --show-sdk-path 2>/dev/null || true)"
if [ -d "$xc_sdk_path" ]; then if [ -d "$xc_sdk_path" ]; then
echo "python-build: use zlib from xcode sdk" echo "python-build: use zlib from xcode sdk"
# Even though SDK's compiler uses the SDK dirs implicitly,
# CPython's setup.py has to have nonstandard paths specified explicitly
# to search for zlib.h in them
export CPPFLAGS="${CPPFLAGS:+$CPPFLAGS }-I${xc_sdk_path}/usr/include" export CPPFLAGS="${CPPFLAGS:+$CPPFLAGS }-I${xc_sdk_path}/usr/include"
if is_mac -ge 1100; then if is_mac -ge 1100; then
export LDFLAGS="${LDFLAGS:+$LDFLAGS }-L${xc_sdk_path}/usr/lib" export LDFLAGS="${LDFLAGS:+$LDFLAGS }-L${xc_sdk_path}/usr/lib"
@ -1645,7 +1648,15 @@ use_homebrew_tcltk() {
if [[ -z "$PYTHON_BUILD_TCLTK_USE_PKGCONFIG" ]]; then if [[ -z "$PYTHON_BUILD_TCLTK_USE_PKGCONFIG" ]]; then
local tcltk_version="$(sh -c '. '"$tcltk_libdir"'/lib/tclConfig.sh; echo $TCL_VERSION')" local tcltk_version="$(sh -c '. '"$tcltk_libdir"'/lib/tclConfig.sh; echo $TCL_VERSION')"
package_option python configure --with-tcltk-libs="-L$tcltk_libdir/lib -ltcl$tcltk_version -ltk$tcltk_version" package_option python configure --with-tcltk-libs="-L$tcltk_libdir/lib -ltcl$tcltk_version -ltk$tcltk_version"
package_option python configure --with-tcltk-includes="-I$tcltk_libdir/include" # In Homebrew Tcl/Tk 8.6.13, headers have been moved to the 'tcl-tk' subdir.
# We're not using tclConfig.sh here 'cuz it produces the version-specific path to <brew prefix>/Cellar
# and we'd rather have rpath set to <brew prefix>/opt/<...> to allow micro release upgrades without rebuilding
# XXX: do use tclConfig.sh and translate the paths if more path shenanigans appear in later releases
if [ -d "$tcltk_libdir/include/tcl-tk" ]; then
package_option python configure --with-tcltk-includes="-I$tcltk_libdir/include/tcl-tk"
else
package_option python configure --with-tcltk-includes="-I$tcltk_libdir/include"
fi
fi fi
export PKG_CONFIG_PATH="${tcltk_libdir}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" export PKG_CONFIG_PATH="${tcltk_libdir}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
fi fi