diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 4f12c42e..a48f514e 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -814,7 +814,7 @@ build_package_standard_build() { if [ "$package_var_name" = "PYTHON" ]; then use_homebrew || true - use_tcltk || true + use_custom_tcltk || use_homebrew_tcltk || true use_homebrew_readline || use_freebsd_pkg || true use_homebrew_ncurses || true if is_mac -ge 1014; then @@ -1693,7 +1693,7 @@ use_homebrew_tcltk() { fi fi export PKG_CONFIG_PATH="${tcltk_libdir}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" - return + return 0 fi done return 1 @@ -1701,8 +1701,13 @@ use_homebrew_tcltk() { # FIXME: this function is a workaround for #1125 # once fixed, it should be removed. +# if tcltk_ops_flag is in PYTHON_CONFIGURE_OPTS, use user provided tcltk use_custom_tcltk() { - local tcltk_ops="$1" + local tcl_tk_ops="$(get_tcltk_flag_from "$PYTHON_CONFIGURE_OPTS")" + + if [[ -z "$tcl_tk_ops" ]]; then + return 1 + fi local tcltk_ops_flag="--with-tcltk-libs=" # get tcltk libs local tcltk_libs="${tcltk_ops//$tcltk_ops_flag/}" @@ -1745,21 +1750,6 @@ get_tcltk_flag_from() { IFS="$OLDIFS" } -use_tcltk() { - if can_use_homebrew; then - local tcltk_libdir="$(brew --prefix tcl-tk 2>/dev/null || true)" - fi - local tcl_tk_libs="$(get_tcltk_flag_from "$PYTHON_CONFIGURE_OPTS")" - - # if tcltk_ops_flag is in PYTHON_CONFIGURE_OPTS, use user provided tcltk - # otherwise default to homebrew-installed tcl-tk, if installed - if [[ -n "$tcl_tk_libs" ]]; then - use_custom_tcltk "$tcl_tk_libs" - elif [ -d "$tcltk_libdir" ]; then - use_homebrew_tcltk - fi -} - # Since 3.12, CPython can add DWARF debug information in MacOS # using Apple's nonstandard way, `dsymutil', that creates a "dSYM bundle" # that's supposed to be installed alongside executables diff --git a/plugins/python-build/test/build.bats b/plugins/python-build/test/build.bats index 3a1e4e6f..271c274a 100644 --- a/plugins/python-build/test/build.bats +++ b/plugins/python-build/test/build.bats @@ -182,7 +182,7 @@ OUT for i in {1..10}; do stub uname '-s : echo Darwin'; done for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done stub brew "--prefix libyaml : echo '$brew_libdir'" - for i in {1..5}; do stub brew false; done + for i in {1..6}; do stub brew false; done stub_make_install install_fixture definitions/needs-yaml @@ -208,7 +208,7 @@ OUT mkdir -p "$readline_libdir" for i in {1..8}; do stub uname '-s : echo Darwin'; done for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done - for i in {1..2}; do stub brew false; done + for i in {1..3}; do stub brew false; done stub brew "--prefix readline : echo '$readline_libdir'" for i in {1..2}; do stub brew false; done stub_make_install @@ -238,7 +238,7 @@ OUT mkdir -p "$ncurses_libdir" for i in {1..9}; do stub uname '-s : echo Darwin'; done for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done - for i in {1..3}; do stub brew false; done + for i in {1..4}; do stub brew false; done stub brew "--prefix ncurses : echo '$ncurses_libdir'" stub brew false stub_make_install @@ -364,7 +364,7 @@ OUT for i in {1..4}; do stub uname '-s : echo Linux'; done stub brew "--prefix : echo '$BREW_PREFIX'" - for i in {1..4}; do stub brew false; done + for i in {1..5}; do stub brew false; done stub_make_install export PYTHON_BUILD_USE_HOMEBREW=1 @@ -394,7 +394,7 @@ OUT for i in {1..4}; do stub uname '-s : echo Linux'; done stub brew "--prefix : echo '$BREW_PREFIX'" - for i in {1..4}; do stub brew false; done + for i in {1..5}; do stub brew false; done stub_make_install export PYTHON_BUILD_USE_HOMEBREW=1 @@ -453,7 +453,7 @@ OUT for i in {1..8}; do stub uname '-s : echo Darwin'; done for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done - for i in {1..4}; do stub brew false; done + for i in {1..5}; do stub brew false; done stub_make_install export PYTHON_CONFIGURE_OPTS="CPPFLAGS=-I$readline_libdir/include LDFLAGS=-L$readline_libdir/lib" @@ -482,11 +482,11 @@ OUT mkdir -p "$tcl_tk_libdir/lib" echo "TCL_VERSION='$tcl_tk_version'" >>"$tcl_tk_libdir/lib/tclConfig.sh" - for i in {1..10}; do stub uname '-s : echo Darwin'; done + for i in {1..9}; do stub uname '-s : echo Darwin'; done for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done stub brew false - for i in {1..2}; do stub brew "--prefix tcl-tk : echo '$tcl_tk_libdir'"; done + stub brew "--prefix tcl-tk@8 : echo '$tcl_tk_libdir'" for i in {1..3}; do stub brew false; done stub_make_install @@ -516,10 +516,10 @@ OUT tcl_tk_version_long="8.6.10" tcl_tk_version="${tcl_tk_version_long%.*}" - for i in {1..9}; do stub uname '-s : echo Darwin'; done + for i in {1..8}; do stub uname '-s : echo Darwin'; done for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done - for i in {1..5}; do stub brew false; done + for i in {1..4}; do stub brew false; done stub_make_install export PYTHON_CONFIGURE_OPTS="--with-tcltk-libs='-L${TMP}/custom-tcl-tk/lib -ltcl$tcl_tk_version -ltk$tcl_tk_version'" @@ -544,14 +544,14 @@ OUT @test "tcl-tk is linked from Homebrew via pkgconfig only when envvar is set" { cached_tarball "Python-3.6.2" - for i in {1..10}; do stub uname '-s : echo Darwin'; done + for i in {1..9}; do stub uname '-s : echo Darwin'; done for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done tcl_tk_libdir="$TMP/homebrew-tcl-tk" mkdir -p "$tcl_tk_libdir/lib" stub brew false - for i in {1..2}; do stub brew "--prefix tcl-tk : echo '${tcl_tk_libdir}'"; done + stub brew "--prefix tcl-tk@8 : echo '${tcl_tk_libdir}'" for i in {1..3}; do stub brew false; done stub_make_install