From 9ce760c798a172bb5afee3e6ac6da4f34eabb059 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Fri, 28 Jun 2013 12:18:45 +0900 Subject: [PATCH 1/2] add `require_cc()` to test existence of CC other than GCC --- plugins/python-build/bin/python-build | 76 +++++++++++++++++++-------- 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 27449be9..a090ec54 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -622,30 +622,48 @@ fix_directory_permissions() { } require_gcc() { - local gcc="$(locate_gcc || true)" + require_cc "gcc" +} + +require_cc() { + local cc ccname + for ccname in "$@"; do + cc="$(locate_cc "$ccname" || true)" + if [ -n "$cc" ]; then + break + fi + done - if [ -z "$gcc" ]; then + if [ -z "$cc" ]; 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 "${esc}[1mERROR${esc}[0m: This package must be compiled with $@, but python-build couldn't" + echo "find a suitable \`cc\` executable on your system. Please install $@" echo "and try again." echo } >&3 return 1 fi + + export CC="$cc" +} - export CC="$gcc" +locate_gcc() { + locate_cc "gcc" "$@" } -locate_gcc() { - local gcc gccs - IFS=: gccs=($(gccs_in_path)) +locate_cc() { + local ccname="$1"; shift + if [ -z "$ccname" ]; then + return 1 + fi + local cc ccs + IFS=: ccs=($(ccs_in_path "${ccname}")) - verify_gcc "$CC" || - verify_gcc "$(command -v gcc || true)" || { - for gcc in "${gccs[@]}"; do - verify_gcc "$gcc" && break || true + verify_cc "${ccname}" "$CC" || + verify_cc "${ccname}" "$(command -v "${ccname}" || true)" || { + for cc in "${ccs[@]}"; do + verify_cc "${ccname}" "$cc" && break || true done } @@ -653,33 +671,49 @@ locate_gcc() { } gccs_in_path() { - local gcc path paths - local gccs=() + 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 gcc in "$path"/gcc-*; do - gccs["${#gccs[@]}"]="$gcc" + for cc in "$path"/${ccname}-*; do + ccs["${#ccs[@]}"]="$cc" done done shopt -u nullglob - printf :%s "${gccs[@]}" + printf :%s "${ccs[@]}" } verify_gcc() { - local gcc="$1" - if [ -z "$gcc" ]; then + 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="$("$gcc" --version || true)" + local version="$("$cc" --version || true)" if [ -z "$version" ]; then return 1 fi - echo "$gcc" + echo "$cc" } has_broken_mac_openssl() { From f76faa88b8840c2edca39ebde78b22b8d069f6ea Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Sat, 29 Jun 2013 12:27:19 +0900 Subject: [PATCH 2/2] add has_broken_mac_gcc_llvm and use clang if true --- plugins/python-build/bin/python-build | 27 ++++++++++++++----- .../python-build/share/python-build/3.3-dev | 2 +- plugins/python-build/share/python-build/3.3.0 | 2 +- plugins/python-build/share/python-build/3.3.1 | 2 +- plugins/python-build/share/python-build/3.3.2 | 2 +- .../python-build/share/python-build/3.4-dev | 2 +- 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index a090ec54..a313f542 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -626,19 +626,27 @@ require_gcc() { } require_cc() { - local cc ccname - for ccname in "$@"; do - cc="$(locate_cc "$ccname" || true)" - if [ -n "$cc" ]; then + while [ -n "$1" ]; do + if [ "$1" = "--if" ]; then + "$2" || return 0 + shift 2 + else break fi done + local cc + local ccname="${1:-cc}" + cc="$(locate_cc "$ccname" || true)" + if [ -n "$cc" ]; then + break + fi + if [ -z "$cc" ]; then local esc=$'\033' { echo - echo "${esc}[1mERROR${esc}[0m: This package must be compiled with $@, but python-build couldn't" - echo "find a suitable \`cc\` executable on your system. Please install $@" + echo "${esc}[1mERROR${esc}[0m: This package must be compiled with $ccname, but python-build couldn't" + echo "find a suitable \`cc\` executable on your system. Please install $ccname" echo "and try again." echo } >&3 @@ -671,7 +679,7 @@ locate_cc() { } gccs_in_path() { - ccs_in_path "$gcc" "$@" + ccs_in_path "gcc" "$@" } ccs_in_path() { @@ -764,6 +772,11 @@ has_broken_mac_readline() { return "$retval" } +has_broken_mac_gcc_llvm() { + [ "$(uname -s)" = "Darwin" ] && + [ "$(gcc --version 2>/dev/null || true)" = "llvm-gcc-4.2" ] +} + # Post-install check for Python 2.5.x build_package_verify_py25() { build_package_verify_readline "$@" diff --git a/plugins/python-build/share/python-build/3.3-dev b/plugins/python-build/share/python-build/3.3-dev index 181c1443..d713046f 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_gcc +require_cc --if has_broken_mac_gcc_llvm "clang" 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-0.7.4" "https://bitbucket.org/pypa/setuptools/downloads/setuptools-0.7.4.tar.gz#c0b8864b63c13312f5d9568c2a54247e" python diff --git a/plugins/python-build/share/python-build/3.3.0 b/plugins/python-build/share/python-build/3.3.0 index 34f6eb70..686305e8 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_gcc +require_cc --if has_broken_mac_gcc_llvm "clang" 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" standard verify_py33 install_package "setuptools-0.7.4" "https://bitbucket.org/pypa/setuptools/downloads/setuptools-0.7.4.tar.gz#c0b8864b63c13312f5d9568c2a54247e" python diff --git a/plugins/python-build/share/python-build/3.3.1 b/plugins/python-build/share/python-build/3.3.1 index a56d8956..99343463 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_gcc +require_cc --if has_broken_mac_gcc_llvm "clang" 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" standard verify_py33 install_package "setuptools-0.7.4" "https://bitbucket.org/pypa/setuptools/downloads/setuptools-0.7.4.tar.gz#c0b8864b63c13312f5d9568c2a54247e" python diff --git a/plugins/python-build/share/python-build/3.3.2 b/plugins/python-build/share/python-build/3.3.2 index a6cc8f54..d5628865 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_gcc +require_cc --if has_broken_mac_gcc_llvm "clang" 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" standard verify_py33 install_package "setuptools-0.7.4" "https://bitbucket.org/pypa/setuptools/downloads/setuptools-0.7.4.tar.gz#c0b8864b63c13312f5d9568c2a54247e" python diff --git a/plugins/python-build/share/python-build/3.4-dev b/plugins/python-build/share/python-build/3.4-dev index 7ac5bf69..c8a589ff 100644 --- a/plugins/python-build/share/python-build/3.4-dev +++ b/plugins/python-build/share/python-build/3.4-dev @@ -5,7 +5,7 @@ if ! pyenv-which python3.4 1>/dev/null 2>&1; then fi fi -require_gcc +require_cc --if has_broken_mac_gcc_llvm "clang" 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-0.7.4" "https://bitbucket.org/pypa/setuptools/downloads/setuptools-0.7.4.tar.gz#c0b8864b63c13312f5d9568c2a54247e" python