lib.sh: Fix python3 detection when 'python' is python2
Properly set $pyver to "3" when we detect we can use python3. In the following version checks, use the $python we detected instead of a 'python' from PATH because the latter might be a python2 while still co-existing with a python3. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>25.04_branch
parent
8affdc0bcb
commit
d9908ca648
|
@ -99,13 +99,17 @@ done
|
||||||
|
|
||||||
pyver="2"
|
pyver="2"
|
||||||
python="python3"
|
python="python3"
|
||||||
command -v python3 1>/dev/null || python="python"
|
if command -v python3 1>/dev/null; then
|
||||||
|
pyver="3"
|
||||||
|
else
|
||||||
|
python="python"
|
||||||
|
fi
|
||||||
command -v $python 1>/dev/null || pyver=""
|
command -v $python 1>/dev/null || pyver=""
|
||||||
[ -z "$pyver" ] || \
|
[ -z "$pyver" ] || \
|
||||||
python -c 'import sys; print(sys.version_info[:])' 1>/dev/null \
|
$python -c 'import sys; print(sys.version_info[:])' 1>/dev/null \
|
||||||
2>/dev/null || $err "Cannot determine which Python version."
|
2>/dev/null || $err "Cannot determine which Python version."
|
||||||
[ -n "$pyver" ] && \
|
[ -n "$pyver" ] && \
|
||||||
pyver="`python -c 'import sys; print(sys.version_info[:])' | \
|
pyver="`$python -c 'import sys; print(sys.version_info[:])' | \
|
||||||
awk '{print $1}'`" && \
|
awk '{print $1}'`" && \
|
||||||
pyver="${pyver#(}" && pyver="${pyver%,}"
|
pyver="${pyver#(}" && pyver="${pyver%,}"
|
||||||
if [ "${pyver%%.*}" != "3" ]; then
|
if [ "${pyver%%.*}" != "3" ]; then
|
||||||
|
|
Loading…
Reference in New Issue