Display the version of pyvenv if USE_PYVENV is set

This commit is contained in:
Yamashita Yuu
2014-01-23 14:51:56 +09:00
parent 39ce4e76fd
commit 4feb64e8d3
3 changed files with 63 additions and 14 deletions

View File

@@ -103,8 +103,17 @@ http_get_wget() {
}
version() {
local version="$(venv --version 2>/dev/null || true)"
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (virtualenv ${version:-unknown})"
detect_venv
local version
if [ -n "$USE_PYVENV" ]; then
version="$(pyenv-which pyvenv 2>/dev/null || true)"
version="${version#$(pyenv-root)/versions/}"
version="${version%/bin/pyvenv}"
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (pyvenv ${version:-unknown})"
else
version="$(venv --version 2>/dev/null || true)"
echo "pyenv-virtualenv ${PYENV_VIRTUALENV_VERSION} (virtualenv ${version:-unknown})"
fi
}
usage() {
@@ -114,6 +123,19 @@ usage() {
[ -z "$1" ] || exit "$1"
}
detect_venv() {
if pyenv-which "virtualenv" 1>/dev/null 2>&1; then
HAS_VIRTUALENV=1
fi
if pyenv-which "pyvenv" 1>/dev/null 2>&1; then
HAS_PYVENV=1
fi
# Use pyvenv only if virtualenv is not installed and there is pyvenv
if [ -n "${HAS_PYVENV}" ] && [ -z "${HAS_VIRTUALENV}" ]; then
USE_PYVENV=1
fi
}
venv() {
local args=("$@")
if [ -n "${USE_PYVENV}" ]; then
@@ -305,17 +327,7 @@ VIRTUALENV_PATH="${PYENV_ROOT}/versions/${VIRTUALENV_NAME}"
unset HAS_VIRTUALENV
unset HAS_PYVENV
unset USE_PYVENV
if pyenv-which "virtualenv" 1>/dev/null 2>&1; then
HAS_VIRTUALENV=1
fi
if pyenv-which "pyvenv" 1>/dev/null 2>&1; then
HAS_PYVENV=1
fi
# Use pyvenv only if virtualenv is not installed and there is pyvenv
if [ -n "${HAS_PYVENV}" ] && [ -z "${HAS_VIRTUALENV}" ]; then
USE_PYVENV=1
fi
detect_venv
if [ -n "${USE_PYVENV}" ]; then
# Unset some arguments not supported by pyvenv