add pyenv-virtualenv-prefix

This commit is contained in:
Yamashita Yuu
2013-06-04 18:53:31 +09:00
parent 6915cd0320
commit b7c498ce03
2 changed files with 20 additions and 8 deletions

19
bin/pyenv-virtualenv-prefix Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
#
# Summary: Display real_prefix for a Python virtualenv version
# Usage: pyenv virtualenv-prefix [<virtualenv>]
#
set -e
[ -n "$PYENV_DEBUG" ] && set -x
if [ -z "$PYENV_ROOT" ]; then
PYENV_ROOT="${HOME}/.pyenv"
fi
if [ -n "$1" ]; then
export PYENV_VERSION="$1"
fi
PYTHON_BIN="$(pyenv-which python)"
"${PYTHON_BIN}" -c 'import sys;print(sys.real_prefix)' 2>/dev/null

View File

@@ -23,7 +23,7 @@ print_version() {
if [ -n "${BARE}" ]; then
echo "${version}"
else
echo "${version} (created from $(virtualenv_origin "${version}"))"
echo "${version} (created from $(pyenv-virtualenv-prefix "${version}"))"
fi
}
@@ -33,13 +33,6 @@ virtualenv_version() {
[ -f "${prefix}/bin/activate" ] && "${prefix}/bin/python" -c 'import sys;sys.real_prefix' 1>/dev/null 2>&1
}
virtualenv_origin() {
local version="$1"
local prefix="$(pyenv-prefix "${version}")"
local origin="$("${prefix}/bin/python" -c 'import sys;print(sys.real_prefix)' 2>/dev/null || true)"
echo "${origin:-unknown}"
}
versions=($(pyenv-versions --bare))
for version in "${versions[@]}"; do