1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pyinventory_ynh.git synced 2024-09-03 20:16:09 +02:00

Bugfix venv creation

Implement the idea of https://github.com/YunoHost-Apps/pyinventory_ynh/pull/90 but without to merge
the code into `_common.sh` because `cp ../conf/requirements.txt "$final_path/requirements.txt"` is
not working in restore :(
This commit is contained in:
JensDiemer 2022-01-18 09:02:51 +01:00
parent 8917f21f8a
commit c9bfad290a
3 changed files with 33 additions and 15 deletions

View file

@ -63,7 +63,7 @@ redis_db=$(ynh_redis_get_free_db)
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=40
ynh_script_progression --message="Installing dependencies..." --weight=20
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
@ -101,9 +101,14 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell
#=================================================
# PIP INSTALLATION
#=================================================
ynh_script_progression --message="Install project via pip..." --weight=80
ynh_script_progression --message="Install project via pip..." --weight=50
# Always recreate everything fresh with current python version
ynh_secure_remove "${final_path}/venv"
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
python3 -m venv --without-pip "${final_path}/venv"
python3 -m venv "${final_path}/venv"
cp ../conf/requirements.txt "$final_path/requirements.txt"
chown -R "$app:" "$final_path"
@ -112,8 +117,9 @@ chown -R "$app:" "$final_path"
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade wheel pip
ynh_exec_as $app $final_path/venv/bin/pip install --no-deps -r "$final_path/requirements.txt"
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-deps -r "$final_path/requirements.txt"
)
#=================================================

View file

@ -78,7 +78,7 @@ chown -R "$app:" "$final_path"
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=40
ynh_script_progression --message="Reinstalling dependencies..." --weight=20
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
@ -86,17 +86,23 @@ ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
# REINSTALL PYTHON VIRTUALENV
# Maybe the backup contains a other Python version
#=================================================
ynh_script_progression --message="Upgrade Python virtualenv..." --weight=10
ynh_script_progression --message="Upgrade Python virtualenv..." --weight=50
python3 -m venv --upgrade "${final_path}/venv"
# Always recreate everything fresh with current python version
ynh_secure_remove "${final_path}/venv"
# 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/pip install --upgrade wheel pip
ynh_exec_as $app $final_path/venv/bin/pip install --no-deps -r "$final_path/requirements.txt"
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-deps -r "$final_path/requirements.txt"
)
#=================================================

View file

@ -63,7 +63,7 @@ ynh_add_nginx_config "public_path" "port"
#=================================================
# Update dependencies
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_script_progression --message="Upgrading dependencies..." --weight=20
ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
@ -85,9 +85,14 @@ ynh_add_systemd_config --service="$app" --template="pyinventory.service"
#=================================================
# UPGRADE VENV
#=================================================
ynh_script_progression --message="Upgrade project via pip..." --weight=80
ynh_script_progression --message="Upgrade project via pip..." --weight=50
# Always recreate everything fresh with current python version
ynh_secure_remove "${final_path}/venv"
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
python3 -m venv --without-pip "${final_path}/venv"
python3 -m venv --upgrade "${final_path}/venv"
cp ../conf/requirements.txt "$final_path/requirements.txt"
chown -R "$app:" "$final_path"
@ -96,8 +101,9 @@ chown -R "$app:" "$final_path"
set +o nounset
source "${final_path}/venv/bin/activate"
set -o nounset
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade wheel pip
ynh_exec_as $app $final_path/venv/bin/pip install --no-deps -r "$final_path/requirements.txt"
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-deps -r "$final_path/requirements.txt"
)
#=================================================