detect_python.fish 944 B

1234567891011121314151617181920212223
  1. # This file should be sourced, not executed!
  2. #
  3. # This is a port of detect_python.sh. More information are provided there.
  4. set OLDEST_PYTHON_SUPPORTED_MAJOR 3
  5. set OLDEST_PYTHON_SUPPORTED_MINOR 7
  6. for p_cmd in python3 python python3.7 python3.8 python3.9 python3.10 python3.11 python3.12;
  7. $p_cmd --version >/dev/null 2>&1; or continue
  8. echo "Checking \"$p_cmd\" ..."
  9. $p_cmd -c "import sys; exit(1) if sys.version_info.major < int(\"$OLDEST_PYTHON_SUPPORTED_MAJOR\") else exit(0);"; or continue
  10. $p_cmd -c "import sys; exit(1) if sys.version_info.minor < int(\"$OLDEST_PYTHON_SUPPORTED_MINOR\") else exit(0);"; or continue
  11. set ESP_PYTHON $p_cmd
  12. break
  13. end
  14. test -n "$ESP_PYTHON"; or echo "Python $OLDEST_PYTHON_SUPPORTED_MAJOR.$OLDEST_PYTHON_SUPPORTED_MINOR+ is not installed! Please see the documentation for how to install it."
  15. test -n "$ESP_PYTHON"; or exit 1
  16. $ESP_PYTHON --version
  17. echo "$ESP_PYTHON has been detected"