check-host-python3.sh 756 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/sh
  2. # prevent shift error
  3. [ $# -lt 2 ] && exit 1
  4. version_min="$(echo ${1} | awk '{ split($1, v, "."); print v[1] v[2] }')"
  5. shift
  6. # The host python interpreter is already checked by dependencies.sh but
  7. # it only check if the version is at least 2.7.
  8. # We want to check the version number of the python3 interpreter even
  9. # if Buildroot is able to use any version but some packages may require
  10. # a more recent version.
  11. for candidate in "${@}" ; do
  12. python3=`which $candidate 2>/dev/null`
  13. if [ ! -x "$python3" ]; then
  14. continue
  15. fi
  16. version=`$python3 -V 2>&1 | awk '{ split($2, v, "."); print v[1] v[2] }'`
  17. if [ $version -lt $version_min ]; then
  18. # no suitable python3 found
  19. continue
  20. fi
  21. # suitable python3 found
  22. echo $python3
  23. break
  24. done