Skip to content

Commit

Permalink
detect python version for installer
Browse files Browse the repository at this point in the history
  • Loading branch information
matmair committed Jul 2, 2024
1 parent f671475 commit 5c96cd6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions contrib/packager.io/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
Color_Off='\033[0m'
On_Red='\033[41m'
PYTHON_FROM=9
PYTHON_TO=12

function detect_docker() {
if [ -n "$(grep docker </proc/1/cgroup)" ]; then
Expand Down Expand Up @@ -57,6 +59,19 @@ function detect_python() {
echo "# No python environment found - using environment variable: ${SETUP_PYTHON}"
fi

# Try to detect a python between 3.9 and 3.12 in reverse order
if [ -z "${SETUP_PYTHON}" ]; then
echo "# Trying to detecting python3.${PYTHON_FROM} to python3.${PYTHON_TO} - using newest version"
for i in $(seq $PYTHON_TO -1 $PYTHON_FROM); do
echo "# Checking for python3.${i}"
if [ -n "$(which python3.${i})" ]; then
SETUP_PYTHON="python3.${i}"
echo "# Found python3.${i} installed - using for setup ${SETUP_PYTHON}"
break
fi
done
fi

# Ensure python can be executed - abort if not
if [ -z "$(which ${SETUP_PYTHON})" ]; then
echo "${On_Red}"
Expand Down

0 comments on commit 5c96cd6

Please sign in to comment.