From badc8255abd7fc83c6a2bf757c8ec89982eaff7d Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Fri, 17 Jan 2014 21:09:52 +0900 Subject: [PATCH] Do not invoke `use_homebrew_readline` twice --- plugins/python-build/bin/python-build | 33 +++++++++++++++++---------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index ee4de1fa..89a7d903 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -913,28 +913,37 @@ use_homebrew_yaml() { fi } +configured_with_readline_dir() { + # Mac OS X 10.4 has broken readline. + # https://github.com/yyuu/pyenv/issues/23 + local arg flag + for arg in ${CONFIGURE_OPTS} ${PYTHON_CONFIGURE_OPTS} "${PYTHON_CONFIGURE_OPTS_ARRAY[@]}"; do + if [[ "$arg" == "CPPFLAGS="* ]]; then + for flag in ${CPPFLAGS} ${arg##CPPFLAGS=}; do + if [[ "$flag" == "-I"* ]] && [ -e "${flag##-I}/readline/rlconf.h" ]; then + return 0 + fi + done + fi + done + return 1 +} + has_broken_mac_readline() { - if [ "$(uname -s)" = "Darwin" ] && ! use_homebrew_readline; then - # MacOSX 10.4 has a broken readline. - # https://github.com/yyuu/pyenv/issues/23 - local retval=1 - local conftest="$BUILD_PATH/has_broken_mac_readline.h" - echo "#include " > "$conftest" - "${CPP:-cpp}" $CPPFLAGS "$conftest" 1>/dev/null 2>&1 || retval=0 - rm -f "$conftest" - return "$retval" - else - return 1 - fi + [ "$(uname -s)" = "Darwin" ] && + ! configured_with_readline_dir && + ! use_homebrew_readline } use_homebrew_readline() { + if ! configured_with_readline_dir; then local libdir="$(brew --prefix readline 2>/dev/null || true)" if [ -d "$libdir" ]; then package_option python configure CPPFLAGS="-I$libdir/include" LDFLAGS="-L$libdir/lib" else return 1 fi + fi } has_broken_mac_openssl() {