From 67fc864252ad88f1f87d6c31cd3dc17bf16e58c0 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Fri, 28 Sep 2012 20:11:06 +0900 Subject: [PATCH] python 2.6 and older don't have "bin/python" as symlink. so we must traverse files like "bin/python*" to obtain canonical name.. --- bin/python-virtualenv | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/python-virtualenv b/bin/python-virtualenv index 026f3bd..1f3438b 100755 --- a/bin/python-virtualenv +++ b/bin/python-virtualenv @@ -115,10 +115,22 @@ fi BOOTSTRAP_PYTHON_BIN="${PYTHON_PREFIX}/bin/python" PYTHON_BIN="${VIRTUALENV_PATH}/bin/python" -# obtain actual name of python executable -while test -L "${BOOTSTRAP_PYTHON_BIN}"; do - BOOTSTRAP_PYTHON_BIN="$(dirname "${BOOTSTRAP_PYTHON_BIN}")/$(resolve_link "${BOOTSTRAP_PYTHON_BIN}")" -done +# find canonical name of python executable. +# virtualenv will create "bin/python" executable as same name as its bootstraped python. +if test -L "${BOOTSTRAP_PYTHON_BIN}"; then + while test -L "${BOOTSTRAP_PYTHON_BIN}"; do # retrieve symlinks + BOOTSTRAP_PYTHON_BIN="$(dirname "${BOOTSTRAP_PYTHON_BIN}")/$(resolve_link "${BOOTSTRAP_PYTHON_BIN}")" + done +else +# python 2.6 and older don't have "bin/python" as symlink. +# so we must traverse files like "bin/python*" to obtain canonical name. + for python in ${PYTHON_PREFIX}/bin/python*; do + if ( basename "$python" | grep '^python[0-9][0-9]*\.[0-9][0-9]*$' && cmp "$BOOTSTRAP_PYTHON_BIN" "$python" ) >/dev/null; then + BOOTSTRAP_PYTHON_BIN="${python}" + break + fi + done +fi # create virtualenv "${BOOTSTRAP_PYTHON_BIN}" "${PYTHON_VIRTUALENV_ROOT}/libexec/virtualenv.py" "${VIRTUALENV_OPTIONS[@]}" "${VIRTUALENV_PATH}"