diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index e7f79a45..6c5dfcc8 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -773,10 +773,13 @@ build_package_standard_build() { local PACKAGE_CFLAGS="${package_var_name}_CFLAGS" if [ "$package_var_name" = "PYTHON" ]; then - use_tcltk || true - use_homebrew_readline || use_freebsd_pkg || true + use_homebrew || true + use_tcltk || true + use_homebrew_readline || use_freebsd_pkg || true if is_mac -ge 1014; then use_xcode_sdk_zlib || use_homebrew_zlib || true + else + use_homebrew_zlib || true fi fi @@ -1325,6 +1328,19 @@ configured_with_package_dir() { return 1 } +use_homebrew() { + # unless Homebrew is at the default /usr/local, need to add its paths to + # compiler search to be able to use non-keg-only deps from there + 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 + export CPPFLAGS="${CPPFLAGS:+${CPPFLAGS% } }-I${brew_prefix}/include" + export LDFLAGS="${LDFLAGS:+${LDFLAGS% } }-L${brew_prefix}/lib" + fi + fi +} + needs_yaml() { ! configured_with_package_dir "python" "yaml.h" && ! use_homebrew_yaml diff --git a/plugins/python-build/test/build.bats b/plugins/python-build/test/build.bats index f30ce9f8..bcf656c2 100644 --- a/plugins/python-build/test/build.bats +++ b/plugins/python-build/test/build.bats @@ -62,10 +62,7 @@ assert_build_log() { cached_tarball "yaml-0.1.6" cached_tarball "Python-3.6.2" - # pyenv/pyenv#1026 - stub uname false false - - stub uname '-s : echo Linux' '-s : echo Linux' + for i in {1..4}; do stub uname '-s : echo Linux'; done stub brew false stub_make_install stub_make_install @@ -92,10 +89,7 @@ OUT cached_tarball "yaml-0.1.6" cached_tarball "Python-3.6.2" - # pyenv/pyenv#1026 - stub uname false false - - stub uname '-s : echo Linux' '-s : echo Linux' + for i in {1..4}; do stub uname '-s : echo Linux'; done stub brew false stub_make_install stub_make_install @@ -154,6 +148,34 @@ make install OUT } +@test "homebrew with uncommon prefix is added to search path" { + cached_tarball "Python-3.6.2" + + BREW_PREFIX="$TMP/homebrew-prefix" + mkdir -p "$BREW_PREFIX" + + for i in {1..4}; do stub uname '-s : echo Darwin'; done + for i in {1..2}; do stub sw_vers '-productVersion : echo 1010'; done + stub brew "--prefix : echo '$BREW_PREFIX'" false + stub_make_install + + run_inline_definition <>"$tcl_tk_libdir/lib/tclConfig.sh" stub uname false - - for i in {1..2}; do stub brew "--prefix tcl-tk : echo '$tcl_tk_libdir'"; done stub brew false + for i in {1..2}; do stub brew "--prefix tcl-tk : echo '$tcl_tk_libdir'"; done + for i in {1..2}; do stub brew false; done stub_make_install run_inline_definition <> build.log" \