From e63d2c389ed276aa161bb50a27c77af94d96a50c Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sat, 21 Jan 2023 09:19:41 -0500 Subject: [PATCH] remove python2 from startup logic for finding the python interpreter Fixes #22 Sem-Ver: api-break --- virtualenvwrapper.sh | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/virtualenvwrapper.sh b/virtualenvwrapper.sh index 79def0d..b8e4a42 100644 --- a/virtualenvwrapper.sh +++ b/virtualenvwrapper.sh @@ -45,29 +45,21 @@ # # Locate the global Python where virtualenvwrapper is installed. -# Use the highest Python version if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ] then - for NAME in python3 python2 python - do - python_executable="$(which $NAME 2>/dev/null)" - if ! [ -z "$python_executable" ] - then - if $python_executable -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1 - then - VIRTUALENVWRAPPER_PYTHON=$python_executable - break - fi - fi - done - if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ] + _virtualenvwrapper_python_executable="$(which python3 2>/dev/null)" + if [ -n "$_virtualenvwrapper_python_executable" ] && $_virtualenvwrapper_python_executable -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1 then - echo -e "ERROR: Python with virtualenvwrapper module not found! -Either, install virtualenvwrapper module for standard python2 -or python3 or set VIRTUALENVWRAPPER_PYTHON variable manually." 1>&2 - return 1 + VIRTUALENVWRAPPER_PYTHON=$_virtualenvwrapper_python_executable fi fi +if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ] +then + echo -e "ERROR: Python with virtualenvwrapper module not found! +Either, install virtualenvwrapper module for the default python3 interpreter +or set VIRTUALENVWRAPPER_PYTHON to the interpreter to use." 1>&2 + return 1 +fi # Set the name of the virtualenv app to use. if [ "${VIRTUALENVWRAPPER_VIRTUALENV:-}" = "" ]