From 558200285bf56367f28742a6d8a1e8c4a2a59db4 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Thu, 16 Jan 2014 14:21:30 +0900 Subject: [PATCH] Use ensurepip to install pip if available --- plugins/python-build/bin/python-build | 65 ++++++++++--------- .../python-build/share/python-build/3.4-dev | 4 +- .../python-build/share/python-build/3.4.0b1 | 4 +- .../python-build/share/python-build/3.4.0b2 | 4 +- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index b0324144..ee4de1fa 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1051,16 +1051,11 @@ apply_python_patch() { } build_package_verify_python() { - # Create `python` executable if missing. Especially for Py3k. - [ -e "${PYTHON_BIN}" ] || { - local python - for python in "${PREFIX_PATH}/bin/python"*; do - if expr "$(basename "$python")" : '^python[0-9][0-9]*\.[0-9][0-9]*$' 2>&1 >/dev/null; then - ( cd "${PREFIX_PATH}/bin" && ln -fs "$(basename "$python")" python ) - break - fi - done - } + local package_name="$1" + local python="$2" + if [ ! -e "${PREFIX_PATH}/bin/python" ] && [ -e "${PREFIX_PATH}/bin/${python}" ]; then + ( cd "${PREFIX_PATH}/bin" && ln -fs "${python}" "python" ) + fi if [ ! -x "${PYTHON_BIN}" ]; then echo "pyenv: invalid Python executable: ${PYTHON_BIN}" >&4 2>&1 return 1 @@ -1069,57 +1064,69 @@ build_package_verify_python() { # Post-install check for Python 2.4.x build_package_verify_py24() { - build_package_verify_python "$@" - build_package_verify_readline "$@" - build_package_verify_zlib "$@" - build_package_verify_bz2 "$@" + build_package_verify_python "$1" "${2:-python2.4}" + build_package_verify_readline "$1" "${2:-python2.4}" + build_package_verify_zlib "$1" "${2:-python2.4}" + build_package_verify_bz2 "$1" "${2:-python2.4}" } # Post-install check for Python 2.5.x build_package_verify_py25() { - build_package_verify_py24 "$@" - build_package_verify_sqlite3 "$@" + build_package_verify_py24 "$1" "${2:-python2.5}" + build_package_verify_sqlite3 "$1" "${2:-python2.5}" } # Post-install check for Python 2.6.x build_package_verify_py26() { - build_package_verify_py25 "$@" - build_package_verify_ssl "$@" + build_package_verify_py25 "$1" "${2:-python2.6}" + build_package_verify_ssl "$1" "${2:-python2.6}" } # Post-install check for Python 2.7.x build_package_verify_py27() { - build_package_verify_py26 "$@" + build_package_verify_py26 "$1" "${2:-python2.7}" } # Post-install check for Python 3.0.x build_package_verify_py30() { - build_package_verify_python "$@" - build_package_verify_readline "$@" - build_package_verify_ssl "$@" - build_package_verify_sqlite3 "$@" - build_package_verify_zlib "$@" - build_package_verify_bz2 "$@" + build_package_verify_python "$1" "${2:-python3.0}" + build_package_verify_readline "$1" "${2:-python3.0}" + build_package_verify_ssl "$1" "${2:-python3.0}" + build_package_verify_sqlite3 "$1" "${2:-python3.0}" + build_package_verify_zlib "$1" "${2:-python3.0}" + build_package_verify_bz2 "$1" "${2:-python3.0}" } # Post-install check for Python 3.1.x build_package_verify_py31() { - build_package_verify_py30 "$@" + build_package_verify_py30 "$1" "${2:-python3.1}" } # Post-install check for Python 3.2.x build_package_verify_py32() { - build_package_verify_py31 "$@" + build_package_verify_py31 "$1" "${2:-python3.2}" } # Post-install check for Python 3.3.x build_package_verify_py33() { - build_package_verify_py32 "$@" + build_package_verify_py32 "$1" "${2:-python3.3}" } # Post-install check for Python 3.4.x build_package_verify_py34() { - build_package_verify_py33 "$@" + build_package_verify_py33 "$1" "${2:-python3.4}" +} + +build_package_ensurepip() { + { "$PYTHON_BIN" -m ensurepip + } >&4 2>&1 + + if [ ! -e "${PREFIX_PATH}/bin/pip" ]; then + local pip="$("$PYTHON_BIN" -c 'import sys;v=sys.version_info;sys.stdout.write("pip%d.%d"%(v[0],v[1]))')" + if [ -e "${PREFIX_PATH}/bin/${pip}" ]; then + ( cd "${PREFIX_PATH}/bin" && ln -fs "${pip}" "pip" ) + fi + fi } build_package_verify_import() { diff --git a/plugins/python-build/share/python-build/3.4-dev b/plugins/python-build/share/python-build/3.4-dev index c3f9868e..c8c0f6c8 100644 --- a/plugins/python-build/share/python-build/3.4-dev +++ b/plugins/python-build/share/python-build/3.4-dev @@ -1,5 +1,3 @@ require_cc "gcc" "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-2.1" "https://pypi.python.org/packages/source/s/setuptools/setuptools-2.1.tar.gz#2044725530450d0517393882dc4b7508" python -install_package "pip-1.5" "https://pypi.python.org/packages/source/p/pip/pip-1.5.tar.gz#6969b8a8adc4c7f7c5eb1707118f0686" python +install_hg "Python-3.4-dev" "https://bitbucket.org/mirror/cpython" "default" standard verify_py34 ensurepip diff --git a/plugins/python-build/share/python-build/3.4.0b1 b/plugins/python-build/share/python-build/3.4.0b1 index ab3fa15f..ef29803b 100644 --- a/plugins/python-build/share/python-build/3.4.0b1 +++ b/plugins/python-build/share/python-build/3.4.0b1 @@ -1,5 +1,3 @@ require_cc "gcc" "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.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 -install_package "pip-1.5" "https://pypi.python.org/packages/source/p/pip/pip-1.5.tar.gz#6969b8a8adc4c7f7c5eb1707118f0686" python +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 ensurepip diff --git a/plugins/python-build/share/python-build/3.4.0b2 b/plugins/python-build/share/python-build/3.4.0b2 index 3b493695..3ee50390 100644 --- a/plugins/python-build/share/python-build/3.4.0b2 +++ b/plugins/python-build/share/python-build/3.4.0b2 @@ -1,5 +1,3 @@ require_cc "gcc" "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.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 -install_package "pip-1.5" "https://pypi.python.org/packages/source/p/pip/pip-1.5.tar.gz#6969b8a8adc4c7f7c5eb1707118f0686" python +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 ensurepip