From 6c283e63d131262679ecc1f7f9a8b0241b69d4ee Mon Sep 17 00:00:00 2001 From: ewilly Date: Wed, 15 Mar 2023 21:31:06 +0100 Subject: [PATCH] Improve updater --- .github/workflows/updater.sh | 9 +++++++++ scripts/_common.sh | 9 ++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh index aad90d1..a758d3f 100644 --- a/.github/workflows/updater.sh +++ b/.github/workflows/updater.sh @@ -47,6 +47,15 @@ fi # Replace new version in _common.sh sed -i "s/^app_version=.*/app_version=$upstream_version/" scripts/_common.sh +# Replace python required version +py_required_major=$(curl -Ls https://pypi.org/pypi/$app/json | jq -r .info.requires_python | cut -d '=' -f 2 | rev | cut -d"." -f2- | rev) +py_required_minor=$(curl -s "https://www.python.org/ftp/python/" | grep ">$py_required_major" | cut -d '/' -f 2 | cut -d '>' -f 2 | sort -rV | head -n 1) +sed -i "s/^py_required_version=.*/py_required_version=$py_required_minor/" scripts/_common.sh + +# Replace pip required version +pip_required=$(curl -Ls https://pypi.org/pypi/$app/json | jq -r .info.requires_dist[] | grep "pip") #"pip (<23.1,>=21.0)" +sed -i "s/^pip_required=.*/pip_required=$pip_required/" scripts/_common.sh + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/_common.sh b/scripts/_common.sh index 26bee10..85f1688 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,10 +7,9 @@ # Release to install app_version=2023.3.1 -# Requirements (Major.Minor.Patch) -# PY_VERSION=$(curl -s "https://www.python.org/ftp/python/" | grep ">3.9" | tail -n1 | cut -d '/' -f 2 | cut -d '>' -f 2) -# Pyhton 3.9.2 will be shiped with bullseye +# Requirements py_required_version=3.10.9 +pip_required="" #================================================= # PERSONAL HELPERS @@ -125,7 +124,7 @@ myynh_install_homeassistant () { ynh_exec_as $app "$install_dir/bin/python3" -m ensurepip # install last version of pip - ynh_exec_as $app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade pip + ynh_exec_as $app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade "$pip_required" # install last version of wheel ynh_exec_as $app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade wheel @@ -137,7 +136,7 @@ myynh_install_homeassistant () { ynh_exec_as $app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade mysqlclient # install Home Assistant - ynh_exec_as $app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade $app==$app_version + ynh_exec_as $app "$install_dir/bin/pip3" --cache-dir "$data_dir/.cache" install --upgrade "$app==$app_version" ) }