make installation path of virtualenv.py configurable

This commit is contained in:
Yamashita Yuu
2013-05-07 21:51:12 +09:00
parent b594b99a18
commit a9903fab6e

View File

@@ -8,6 +8,7 @@
# #
PYENV_VIRTUALENV_VERSION="20130507" PYENV_VIRTUALENV_VERSION="20130507"
VIRTUALENV_VERSION="${VIRTUALENV_VERSION:-1.9.1}"
set -e set -e
[ -n "$PYENV_DEBUG" ] && set -x [ -n "$PYENV_DEBUG" ] && set -x
@@ -63,9 +64,40 @@ abs_dirname() {
cd "$cwd" cd "$cwd"
} }
http() {
local method="$1"
local url="$2"
local file="$3"
[ -n "$url" ] || return 1
if type curl &>/dev/null; then
"http_${method}_curl" "$url" "$file"
elif type wget &>/dev/null; then
"http_${method}_wget" "$url" "$file"
else
echo "error: please install \`curl\` or \`wget\` and try again" >&2
exit 1
fi
}
http_head_curl() {
curl -qsILf "$1" >&4 2>&1
}
http_get_curl() {
curl -C - -o "${2:--}" -qsSLf "$1"
}
http_head_wget() {
wget -q --spider "$1" >&4 2>&1
}
http_get_wget() {
wget -nv -c -O "${2:--}" "$1"
}
version() { version() {
local VIRTUALENV_VERSION="$(pyenv-exec python "${VIRTUALENV}" --version || true)" echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (virtualenv ${VIRTUALENV_VERSION})"
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (virtualenv ${VIRTUALENV_VERSION:-unknown})"
} }
usage() { usage() {
@@ -76,7 +108,13 @@ usage() {
} }
PYENV_VIRTUALENV_ROOT="$(abs_dirname "$0")/.." PYENV_VIRTUALENV_ROOT="$(abs_dirname "$0")/.."
VIRTUALENV="${PYENV_VIRTUALENV_ROOT}/libexec/pyenv-virtualenv/virtualenv.py" if [ -z "${PYENV_VIRTUALENV_CACHE_PATH}" ]; then
PYENV_VIRTUALENV_CACHE_PATH="${PYTHON_BUILD_CACHE_PATH:-${PYENV_ROOT}/cache}"
fi
if [ -z "${PYENV_VIRTUALENV_SCRIPT_PATH}" ]; then
PYENV_VIRTUALENV_SCRIPT_PATH="${PYENV_VIRTUALENV_ROOT}/libexec/pyenv-virtualenv"
fi
VIRTUALENV="${PYENV_VIRTUALENV_SCRIPT_PATH}/virtualenv.py"
VIRTUALENV_OPTIONS=() VIRTUALENV_OPTIONS=()
parse_options "$@" parse_options "$@"
@@ -104,7 +142,7 @@ done
PYTHON_BIN=$(PYENV_VERSION="${VERSION_NAME}" pyenv-which python) PYTHON_BIN=$(PYENV_VERSION="${VERSION_NAME}" pyenv-which python)
if [ ! -x "${PYTHON_BIN}" ]; then if [ ! -x "${PYTHON_BIN}" ]; then
echo "pyenv-virtualenv: could not obtain python executable: ${PYTHON_BIN}" >&2 echo "pyenv-virtualenv: could not find python executable: ${PYTHON_BIN}" >&2
exit 1 exit 1
fi fi
@@ -130,9 +168,6 @@ VIRTUALENV_PATH="${PYENV_ROOT}/versions/${VIRTUALENV_NAME}"
# virtualenv may download distribute/setuptools in current directory. # virtualenv may download distribute/setuptools in current directory.
# change to cache directory to reuse them between invocation. # change to cache directory to reuse them between invocation.
if [ -z "${PYENV_VIRTUALENV_CACHE_PATH}" ]; then
PYENV_VIRTUALENV_CACHE_PATH="${PYTHON_BUILD_CACHE_PATH:-${PYENV_ROOT}/cache}"
fi
mkdir -p "${PYENV_VIRTUALENV_CACHE_PATH}" mkdir -p "${PYENV_VIRTUALENV_CACHE_PATH}"
{ {
cd "${PYENV_VIRTUALENV_CACHE_PATH}" cd "${PYENV_VIRTUALENV_CACHE_PATH}"