hassio-addons / addon-appdaemon

AppDaemon4 - Home Assistant Community Add-ons
https://addons.community
MIT License
149 stars 46 forks source link

Add auto-install system and pip packages #272

Closed AlexMKX closed 1 year ago

AlexMKX commented 1 year ago

Proposed Changes

Porting the original functionality from the AppDaemon's docker image.

This change will consists of the following functionalities:

  1. Auto-installing the system packages from the system_packages.txt, provided by the app.
  2. Auto-installing the python packages from requirements.txt, provided by the app. The above functionality will make app installation more straight-forward and unattended (no need to modify config, just checkout or copy files)
  3. Creating the cache for ystem packages and pip packages in /share/appdaemon so AppDaemon addon will start faster and can start without internet connection.
AlexMKX commented 1 year ago

There seem to be a bunch of unrelated changes in this PR.

../Frenck

Hello @frenck Thank you for reviewing the PR. Actually, I've tried to cope with UTF-8 BOM with those commits. Should've I squash them?

Though it seems github added package.json and config.yaml (not sure why, I've explicitly reverted them). The only changes are :

mkdir -p /share/appdaemon/apk.cache
ln -s /share/appdaemon/apk.cache /etc/apk/cache
find /config/appdaemon -name system_packages.txt -type f -not -empty -exec cat {} \; -exec echo -n " " \; | tr -d '\xEF\xBB\xBF' | sed ':a;N;$!ba;s/\n/ /g' | xargs -n 1 -r -t apk add
mkdir -p /share/appdaemon/pip.cache
find /config/appdaemon -name requirements.txt -type f -not -empty -exec pip3 --cache-dir /share/appdaemon/pip.cache install --upgrade -r {} \;

It replicates this functionality : https://appdaemon.readthedocs.io/en/latest/DOCKER_TUTORIAL.html#runtime-dependencies

The short background : I created bunch of AD plugins and going to create more. Some of them needs specific packages. Although they can be added through the HASS Plugin settings, this is not true CI/CD and pythonic way because it involves lot of manual operations and unable to automate through terraform or another automation systems like ansible, chief and so forth.

By using above functionality, there is no need to click through the settings during the install at all. The only step is to copy the AD plugin and that's all.

Best, Alex.

frenck commented 1 year ago

By using above functionality, there is no need to click through the settings during the install at all. The only step is to copy the AD plugin and that's all.

I guess this means you didn't read my previous answer.

Nevertheless, thanks for being willing to contribute.

../Frenck