diff --git a/android-configure b/android-configure index 3c9adbb273e8f0..c316ece0a9bcac 100755 --- a/android-configure +++ b/android-configure @@ -1,12 +1,25 @@ #!/bin/sh -# Run android_configure.py with the latest installed python version (3.6+) -PYTHONS=$(ls /usr/bin | grep -E "^python3(\.[0-9]+)?$" | sort -r) +# Run (current script).py with the latest installed python version (3.6+) +# Find all python3 versions installed in /usr/bin +PYTHONS=$(ls /usr/bin/python3* 2>/dev/null | grep -E "^/usr/bin/python3(\.[0-9]+)?$" | sort -r) + +# Check if any python version is found +if [ -z "$PYTHONS" ]; then + echo "No python3 executables found in /usr/bin." + exit 1 +fi + +# Iterate through each python version for PYTHON in $PYTHONS; do - # >3.6 - if [ `$PYTHON -c "import sys; print(sys.version_info[:2] >= (3, 6))"` = "True" ]; then - $PYTHON android_configure.py $@ + # Check if the python version is >= 3.6 + if [ "$($PYTHON -c 'import sys; print(sys.version_info >= (3, 6))' 2>/dev/null)" = "True" ]; then + # Run the script with the appropriate python version + $PYTHON "$0.py" "$@" exit $? fi done + +echo "No python found with a version >= 3.6" +exit 1