From 00988e49720fe9d6bd8bbde8583bb58bb2f7817b Mon Sep 17 00:00:00 2001 From: Eugene Brodsky Date: Thu, 27 Jul 2023 13:27:58 -0400 Subject: [PATCH] (installer) check that the found Python executable is actually operational when multiple python versions are installed with `pyenv`, the executable (shim) exists, but returns an error when trying to run it unless activated with `pyenv`. This commit ensures the python executable is usable. --- installer/install.sh.in | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/installer/install.sh.in b/installer/install.sh.in index 6757447416..1b8ba92ea6 100755 --- a/installer/install.sh.in +++ b/installer/install.sh.in @@ -13,12 +13,16 @@ MAXIMUM_PYTHON_VERSION=3.11.100 PYTHON="" for candidate in python3.11 python3.10 python3.9 python3 python ; do if ppath=`which $candidate`; then + # when using `pyenv`, the executable for an inactive Python version will exist but will not be operational + # we check that this found executable can actually run + if [ $($candidate --version &>/dev/null; echo ${PIPESTATUS}) -gt 0 ]; then continue; fi + python_version=$($ppath -V | awk '{ print $2 }') if [ $(version $python_version) -ge $(version "$MINIMUM_PYTHON_VERSION") ]; then - if [ $(version $python_version) -le $(version "$MAXIMUM_PYTHON_VERSION") ]; then - PYTHON=$ppath - break - fi + if [ $(version $python_version) -le $(version "$MAXIMUM_PYTHON_VERSION") ]; then + PYTHON=$ppath + break + fi fi fi done