linuxserver / docker-homeassistant

GNU General Public License v3.0
208 stars 33 forks source link

[FEAT] Add Home Assistant PIP index #84

Closed roflcoopter closed 1 year ago

roflcoopter commented 1 year ago

Is this a new feature request?

Wanted change

Would it be possible to include https://wheels.home-assistant.io/musllinux/ in the PIP index search URLs?

Reason for change

I have hit a problem with the custom integration for Husqvarna Automower which has Shapely>=1.8.2 as a dependency.

The pip index URLs used in this image does not seem to have the Home Assistant index https://wheels.home-assistant.io/musllinux/ included, which causes the container to try and build Shapely from source which crashes because of missing build deps.

To band-aid fix this i created a custom init script which runs the following: pip3 install --no-cache-dir --no-index --only-binary=:all: --find-links "https://wheels.home-assistant.io/musllinux/" Shapely>=1.8.2

Is there a way to solve this in the container or do i have to rely on my custom script?

Proposed code change

No response

github-actions[bot] commented 1 year ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

aptalca commented 1 year ago

Home Assistant's wheels are not fully compatible with our image. They do a bunch of processing including renaming the wheels. I tried to look into what else they do but their workflows are a deep rabbit hole I was not interested in investing enough time to figure out. We build our own wheels hosted at https://wheel-index.linuxserver.io/

If there is an issue, we can try to fix on our end.

One thing that surprises me is that the dep for a custom integration is in the HA wheel repo. They generally don't host those.

Anyhow, I went ahead and pushed the wheel for the latest shapely to our repo: https://github.com/linuxserver/wheelie/commit/098d19692ae134f91baa348a0b93d1d4509c56e8 You can use this mod to make sure it's installed on every container start by adding the following env vars:

DOCKER_MODS=linuxserver/mods:universal-package-install
INSTALL_PIP_PACKAGES=shapely

In reality, it should install it in the config folder the first time (persistent storage), and it shouldn't need to reinstall unless the custom integration needs a newer version or if/when our HA image moves to the next python version (3.12), which won't be for a while.

roflcoopter commented 1 year ago

I figured it there was a specific reason for it.

Tried using the Docker mod, works great! Thanks a lot for the quick reply and solution.

Iceman248 commented 1 year ago

So I wasted about an hour trying to upgrade from 2023.6.0, since 6.1 or 7.0 didn't work, but after doing these 2 variables, my new error became this. Even downgrading back to 6.0, still had this issue, ended up deleting the variables, redoing completely to get it to work again error free.

Logger: homeassistant.setup
Source: lsiopy/lib/python3.11/site-packages/shapely/__init__.py:1
First occurred: 6:33:08 PM (1 occurrences)
Last logged: 6:33:08 PM

Setup failed for custom integration husqvarna_automower: Unable to import component: Error loading shared library libgeos_c.so.1: No such file or directory (needed by /config/lsiopy/lib/python3.11/site-packages/shapely/lib.cpython-311-x86_64-linux-musl.so)
Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/setup.py", line 215, in _async_setup_component
    component = integration.get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/loader.py", line 813, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/husqvarna_automower/__init__.py", line 18, in <module>
    from .const import (
  File "/config/custom_components/husqvarna_automower/const.py", line 3, in <module>
    from shapely.geometry import Polygon
  File "/config/lsiopy/lib/python3.11/site-packages/shapely/__init__.py", line 1, in <module>
    from .lib import GEOSException  # NOQA
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: Error loading shared library libgeos_c.so.1: No such file or directory (needed by /config/lsiopy/lib/python3.11/site-packages/shapely/lib.cpython-311-x86_64-linux-musl.so)
aptalca commented 1 year ago

Try getting the package installer to also install geos as an os package and see if it fixes it