fix: Add installer check for python version (#7440) (#7441)

* fix: Add installer check for python version

Closes #7439
Closes #7437
Closes #7377

* fix error message

* Add color

(cherry picked from commit 960c27b142)

Co-authored-by: Matthias Mair <code@mjmair.com>
This commit is contained in:
github-actions[bot] 2024-06-14 08:33:55 +10:00 committed by GitHub
parent d7c76aab9d
commit f1dfced89b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,8 @@
# #
# packager.io postinstall script functions # packager.io postinstall script functions
# #
Color_Off='\033[0m'
On_Red='\033[41m'
function detect_docker() { function detect_docker() {
if [ -n "$(grep docker </proc/1/cgroup)" ]; then if [ -n "$(grep docker </proc/1/cgroup)" ]; then
@ -50,9 +52,19 @@ function detect_python() {
echo "# Python environment already present" echo "# Python environment already present"
# Extract earliest python version initialised from /opt/inventree/env/lib # Extract earliest python version initialised from /opt/inventree/env/lib
SETUP_PYTHON=$(ls -1 ${APP_HOME}/env/bin/python* | sort | head -n 1) SETUP_PYTHON=$(ls -1 ${APP_HOME}/env/bin/python* | sort | head -n 1)
echo "# Found earliest version: ${SETUP_PYTHON}" echo "# Found earlier used version: ${SETUP_PYTHON}"
else else
echo "# No python environment found - using ${SETUP_PYTHON}" echo "# No python environment found - using environment variable: ${SETUP_PYTHON}"
fi
# Ensure python can be executed - abort if not
if [ -z "$(which ${SETUP_PYTHON})" ]; then
echo "${On_Red}"
echo "# Python ${SETUP_PYTHON} not found - aborting!"
echo "# Please ensure python can be executed with the command '$SETUP_PYTHON' by the current user '$USER'."
echo "# If you are using a different python version, please set the environment variable SETUP_PYTHON to the correct command - eg. 'python3.10'."
echo "${Color_Off}"
exit 1
fi fi
} }