diff --git a/manifest.json b/manifest.json index 81b677d..311cbc5 100644 --- a/manifest.json +++ b/manifest.json @@ -5,7 +5,7 @@ "description": { "en": "Web based management to catalog things including state and location etc." }, - "version": "0.13.0~ynh3", + "version": "0.13.0~ynh4", "url": "https://github.com/jedie/PyInventory", "license": "GPL-3.0", "maintainer": { @@ -25,29 +25,17 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain for PyInventory", - "fr": "Choisissez un domaine pour PyInventory" - }, "example": "domain.org" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for PyInventory", - "fr": "Choisissez un chemin pour PyInventory" - }, "example": "/pyinventory", "default": "/pyinventory" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user for PyInventory", - "fr": "Choisissez l'administrateur pour PyInventory" - }, "example": "johndoe" } ] diff --git a/pyproject.toml b/pyproject.toml index 6c3efa6..57c587a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pyinventory_ynh" -version = "0.13.0~ynh3" +version = "0.13.0~ynh4" description = "Test pyinventory_ynh via local_test.py" authors = ["JensDiemer "] license = "GPL" diff --git a/scripts/_common.sh b/scripts/_common.sh index bfeba57..25ee365 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,9 +8,11 @@ domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN -is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME +# Currently not used: PyInventory has no public pages, yet! +is_public=$YNH_APP_ARG_IS_PUBLIC + #================================================= # SET CONSTANTS #================================================= @@ -27,31 +29,6 @@ log_file="${log_path}/pyinventory.log" # dependencies used by the app pkg_dependencies="build-essential python3-dev python3-pip python3-venv git libpq-dev postgresql postgresql-contrib libjpeg-dev" -#================================================= -# PyInventory shared functions -#================================================= - -setup_venv() { - ynh_script_progression --message="Setup Python virtualenv..." --weight=15 - - # Always recreate everything fresh with current python version - ynh_secure_remove "${final_path}/venv" - - python3 -m venv --without-pip "${final_path}/venv" - - cp ../conf/requirements.txt "$final_path/requirements.txt" - chown -R "$app:" "$final_path" - ( - # Activate venv in 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 - ynh_exec_as $app $final_path/venv/bin/pip3 install --no-deps -r "$final_path/requirements.txt" - ) -} - #================================================= # Redis HELPERS #================================================= diff --git a/scripts/change_url b/scripts/change_url index 872af64..56e02c2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -25,7 +25,6 @@ new_path=$YNH_APP_NEW_PATH ynh_script_progression --message="Loading installation settings..." admin=$(ynh_app_setting_get --app="$app" --key=admin) -is_public=$(ynh_app_setting_get --app="$app" --key=is_public) public_path=$(ynh_app_setting_get --app="$app" --key=public_path) final_path=$(ynh_app_setting_get --app="$app" --key=final_path) log_path=$(ynh_app_setting_get --app="$app" --key=log_path) @@ -38,7 +37,7 @@ redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=15 +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=40 # Backup the current version of the app ynh_backup_before_upgrade diff --git a/scripts/install b/scripts/install index ac5e51d..5e91b78 100755 --- a/scripts/install +++ b/scripts/install @@ -40,7 +40,6 @@ touch "${log_file}" ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app="$app" --key=admin --value="$admin" -ynh_app_setting_set --app="$app" --key=is_public --value="$is_public" ynh_app_setting_set --app="$app" --key=public_path --value="$public_path" ynh_app_setting_set --app="$app" --key=final_path --value="$final_path" ynh_app_setting_set --app="$app" --key=log_path --value="$log_file" @@ -63,7 +62,7 @@ redis_db=$(ynh_redis_get_free_db) #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=10 +ynh_script_progression --message="Installing dependencies..." --weight=20 ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" @@ -101,7 +100,26 @@ ynh_system_user_create --username="$app" --home_dir="$final_path" --use_shell #================================================= # PIP INSTALLATION #================================================= -setup_venv # function defined in _common.sh +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" + +cp ../conf/requirements.txt "$final_path/requirements.txt" +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-deps -r "$final_path/requirements.txt" +) #================================================= # copy config files diff --git a/scripts/restore b/scripts/restore index 4cdd9a1..0cbf548 100755 --- a/scripts/restore +++ b/scripts/restore @@ -78,7 +78,7 @@ chown -R "$app:" "$final_path" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=10 +ynh_script_progression --message="Reinstalling dependencies..." --weight=20 ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" @@ -86,7 +86,24 @@ ynh_exec_warn_less ynh_install_app_dependencies "$pkg_dependencies" # REINSTALL PYTHON VIRTUALENV # Maybe the backup contains a other Python version #================================================= -setup_venv # function defined in _common.sh +ynh_script_progression --message="Upgrade Python virtualenv..." --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" +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-deps -r "$final_path/requirements.txt" +) #================================================= # RESTORE THE PostgreSQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index f8eedaa..a22d79e 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Loading installation settings..." admin=$(ynh_app_setting_get --app="$app" --key=admin) -is_public=$(ynh_app_setting_get --app="$app" --key=is_public) public_path=$(ynh_app_setting_get --app="$app" --key=public_path) final_path=$(ynh_app_setting_get --app="$app" --key=final_path) log_path=$(ynh_app_setting_get --app="$app" --key=log_path) @@ -29,7 +28,7 @@ redis_db=$(ynh_app_setting_get --app="$app" --key=redis_db) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=15 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=40 # Backup the current version of the app ynh_backup_before_upgrade @@ -63,7 +62,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,7 +84,26 @@ ynh_add_systemd_config --service="$app" --template="pyinventory.service" #================================================= # UPGRADE VENV #================================================= -setup_venv # function defined in _common.sh +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" + +cp ../conf/requirements.txt "$final_path/requirements.txt" +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-deps -r "$final_path/requirements.txt" +) #================================================= # copy config files