Skip to content

Commit e63d2c3

Browse files
committed
remove python2 from startup logic for finding the python interpreter
Fixes #22 Sem-Ver: api-break
1 parent b852662 commit e63d2c3

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

virtualenvwrapper.sh

+10-18
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,21 @@
4545
#
4646

4747
# Locate the global Python where virtualenvwrapper is installed.
48-
# Use the highest Python version
4948
if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ]
5049
then
51-
for NAME in python3 python2 python
52-
do
53-
python_executable="$(which $NAME 2>/dev/null)"
54-
if ! [ -z "$python_executable" ]
55-
then
56-
if $python_executable -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1
57-
then
58-
VIRTUALENVWRAPPER_PYTHON=$python_executable
59-
break
60-
fi
61-
fi
62-
done
63-
if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ]
50+
_virtualenvwrapper_python_executable="$(which python3 2>/dev/null)"
51+
if [ -n "$_virtualenvwrapper_python_executable" ] && $_virtualenvwrapper_python_executable -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1
6452
then
65-
echo -e "ERROR: Python with virtualenvwrapper module not found!
66-
Either, install virtualenvwrapper module for standard python2
67-
or python3 or set VIRTUALENVWRAPPER_PYTHON variable manually." 1>&2
68-
return 1
53+
VIRTUALENVWRAPPER_PYTHON=$_virtualenvwrapper_python_executable
6954
fi
7055
fi
56+
if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ]
57+
then
58+
echo -e "ERROR: Python with virtualenvwrapper module not found!
59+
Either, install virtualenvwrapper module for the default python3 interpreter
60+
or set VIRTUALENVWRAPPER_PYTHON to the interpreter to use." 1>&2
61+
return 1
62+
fi
7163

7264
# Set the name of the virtualenv app to use.
7365
if [ "${VIRTUALENVWRAPPER_VIRTUALENV:-}" = "" ]

0 commit comments

Comments
 (0)