Prefer tcl-tk@8 from Homebrew

Since 10.11.2024, Homebrew upgraded tck-tk to 9.0
which CPython is not compatible with yet
This commit is contained in:
Ivan Pozdeev 2024-12-04 02:19:23 +03:00
parent 0f8b2b2b84
commit 75358a2ce5

View File

@ -1671,25 +1671,32 @@ use_xcode_sdk_zlib() {
use_homebrew_tcltk() { use_homebrew_tcltk() {
can_use_homebrew || return 1 can_use_homebrew || return 1
# get the version from the folder that homebrew versions # Since https://github.com/Homebrew/homebrew-core/commit/f10e88617b41555193c22fdcba6109fe82155ee2 (10.11.2024),
local tcltk_libdir="$(brew --prefix tcl-tk 2>/dev/null || true)" # tcl-tk is 9.0 which is not compatible with CPython as of this writing
if [ -d "$tcltk_libdir" ]; then # but we'll keep it as backup for cases like non-updated Homebrew
echo "python-build: use tcl-tk from homebrew" local tcltk
if [[ -z "$PYTHON_BUILD_TCLTK_USE_PKGCONFIG" ]]; then for tcltk in "tcl-tk@8" "tcl-tk"; do
local tcltk_version="$(sh -c '. '"$tcltk_libdir"'/lib/tclConfig.sh; echo $TCL_VERSION')" local tcltk_libdir="$(brew --prefix "${tcltk}" 2>/dev/null || true)"
package_option python configure --with-tcltk-libs="-L$tcltk_libdir/lib -ltcl$tcltk_version -ltk$tcltk_version" if [ -d "$tcltk_libdir" ]; then
# In Homebrew Tcl/Tk 8.6.13, headers have been moved to the 'tcl-tk' subdir. echo "python-build: use tcl-tk from homebrew"
# We're not using tclConfig.sh here 'cuz it produces the version-specific path to <brew prefix>/Cellar if [[ -z "$PYTHON_BUILD_TCLTK_USE_PKGCONFIG" ]]; then
# and we'd rather have rpath set to <brew prefix>/opt/<...> to allow micro release upgrades without rebuilding local tcltk_version="$(sh -c '. '"$tcltk_libdir"'/lib/tclConfig.sh; echo $TCL_VERSION')"
# XXX: do use tclConfig.sh and translate the paths if more path shenanigans appear in later releases package_option python configure --with-tcltk-libs="-L$tcltk_libdir/lib -ltcl$tcltk_version -ltk$tcltk_version"
if [ -d "$tcltk_libdir/include/tcl-tk" ]; then # In Homebrew Tcl/Tk 8.6.13, headers have been moved to the 'tcl-tk' subdir.
package_option python configure --with-tcltk-includes="-I$tcltk_libdir/include/tcl-tk" # We're not using tclConfig.sh here 'cuz it produces the version-specific path to <brew prefix>/Cellar
else # and we'd rather have rpath set to <brew prefix>/opt/<...> to allow micro release upgrades without rebuilding
package_option python configure --with-tcltk-includes="-I$tcltk_libdir/include" # 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}"
return
fi fi
export PKG_CONFIG_PATH="${tcltk_libdir}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" done
fi return 1
} }
# FIXME: this function is a workaround for #1125 # FIXME: this function is a workaround for #1125