diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index cc32c88a..1085545d 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -758,28 +758,104 @@ fix_rbx_irb() { } require_gcc() { - require_cc "gcc" + local gcc="$(locate_gcc || true)" + + if [ -z "$gcc" ]; then + local esc=$'\033' + { echo + echo "${esc}[1mERROR${esc}[0m: This package must be compiled with GCC, but python-build couldn't" + echo "find a suitable \`gcc\` executable on your system. Please install GCC" + echo "and try again." + echo + + if [ "$(uname -s)" = "Darwin" ]; then + echo "${esc}[1mDETAILS${esc}[0m: Apple no longer includes the official GCC compiler with Xcode" + echo "as of version 4.2. Instead, the \`gcc\` executable is a symlink to" + echo "\`llvm-gcc\`, a modified version of GCC which outputs LLVM bytecode." + echo + echo "For most programs the \`llvm-gcc\` compiler works fine. However," + echo "versions of CPython newer than 3.3.0 are incompatible with" + echo "\`llvm-gcc\`. To build newer versions of CPython you must have the official" + echo "GCC compiler installed on your system." + echo + + if type brew &>/dev/null; then + echo "${esc}[1mTO FIX THE PROBLEM${esc}[0m: Install Homebrew's apple-gcc42 package with this" + echo "command: ${esc}[4mbrew tap homebrew/dupes ; brew install apple-gcc42${esc}[0m" + else + echo "${esc}[1mTO FIX THE PROBLEM${esc}[0m: Install the official GCC compiler using these" + echo "packages: ${esc}[4mhttps://github.com/kennethreitz/osx-gcc-installer/downloads${esc}[0m" + fi + + echo + echo "You will need to install the official GCC compiler to build newer" + echo "versions of CPython even if you have installed Apple's Command Line Tools" + echo "for Xcode package. The Command Line Tools for Xcode package only" + echo "includes \`llvm-gcc\`." + fi + } >&3 + return 1 + fi + + export CC="$gcc" } -require_cc() { - while [ -n "$1" ]; do - if [ "$1" = "--if" ]; then - "$2" || return 0 - shift 2 - else - break - fi - done +locate_gcc() { + local gcc gccs + IFS=: gccs=($(gccs_in_path)) - local cc - local ccname="${1:-cc}" - cc="$(locate_cc "$ccname" || true)" + verify_gcc "$CC" || + verify_gcc "$(command -v gcc || true)" || { + for gcc in "${gccs[@]}"; do + verify_gcc "$gcc" && break || true + done + } + + return 1 +} + +gccs_in_path() { + local gcc path paths + local gccs=() + IFS=: paths=($PATH) + + shopt -s nullglob + for path in "${paths[@]}"; do + for gcc in "$path"/gcc-*; do + gccs["${#gccs[@]}"]="$gcc" + done + done + shopt -u nullglob + + printf :%s "${gccs[@]}" +} + +verify_gcc() { + local gcc="$1" + if [ -z "$gcc" ]; then + return 1 + fi + + local version="$("$gcc" --version || true)" + if [ -z "$version" ]; then + return 1 + fi + + if echo "$version" | grep LLVM >/dev/null; then + return 1 + fi + + echo "$gcc" +} + +require_clang() { + local cc="$(command -v "$CC" || command -v "clang" || command -v "cc" || true)" if [ -z "$cc" ]; then local esc=$'\033' { echo - echo "${esc}[1mERROR${esc}[0m: This package must be compiled with $ccname, but python-build couldn't" - echo "find a suitable \`$ccname\` executable on your system. Please install $ccname" + echo "${esc}[1mERROR${esc}[0m: This package must be compiled with cc, but python-build couldn't" + echo "find a suitable \`cc\` executable on your system. Please install cc" echo "and try again." echo } >&3 @@ -789,76 +865,8 @@ require_cc() { export CC="$cc" } -locate_gcc() { - locate_cc "gcc" "$@" -} - -locate_cc() { - local ccname="$1"; shift - if [ -z "$ccname" ]; then - return 1 - fi - local cc ccs - IFS=: ccs=($(ccs_in_path "${ccname}")) - - verify_cc "${ccname}" "$CC" || - verify_cc "${ccname}" "$(command -v "${ccname}" || true)" || { - for cc in "${ccs[@]}"; do - verify_cc "${ccname}" "$cc" && break || true - done - } - - return 1 -} - -gccs_in_path() { - ccs_in_path "gcc" "$@" -} - -ccs_in_path() { - local ccname="$1"; shift - if [ -z "$ccname" ]; then - return 1 - fi - local cc path paths - local ccs=() - IFS=: paths=($PATH) - - shopt -s nullglob - for path in "${paths[@]}"; do - for cc in "$path"/${ccname}-*; do - ccs["${#ccs[@]}"]="$cc" - done - done - shopt -u nullglob - - printf :%s "${ccs[@]}" -} - -verify_gcc() { - verify_cc "gcc" "$@" -} - -verify_cc() { - local ccname="$1"; shift - if [ -z "$ccname" ]; then - return 1 - fi - local cc="$1" - if [ -z "$cc" ]; then - return 1 - fi - - local version="$("$cc" --version || true)" - if [ -z "$version" ]; then - return 1 - fi - - echo "$cc" -} - require_java() { - local java="$(locate_java || true)" + local java="$(command -v java || true)" if [ -z "$java" ]; then local esc=$'\033' @@ -874,52 +882,8 @@ require_java() { export JAVA="$java" } -locate_java() { - local java javas - IFS=: javas=($(javas_in_path)) - - verify_java "$JAVA" || - verify_java "$(command -v java || true)" || { - for java in "${javas[@]}"; do - verify_java "$java" && break || true - done - } - - return 1 -} - -javas_in_path() { - local java path paths - local javas=() - IFS=: paths=($PATH) - - shopt -s nullglob - for path in "${paths[@]}"; do - local java="$path"/java - if [ -x "$java" ]; then - javas["${#javas[@]}"]="$java" - fi - done - shopt -u nullglob - - printf :%s "${javas[@]}" -} - -verify_java() { - local java="$1" - if [ -z "$java" ]; then - return 1 - fi - - if [ ! -x "$java" ]; then - return 1 - fi - - echo "$java" -} - needs_yaml() { - [[ "$RUBY_CONFIGURE_OPTS" != *--with-libyaml-dir=* ]] && + [[ "$PYTHON_CONFIGURE_OPTS" != *--with-libyaml-dir=* ]] && ! use_homebrew_yaml } @@ -1069,11 +1033,6 @@ apply_python_patch() { esac } -has_broken_mac_llvm_gcc() { - [ "$(uname -s)" = "Darwin" ] && - [[ "$(gcc --version 2>/dev/null || true)" == *"llvm-gcc-4.2"* ]] -} - build_package_verify_python() { # Check the existence of ./bin since pyenv-which searches the executables from there if [ ! -d "${PREFIX_PATH}/bin" ]; then diff --git a/plugins/python-build/share/python-build/3.3-dev b/plugins/python-build/share/python-build/3.3-dev index 9b1b5f2a..29d38d67 100644 --- a/plugins/python-build/share/python-build/3.3-dev +++ b/plugins/python-build/share/python-build/3.3-dev @@ -1,4 +1,4 @@ -require_cc --if has_broken_mac_llvm_gcc "clang" +require_clang || require_gcc install_package "readline-6.2" "http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz#67948acb2ca081f23359d0256e9a271c" standard --if has_broken_mac_readline install_hg "Python-3.3-dev" "https://bitbucket.org/mirror/cpython" "3.3" standard verify_py33 install_package "setuptools-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python diff --git a/plugins/python-build/share/python-build/3.3.0 b/plugins/python-build/share/python-build/3.3.0 index cd4b9c39..526399a2 100644 --- a/plugins/python-build/share/python-build/3.3.0 +++ b/plugins/python-build/share/python-build/3.3.0 @@ -1,4 +1,4 @@ -require_cc --if has_broken_mac_llvm_gcc "clang" +require_clang || require_gcc install_package "readline-6.2" "http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz#67948acb2ca081f23359d0256e9a271c" standard --if has_broken_mac_readline install_package "Python-3.3.0" "http://python.org/ftp/python/3.3.0/Python-3.3.0.tgz#198a64f7a04d1d5e95ce2782d5fd8254" ldflags_dirs standard verify_py33 install_package "setuptools-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python diff --git a/plugins/python-build/share/python-build/3.3.1 b/plugins/python-build/share/python-build/3.3.1 index 1f92a2d0..8ee90134 100644 --- a/plugins/python-build/share/python-build/3.3.1 +++ b/plugins/python-build/share/python-build/3.3.1 @@ -1,4 +1,4 @@ -require_cc --if has_broken_mac_llvm_gcc "clang" +require_clang || require_gcc install_package "readline-6.2" "http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz#67948acb2ca081f23359d0256e9a271c" standard --if has_broken_mac_readline install_package "Python-3.3.1" "http://python.org/ftp/python/3.3.1/Python-3.3.1.tgz#c19bfd6ea252b61779a4f2996fb3b330" ldflags_dirs standard verify_py33 install_package "setuptools-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python diff --git a/plugins/python-build/share/python-build/3.3.2 b/plugins/python-build/share/python-build/3.3.2 index 4c1aacb6..3e7b2a67 100644 --- a/plugins/python-build/share/python-build/3.3.2 +++ b/plugins/python-build/share/python-build/3.3.2 @@ -1,4 +1,4 @@ -require_cc --if has_broken_mac_llvm_gcc "clang" +require_clang || require_gcc install_package "readline-6.2" "http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz#67948acb2ca081f23359d0256e9a271c" standard --if has_broken_mac_readline install_package "Python-3.3.2" "http://python.org/ftp/python/3.3.2/Python-3.3.2.tgz#0a2ea57f6184baf45b150aee53c0c8da" ldflags_dirs standard verify_py33 install_package "setuptools-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python diff --git a/plugins/python-build/share/python-build/3.3.3 b/plugins/python-build/share/python-build/3.3.3 index 06a2ec19..96cdca31 100644 --- a/plugins/python-build/share/python-build/3.3.3 +++ b/plugins/python-build/share/python-build/3.3.3 @@ -1,4 +1,4 @@ -require_cc --if has_broken_mac_llvm_gcc "clang" +require_clang || require_gcc install_package "readline-6.2" "http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz#67948acb2ca081f23359d0256e9a271c" standard --if has_broken_mac_readline install_package "Python-3.3.3" "http://python.org/ftp/python/3.3.3/Python-3.3.3.tgz#831d59212568dc12c95df222865d3441" ldflags_dirs standard verify_py33 install_package "setuptools-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python diff --git a/plugins/python-build/share/python-build/3.4-dev b/plugins/python-build/share/python-build/3.4-dev index 1de4a50a..be2bc469 100644 --- a/plugins/python-build/share/python-build/3.4-dev +++ b/plugins/python-build/share/python-build/3.4-dev @@ -1,4 +1,4 @@ -require_cc --if has_broken_mac_llvm_gcc "clang" +require_clang || require_gcc install_package "readline-6.2" "http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz#67948acb2ca081f23359d0256e9a271c" standard --if has_broken_mac_readline install_hg "Python-3.4-dev" "https://bitbucket.org/mirror/cpython" "default" standard verify_py34 install_package "setuptools-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python diff --git a/plugins/python-build/share/python-build/3.4.0a2 b/plugins/python-build/share/python-build/3.4.0a2 index b751c844..bbcbefdf 100644 --- a/plugins/python-build/share/python-build/3.4.0a2 +++ b/plugins/python-build/share/python-build/3.4.0a2 @@ -1,4 +1,4 @@ -require_cc --if has_broken_mac_llvm_gcc "clang" +require_clang || require_gcc install_package "readline-6.2" "http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz#67948acb2ca081f23359d0256e9a271c" standard --if has_broken_mac_readline install_package "Python-3.4.0a2" "http://python.org/ftp/python/3.4.0/Python-3.4.0a2.tgz#e6e81242a32e6f63d224254d24edbd2f" ldflags_dirs standard verify_py34 install_package "setuptools-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python diff --git a/plugins/python-build/share/python-build/3.4.0a3 b/plugins/python-build/share/python-build/3.4.0a3 index e4aa2eca..6799d84d 100644 --- a/plugins/python-build/share/python-build/3.4.0a3 +++ b/plugins/python-build/share/python-build/3.4.0a3 @@ -1,4 +1,4 @@ -require_cc --if has_broken_mac_llvm_gcc "clang" +require_clang || require_gcc install_package "readline-6.2" "http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz#67948acb2ca081f23359d0256e9a271c" standard --if has_broken_mac_readline install_package "Python-3.4.0a3" "http://python.org/ftp/python/3.4.0/Python-3.4.0a3.tgz#3598af9717cddd4c346d731913fdfd64" ldflags_dirs standard verify_py34 install_package "setuptools-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python diff --git a/plugins/python-build/share/python-build/3.4.0a4 b/plugins/python-build/share/python-build/3.4.0a4 index e2dd8f5c..dbe8db37 100644 --- a/plugins/python-build/share/python-build/3.4.0a4 +++ b/plugins/python-build/share/python-build/3.4.0a4 @@ -1,4 +1,4 @@ -require_cc --if has_broken_mac_llvm_gcc "clang" +require_clang || require_gcc install_package "readline-6.2" "http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz#67948acb2ca081f23359d0256e9a271c" standard --if has_broken_mac_readline install_package "Python-3.4.0a4" "http://python.org/ftp/python/3.4.0/Python-3.4.0a4.tgz#f874d97c90130b0249848be889b5e6e1" ldflags_dirs standard verify_py34 install_package "setuptools-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python diff --git a/plugins/python-build/share/python-build/3.4.0b1 b/plugins/python-build/share/python-build/3.4.0b1 index a9608cf6..a3f1601b 100644 --- a/plugins/python-build/share/python-build/3.4.0b1 +++ b/plugins/python-build/share/python-build/3.4.0b1 @@ -1,4 +1,4 @@ -require_cc --if has_broken_mac_llvm_gcc "clang" +require_clang || require_gcc install_package "readline-6.2" "http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz#67948acb2ca081f23359d0256e9a271c" standard --if has_broken_mac_readline install_package "Python-3.4.0b1" "http://python.org/ftp/python/3.4.0/Python-3.4.0b1.tgz#83143a755b8a29a59026c1fdfb8d18fc" ldflags_dirs standard verify_py34 install_package "setuptools-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python diff --git a/plugins/python-build/share/python-build/3.4.0b2 b/plugins/python-build/share/python-build/3.4.0b2 index cd2f781f..7f44e4e9 100644 --- a/plugins/python-build/share/python-build/3.4.0b2 +++ b/plugins/python-build/share/python-build/3.4.0b2 @@ -1,4 +1,4 @@ -require_cc --if has_broken_mac_llvm_gcc "clang" +require_clang || require_gcc install_package "readline-6.2" "http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz#67948acb2ca081f23359d0256e9a271c" standard --if has_broken_mac_readline install_package "Python-3.4.0b2" "http://python.org/ftp/python/3.4.0/Python-3.4.0b2.tgz#afe112d6fe595f501f1dcb3627e7b476" ldflags_dirs standard verify_py34 install_package "setuptools-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python