From ca551b3a550b752b2d7e329a945392702c7292fc Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Thu, 18 Sep 2025 19:41:50 +0300 Subject: [PATCH] Add PYTHON_BUILD_TCLTK_FORMULA to allow building against Tcl/Tk 9 Tcl/Tk 9.0 support was added in 3.13.0b3 and is not official as of 3.14.0; the build with Homebrew version fails as of this writing --- plugins/python-build/README.md | 1 + plugins/python-build/bin/python-build | 2 +- plugins/python-build/test/build.bats | 36 ++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/plugins/python-build/README.md b/plugins/python-build/README.md index 2b8852cf..22dc2420 100644 --- a/plugins/python-build/README.md +++ b/plugins/python-build/README.md @@ -175,6 +175,7 @@ You can set certain environment variables to control the build process. * `PYTHON_BUILD_SKIP_HOMEBREW`, if set, will not search for libraries installed by Homebrew when it would normally will. * `PYTHON_BUILD_USE_HOMEBREW`, if set, will search for libraries installed by Homebrew when it would normally not. * `PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA`, override the Homebrew OpenSSL formula to use. +* `PYTHON_BUILD_TCLTK_FORMULA`, override the Homebrew Tcl/Tk formula to use. * `PYTHON_BUILD_SKIP_MACPORTS`, if set, will not search for libraries installed by MacPorts when it would normally will. * `PYTHON_BUILD_USE_MACPORTS`, if set, will search for libraries installed by MacPorts when it would normally not. * `PYTHON_BUILD_ROOT` overrides the default location from where build definitions diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 157833e6..082603e0 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1884,7 +1884,7 @@ use_homebrew_tcltk() { # tcl-tk is 9.0 which is not compatible with CPython as of this writing # but we'll keep it as backup for cases like non-updated Homebrew local tcltk - for tcltk in "tcl-tk@8" "tcl-tk"; do + for tcltk in ${PYTHON_BUILD_TCLTK_FORMULA:-tcl-tk@8 tcl-tk}; do local tcltk_libdir="$(brew --prefix "${tcltk}" 2>/dev/null || true)" if [ -d "$tcltk_libdir" ]; then echo "python-build: use tcl-tk from homebrew" diff --git a/plugins/python-build/test/build.bats b/plugins/python-build/test/build.bats index e87e1569..d123103e 100644 --- a/plugins/python-build/test/build.bats +++ b/plugins/python-build/test/build.bats @@ -46,7 +46,7 @@ tarball() { #!$BASH echo "$name: CFLAGS=\\"\$CFLAGS\\" CPPFLAGS=\\"\$CPPFLAGS\\" LDFLAGS=\\"\$LDFLAGS\\" PKG_CONFIG_PATH=\\"\$PKG_CONFIG_PATH\\"" >> build.log echo "$name:" "\$@" \${PYTHONOPT:+PYTHONOPT=\$PYTHONOPT} >> build.log -${extra_vars:+echo \"$name: $extra_vars\" >>build.log} +${extra_vars:+echo $name: $extra_vars >>build.log} OUT for file; do @@ -794,6 +794,40 @@ make install OUT } +@test "tcl-tk is linked from Homebrew with PYTHON_BUILD_TCLTK_FORMULA" { + cached_tarball "Python-3.6.2" + tcl_tk_version=8.6 + tcl_tk_libdir="$BATS_TEST_TMPDIR/homebrew-tcl-tk" + mkdir -p "$tcl_tk_libdir/lib" + echo "TCL_VERSION='$tcl_tk_version'" >>"$tcl_tk_libdir/lib/tclConfig.sh" + + stub uname '-s : echo Darwin' + stub sw_vers '-productVersion : echo 1010' + + stub brew "--prefix tcl-tk-custom : echo '$tcl_tk_libdir'" + for i in {1..4}; do stub brew false; done + + stub_make_install + + run_inline_definition <