Skip to content

Commit b71ddca

Browse files
committed
Find the highest Python version with installed virtualenvwrapper
1 parent aa2ac7f commit b71ddca

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

virtualenvwrapper.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,21 @@
4545
#
4646

4747
# Locate the global Python where virtualenvwrapper is installed.
48+
# Use the highest Python version
4849
if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ]
4950
then
50-
VIRTUALENVWRAPPER_PYTHON="$(command \which python)"
51+
for NAME in python3 python2 python
52+
do
53+
PYTHON="$(command \which $NAME 2>&1)"
54+
if ! [ -z $PYTHON ]
55+
then
56+
if $PYTHON -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1
57+
then
58+
VIRTUALENVWRAPPER_PYTHON=$PYTHON
59+
break
60+
fi
61+
fi
62+
done
5163
fi
5264

5365
# Set the name of the virtualenv app to use.

0 commit comments

Comments
 (0)