From 6bad6a92e0c3dd400dfb9a70f19e8e33eb1d216c Mon Sep 17 00:00:00 2001 From: Krakinou Date: Mon, 2 Jan 2023 23:10:38 +0100 Subject: [PATCH] reinstall pip depedencies --- scripts/restore | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/restore b/scripts/restore index 5673a15..a85bb32 100755 --- a/scripts/restore +++ b/scripts/restore @@ -92,6 +92,29 @@ chmod 740 $final_path ynh_script_progression --message="Reinstalling dependencies..." --weight=15 ynh_install_app_dependencies $PKG_DEPENDENCIES +#Use venv to install pip requirements - Inspired from https://github.com/YunoHost-Apps/pyinventory_ynh/blob/master/scripts/install +ynh_script_progression --message="Reinstalling pip requirements..." --weight=70 +# Always recreate everything fresh with current python version +# When reinstalling on a new yunohost, this is required +if [ -d "${final_path}/venv" ] ; then + ynh_secure_remove "${final_path}/venv" +fi + +# Skip pip because of: https://github.com/YunoHost/issues/issues/1960 +python3 -m venv --without-pip "${final_path}/venv" +chown -R "$app:" "$final_path" + +#run source in a 'sub shell' +( + set +o nounset + source "${final_path}/venv/bin/activate" + set -o nounset + ynh_exec_as $app $final_path/venv/bin/python3 -m ensurepip + ynh_exec_as $app $final_path/venv/bin/pip3 install --upgrade wheel pip setuptools + ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/requirements.txt" + ynh_exec_as $app $final_path/venv/bin/pip3 install --no-cache-dir --upgrade -r "$final_path/optional-requirements.txt" +) + #================================================= # RESTORE SYSTEMD #=================================================