mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-11 21:13:52 -05:00
add pyenv-virtualenv-prefix
This commit is contained in:
19
bin/pyenv-virtualenv-prefix
Executable file
19
bin/pyenv-virtualenv-prefix
Executable 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user