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

* fix: Add installer check for python version

Closes #7439
Closes #7437
Closes #7377

* fix error message

* Add color
This commit is contained in:
Matthias Mair 2024-06-14 00:25:58 +02:00 committed by GitHub
parent 129975adc6
commit 960c27b142
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
} }