Skip to content

Commit 6ada908

Browse files
committed
Add detection of pyenv-virtualenv environments
1 parent 746bda8 commit 6ada908

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

bin/pyenv-users

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ regex="${PYENV_ROOT}/versions/(.+)/bin/(.+)"
3737

3838
for link in "${links[@]}"; do
3939
# `$link` is the `python` symlink, and `$target` is its target.
40+
linkpath=$(realpath -s "$link")
4041
target=$(readlink -f "$link")
41-
# Ignore symlinks inside $PYENV_ROOT itself
42-
if realpath -s "$link" | grep -v -q "$PYENV_ROOT"; then
43-
[[ "$target" =~ $regex ]]
44-
version="${BASH_REMATCH[1]}"
42+
[[ "$target" =~ $regex ]]
43+
version="${BASH_REMATCH[1]}"
44+
# Only capture links outside PYENV_ROOT or inside pyenv-virtualenv venvs
45+
if grep -v -q "$PYENV_ROOT" <<< "$linkpath" || \
46+
grep -q "$PYENV_ROOT/versions/$version/envs" <<< "$linkpath"
47+
then
4548
echo "$version":"${link%/bin/python}"
4649
fi
4750
done | sort | $output

0 commit comments

Comments
 (0)