detect_python.fish 699 B

12345678910111213141516171819202122232425
  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 -x ESP_PYTHON python
  5. for p_cmd in python python3;
  6. echo "Checking \"$p_cmd\" ..."
  7. set res ($p_cmd -c "import sys; print(sys.version_info.major)")
  8. if [ "$res" = "3" ]
  9. set -x ESP_PYTHON $p_cmd
  10. break
  11. end
  12. end
  13. $ESP_PYTHON --version
  14. if [ $status -ne 0 ]
  15. echo "\"$ESP_PYTHON\" is not installed! Please see the documentation for how to install it."
  16. # The following exit skips the rest of this file but won't exit fish where the script was sourced. This is not a
  17. # fatal issue.
  18. exit 1
  19. end
  20. echo "\"$ESP_PYTHON\" has been detected"