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