From 1c083845e7d5640ef895fe9c1c500e0a1f279855 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Thu, 28 Dec 2023 17:47:46 +0100 Subject: [PATCH] Automatically enable Python environment in app shells assuming it is in `$install_dir/venv` --- helpers/apps | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/helpers/apps b/helpers/apps index 7a93298c0..81a5717eb 100644 --- a/helpers/apps +++ b/helpers/apps @@ -196,6 +196,15 @@ ynh_spawn_app_shell() { set +a fi + # Activate the Python environment, if it exists + if [ -f $install_dir/venv/bin/activate ] + then + # set -/+a enables and disables new variables being automatically exported. Needed when using `source`. + set -a + source $install_dir/venv/bin/activate + set +a + fi + # cd into the WorkingDirectory set in the service, or default to the install_dir local env_dir=$(systemctl show $service.service -p "WorkingDirectory" --value) [ -z $env_dir ] && env_dir=$install_dir;