From 059dad747d63e1832b2f69226a031cc0b1534afb Mon Sep 17 00:00:00 2001 From: Dave Page Date: Mon, 8 Mar 2021 11:17:55 +0000 Subject: [PATCH] Ensure our venv uses the correct python interpreter, even if the user has set a different version using update-alternatives or similar. Partially fixes #6279 --- pkg/linux/build-functions.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/linux/build-functions.sh b/pkg/linux/build-functions.sh index 4715fd445..dc4ad2084 100644 --- a/pkg/linux/build-functions.sh +++ b/pkg/linux/build-functions.sh @@ -211,5 +211,13 @@ _copy_code() { # Web setup script mkdir -p "${WEBROOT}/usr/${APP_NAME}/bin/" cp "${SOURCEDIR}/pkg/linux/setup-web.sh" "${WEBROOT}/usr/${APP_NAME}/bin/" + + # Ensure our venv will use the correct Python interpretor, even if the + # user has configured an alternative default. + # DO THIS LAST! + cd "${SERVERROOT}/usr/${APP_NAME}/venv/bin" + PYTHON_INTERPRETER=$(/usr/bin/python3 -c "import os, sys; print(os.path.realpath(sys.executable))") + rm python && ln -s python3 python + rm python3 && ln -s "${PYTHON_INTERPRETER}" python3 }