From 07ae0d8e4256b66faa2400f3f92f8bb5760b934f Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Fri, 10 Jan 2014 20:05:01 +0900 Subject: [PATCH] Import changes from ruby-build 20140110.1 --- plugins/python-build/bin/pyenv-install | 12 ++++++------ plugins/python-build/bin/pyenv-uninstall | 24 +++++++++++++++++++++++- plugins/python-build/bin/python-build | 22 +++++++--------------- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/plugins/python-build/bin/pyenv-install b/plugins/python-build/bin/pyenv-install index f862d4cf..febd3213 100755 --- a/plugins/python-build/bin/pyenv-install +++ b/plugins/python-build/bin/pyenv-install @@ -99,7 +99,7 @@ unset VERSION_NAME # version is specified by pyenv. Show usage instructions if a local # version is not specified. DEFINITION="${ARGUMENTS[0]}" -[ -n "$DEFINITION" ] || DEFINITION="$(pyenv local 2>/dev/null || true)" +[ -n "$DEFINITION" ] || DEFINITION="$(pyenv-local 2>/dev/null || true)" [ -n "$DEFINITION" ] || usage 1 @@ -118,10 +118,10 @@ after_install() { after_hooks["${#after_hooks[@]}"]="$hook" } -# Load plugin hooks. -for script in $(pyenv-hooks install); do - source "$script" -done +OLDIFS="$IFS" +IFS=$'\n' scripts=(`pyenv-hooks install`) +IFS="$OLDIFS" +for script in "${scripts[@]}"; do source "$script"; done # Set VERSION_NAME from $DEFINITION, if it is not already set. Then @@ -201,7 +201,7 @@ for hook in "${after_hooks[@]}"; do eval "$hook"; done # Run `pyenv-rehash` after a successful installation. if [ "$STATUS" == "0" ]; then - pyenv rehash + pyenv-rehash else cleanup fi diff --git a/plugins/python-build/bin/pyenv-uninstall b/plugins/python-build/bin/pyenv-uninstall index fdf4061c..8336b454 100755 --- a/plugins/python-build/bin/pyenv-uninstall +++ b/plugins/python-build/bin/pyenv-uninstall @@ -38,6 +38,24 @@ case "$DEFINITION" in ;; esac +declare -a before_hooks after_hooks + +before_uninstall() { + local hook="$1" + before_hooks["${#before_hooks[@]}"]="$hook" +} + +after_uninstall() { + local hook="$1" + after_hooks["${#after_hooks[@]}"]="$hook" +} + +OLDIFS="$IFS" +IFS=$'\n' scripts=(`pyenv-hooks uninstall`) +IFS="$OLDIFS" +for script in "${scripts[@]}"; do source "$script"; done + + VERSION_NAME="${DEFINITION##*/}" PREFIX="${PYENV_ROOT}/versions/${VERSION_NAME}" @@ -54,7 +72,11 @@ if [ -z "$FORCE" ]; then esac fi +for hook in "${before_hooks[@]}"; do eval "$hook"; done + if [ -d "$PREFIX" ]; then rm -rf "$PREFIX" - pyenv rehash + pyenv-rehash fi + +for hook in "${after_hooks[@]}"; do eval "$hook"; done diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index a54ca581..f57e2dc4 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1,6 +1,6 @@ #!/usr/bin/env bash -PYTHON_BUILD_VERSION="20131225.1" +PYTHON_BUILD_VERSION="20140110.1" set -E exec 3<&2 # preserve original stderr at fd 3 @@ -897,7 +897,6 @@ require_java() { } needs_yaml() { - [[ "$PYTHON_CONFIGURE_OPTS" != *--with-libyaml-dir=* ]] && ! use_homebrew_yaml } @@ -1048,14 +1047,8 @@ apply_python_patch() { } build_package_verify_python() { - # Check the existence of ./bin since pyenv-which searches the executables from there - if [ ! -d "${PREFIX_PATH}/bin" ]; then - echo "pyenv: invalid Python installation" >&4 2>&1 - return 1 - fi - # Create `python` executable if missing. Especially for Py3k. - if [ ! -e "${PREFIX_PATH}/bin/python" ]; then + [ -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 @@ -1063,8 +1056,7 @@ build_package_verify_python() { break fi done - fi - + } if [ ! -x "${PYTHON_BIN}" ]; then echo "pyenv: invalid Python executable: ${PYTHON_BIN}" >&4 2>&1 return 1 @@ -1193,8 +1185,8 @@ list_definitions() { unset VERBOSE unset KEEP_BUILD_PATH unset HAS_PATCH -unset DEBUG PYTHON_BUILD_ROOT="$(abs_dirname "$0")/.." +unset DEBUG parse_options "$@" @@ -1311,9 +1303,9 @@ if [ -n "$DEBUG" ]; then package_option python configure --with-pydebug fi -if [[ "$PYTHON_CONFIGURE_OPTS" == *"--enable-shared"* ]] && [[ "$LDFLAGS" != *"-rpath="* ]]; then +if [[ "$CONFIGURE_OPTS" == *"--enable-shared"* ]] || [[ "$PYTHON_CONFIGURE_OPTS" == *"--enable-shared"* ]]; then # The ld on Darwin embeds the full paths to each dylib by default - if [[ "Darwin" != "$(uname -s)" ]]; then + if [[ "$LDFLAGS" != *"-rpath="* ]] && [[ "Darwin" != "$(uname -s)" ]]; then export LDFLAGS="-Wl,-rpath=${PREFIX_PATH}/lib ${LDFLAGS}" fi fi @@ -1323,7 +1315,7 @@ LOG_PATH="${TMP}/python-build.${SEED}.log" PYTHON_BIN="${PREFIX_PATH}/bin/python" CWD="$(pwd)" -if [ -z $PYTHON_BUILD_BUILD_PATH ]; then +if [ -z "$PYTHON_BUILD_BUILD_PATH" ]; then BUILD_PATH="${TMP}/python-build.${SEED}" else BUILD_PATH="$PYTHON_BUILD_BUILD_PATH"