Always recreate fresh venv

This commit is contained in:
JensDiemer 2022-04-15 16:38:10 +02:00
parent 848f45d16a
commit 67f4d47ea3
3 changed files with 36 additions and 15 deletions

View file

@ -63,7 +63,7 @@ redis_db=$(ynh_redis_get_free_db)
#================================================= #=================================================
# INSTALL DEPENDENCIES # 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" 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 # 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" cp ../conf/requirements.txt "$final_path/requirements.txt"
chown -R "$app:" "$final_path" chown -R "$app:" "$final_path"
@ -112,13 +117,15 @@ chown -R "$app:" "$final_path"
set +o nounset set +o nounset
source "${final_path}/venv/bin/activate" source "${final_path}/venv/bin/activate"
set -o nounset set -o nounset
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade wheel pip
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
# for installing packages like "matplotlib" # for installing packages like "matplotlib"
# See: https://github.com/YunoHost-Apps/django-for-runners_ynh/issues/15 # See: https://github.com/YunoHost-Apps/django-for-runners_ynh/issues/15
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade --prefer-binary Cython ynh_exec_as $app $final_path/venv/bin/pip install --upgrade --prefer-binary Cython
ynh_exec_as $app $final_path/venv/bin/pip install --no-deps --prefer-binary -r "$final_path/requirements.txt" 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 # 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" ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
@ -86,22 +86,29 @@ ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
# REINSTALL PYTHON VIRTUALENV # REINSTALL PYTHON VIRTUALENV
# Maybe the backup contains a other Python version # 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 "${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' #run source in a 'sub shell'
( (
set +o nounset set +o nounset
source "${final_path}/venv/bin/activate" source "${final_path}/venv/bin/activate"
set -o nounset set -o nounset
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade wheel pip
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
# for installing packages like "matplotlib" # for installing packages like "matplotlib"
# See: https://github.com/YunoHost-Apps/django-for-runners_ynh/issues/15 # See: https://github.com/YunoHost-Apps/django-for-runners_ynh/issues/15
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade --prefer-binary Cython ynh_exec_as $app $final_path/venv/bin/pip install --upgrade --prefer-binary Cython
ynh_exec_as $app $final_path/venv/bin/pip install --no-deps --prefer-binary -r "$final_path/requirements.txt" 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 # 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" ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies"
@ -85,9 +85,14 @@ ynh_add_systemd_config --service="$app" --template="django-for-runners.service"
#================================================= #=================================================
# UPGRADE VENV # 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" cp ../conf/requirements.txt "$final_path/requirements.txt"
chown -R "$app:" "$final_path" chown -R "$app:" "$final_path"
@ -96,13 +101,15 @@ chown -R "$app:" "$final_path"
set +o nounset set +o nounset
source "${final_path}/venv/bin/activate" source "${final_path}/venv/bin/activate"
set -o nounset set -o nounset
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade wheel pip
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
# for installing packages like "matplotlib" # for installing packages like "matplotlib"
# See: https://github.com/YunoHost-Apps/django-for-runners_ynh/issues/15 # See: https://github.com/YunoHost-Apps/django-for-runners_ynh/issues/15
ynh_exec_as $app $final_path/venv/bin/pip install --upgrade --prefer-binary Cython ynh_exec_as $app $final_path/venv/bin/pip install --upgrade --prefer-binary Cython
ynh_exec_as $app $final_path/venv/bin/pip install --no-deps --prefer-binary -r "$final_path/requirements.txt" ynh_exec_as $app $final_path/venv/bin/pip3 install --no-deps -r "$final_path/requirements.txt"
) )
#================================================= #=================================================