Automatically enable Python environment in app shells

assuming it is in `$install_dir/venv`
This commit is contained in:
tituspijean 2023-12-28 17:47:46 +01:00 committed by GitHub
parent 6c3290d8bf
commit 1c083845e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;