Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homeassistant: update to v2022.10.5 #5478

Merged
merged 14 commits into from
Jan 22, 2023

Conversation

hgy59
Copy link
Contributor

@hgy59 hgy59 commented Nov 4, 2022

Description

Since we can now build Cryptography wheel with rust, it is time to update homeassistant.

Fixes #4977, fixes #4189, fixes #5469, fixes #5362
Closes #4969, closes #3638, closes #4183, closes #5064

Checklist

  • Build rule all-supported completed successfully
  • New installation of package completed successfully
  • Package upgrade completed successfully (Manually install the package again)
  • Package functionality was tested
  • Any needed documentation is updated/created

Type of change

  • Package update
  • Includes small framework changes (fix python virtualenv creation for DSM<7)
  • This change requires a documentation update (e.g. Wiki)

@hgy59
Copy link
Contributor Author

hgy59 commented Nov 4, 2022

@th0ma7 homeassistant depends now on orjson wheel.

The build of orjson wheel needs manturin instead of setuptools-rust to build with rust.
I have fixed this by installing maturin with pip in native/python310 and into the cross build env.

In this context I found, that spk/homeassistant/Makefile did not add the path to native/python310 bin folder to the environment (and could not find maturin...).

I suppose that all packages creating wheels must set the path for native/python to be found first, otherwise it uses python3 (and wheel, pip, ...) of the dev environment that is still on python 3.9.

@th0ma7
Copy link
Contributor

th0ma7 commented Nov 4, 2022

That is really really odd. A few things:

  • When creating the crossenv directory cross/python310 does use proper pip from PIP_NATIVE variable which in turns points to native/python310
  • in theory, neither manturin nor setuptools-rust are needed into native/python310. They are only needed part of the work-<arch>-<version>/crossenv being generated duging cross/python310
  • As you are invoking the work-<arch>-<version>/crossenv/cross/bin/* cross-environment binaries when cross-compiling wheels, in turns you make use of native/python310 libraries.
  • even if you build pure-python wheel, you'll still be calling native/python310

So I wonder how did you ended-up calling python3.9, how was that even possible?

@Safihre
Copy link
Contributor

Safihre commented Nov 6, 2022

Does Homeassistant really need orjson? SABnzbd can also use it for example, but will just fallback to regular json if not available.
Does the package not start without it?

@hgy59
Copy link
Contributor Author

hgy59 commented Nov 6, 2022

Does Homeassistant really need orjson? SABnzbd can also use it for example, but will just fallback to regular json if not available. Does the package not start without it?

@Safihre I didn't try to start it without orjson, as this is listed in the dependencies in homeassistants pyproject.toml

@ixje
Copy link

ixje commented Nov 16, 2022

Does Homeassistant really need orjson? SABnzbd can also use it for example, but will just fallback to regular json if not available. Does the package not start without it?

fwiw I looked at it. It's part of their helpers/utils and there is no logic to fallback to the default. Their utils use specific options when dumping such as orjson.OPT_PASSTHROUGH_DATACLASS with the note

orjson supports serializing dataclasses natively which
eliminates the need to implement as_dict in many places
when the data is already in a dataclass. This works
well as long as all the data in the dataclass can also
be serialized.

Which makes me believe they rely on it later in their code base. Finally, the home_kit component also has orjson as requirement.

@hgy59
Copy link
Contributor Author

hgy59 commented Nov 16, 2022

So I will drop ARMv5 support of homeassistant, as maturin wheel cannot be built for it.

Affected models with DSM 6 are

  • DS213air, DS213, DS413j
  • DS112, DS112+, DS212, DS212+, RS212, RS812, DS212j, DS112j
  • DS111, DS211, DS211+, DS411slim, DS411, RS411, DS211j, DS411j

EDIT:
ARMv5 support was already dropped by numpy.

@Safihre
Copy link
Contributor

Safihre commented Nov 16, 2022

Ancient models. So just put it in release notes if anyone is wondering later.

@ixje
Copy link

ixje commented Nov 16, 2022

🎉 can't wait for this release. Thanks for the work 👍

@hgy59
Copy link
Contributor Author

hgy59 commented Nov 17, 2022

@ixje the default configurations are working now.

If you wanna try, wait for the github action to complete (successfully I hope).
But be aware, that intergrations might need a manual installation

To manually install missing python modules (wheels):

  1. ssh into your diskstation
  2. navigate (cd) to folder /var/packages/homeassistant/target/env/bin
  3. call ./pip install --no-deps "python-package==version"
  4. report working integrations and/or missing python modules here

you find the spk packages to download after gh action completes under "checks - build - summary - artifacts"
to find the matching package see our wiki under Package Archs

Thanks.

@ixje
Copy link

ixje commented Nov 18, 2022 via email

@Safihre
Copy link
Contributor

Safihre commented Nov 18, 2022

Working hard @hgy59! 👍 👍

@hgy59
Copy link
Contributor Author

hgy59 commented Nov 18, 2022

Hi homeassistant users!
I currently have some questions on how to resolve the huge Dependency Stuff

When I released the last ha package (2021.9.7-15) I started to bundle only the cross compiled wheels into the package and load all the pure python dependencies at installation time (this takes up to 60 minutes to install HA on an old weak model like DS-115j). One reason to do so, was to keep the spk files as small as possible.

But it is a time consuming task to find all the dependencies (I created a test client that tries to add all integrations and added the modules until respective error logs where gone).

But I actually do not want to include a list of all the (pure) python modules anymore and install all those packages at installation time. This can be done for the basic requirements to run homeassistant at its own. But not for the huge (constantly growing) number of integrations.
I am (as a non python programmer) wondering, why some python modules in homeassistant (or any other python program?) are installed on the fly and others fail with No module named ....

  • Isn't there an automatic dependency resolver in Python available, that installs missing dependencies on the fly (without adjusting the code of homeassistant)? (I found pipimport, but AFAICT you have to use it inside python code)
  • What kind of application/tool could provide a solution for automatic python module installation?
  • Exists this dependency problem only in Home Assistent Core? (don't know the other distributions [supervisor?], but those do not run on Synology DSM anyway).

So far a manuall installation of missing python modules is the only solution but on spk package updates, all those manual installations are lost.

some early ideas:

  • create an additional requirements file that can be manually updated by users and that is used to install additional dependencies at service start (and that will survive package updates)
  • create a tool that watches the homeassistant log files and calls pip to install missing modules on the fly
  • ask homeassistant developers to improve the code to automatically (or interactivly) install missing dependencies when adding integrations

...probably I am too far away from the python mystery and there exists a simple solution?

@ixje
Copy link

ixje commented Nov 18, 2022 via email

@ixje
Copy link

ixje commented Nov 24, 2022

Got delayed a bit, just finished trying to install.
I installed the wheels from package/share/wheelhouse/ all fine. Then tried to install /package/share/postinst_components_requirements.txt.
I solved about 5 conflicts then stopped because I'm wondering if it is worth it. Where did this list come from and is it up to date?

@daxcore
Copy link

daxcore commented Dec 22, 2022

I had to install python module "natsort" by my own to get work one of the "helpers" - I guess it was the "utility meter" or "Riemann sum integral" helper.

@abwebc
Copy link

abwebc commented Dec 27, 2022

Do we know when this could be merged?

@chickenandpork
Copy link
Member

Is there an updated build container for this? I would normally use the latest container in GHCR but that lacks the rust toolchain.

My usual go-to looks like this:

docker run -it -v ${HOME}/src/spksrc:/spksrc -w /spksrc \
    ghcr.io/synocommunity/spksrc \
    /usr/bin/make homeassistant-clean spk-homeassistant-denverton-7.0

I'm a python guy, but not a rust guy outside of limited cmake-based rust builds

I wrapped the build container with a quick rust-equivalent of get-pip like this, but it failed:

FROM ghcr.io/synocommunity/spksrc:latest
  
RUN curl -o installer --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs && sh ./installer -y

(that's a curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh per documentation, but a temp file to allow adding -y param to run non-interactively)

Failed as:

Building wheels for collected packages: maturin
  Building wheel for maturin (pyproject.toml): started
  Building wheel for maturin (pyproject.toml): finished with status 'error'
...
      writing manifest file 'maturin.egg-info/SOURCES.txt'
      running build_ext
      running build_rust
      error: can't find Rust compiler

... so there's something else missing in the rust toolchain.

@hgy59 if you had to update the build container, can you document it, or have I made a silly error in my repro of building this SPK ?

@chickenandpork
Copy link
Member

chickenandpork commented Jan 3, 2023

@hgy59 @ixje

I am (as a non python programmer) wondering, why some python modules in homeassistant (or any other python program?) are installed on the fly and others fail with No module named ....

  • Isn't there an automatic dependency resolver in Python available, that installs missing dependencies on the fly (without adjusting the code of homeassistant)? (I found pipimport, but AFAICT you have to use it inside python code)
  • What kind of application/tool could provide a solution for automatic python module installation?
  • Exists this dependency problem only in Home Assistent Core? (don't know the other distributions [supervisor?], but those do not run on Synology DSM anyway).
    So far a manuall installation of missing python modules is the only solution but on spk package updates, all those manual installations are lost.

I think it is as you say: there is a basic set of dependencies installed, and dependencies of integration are installed as needed. For example, take a look at https://github.com/home-assistant/core/blob/dev/pyproject.toml#L26 ... this might fail on case-by-case with integrations that don't describe dependencies, assuming all servers have certain modules at certain versions. I think it may be important to see which fail specifically.

(@hgy59 pyproject.toml is the newer way of recording the metadata about a python thing; IIUC it should replace setup.py)
You'll see just a basic set of requirements; based on how HASS used to act, others were installed as-needed based on the integration I was activating, but I don't have hard proof of that. I know that python won't discover a missing dependency until you interpret the affected file, so there might be some scaffolding around the activation of a new integration to stage in the dependencies.

Your list should probably be an automatic pip freeze or pip-compile of the dependencies based on this file -- every install of this SPK should start out the same to avoid identical installs reaching different results. I realize I'm biased: I'm a bazel guy, and I use version-locked python dependencies for aggressive consistency. I use the bazel stuff for pip-compile so I never run it myself, so I'm rusty there too :(

The idea of an extra list of dependencies, or archives to lay into the config/custom_components that would survive updates would be awesome!

@davesc63
Copy link

davesc63 commented Jan 12, 2023

Testing out your latest build.
I am getting python path issues and packages not installing.

Main errors are:
Unable to install package packageName==0.0.15: ERROR: Will not install to the user site because it will lack sys.path precedence to "dependancy" in /volume1/@appstore/homeassistant/env/lib/python3.10/site-packages

I can resolve that issue manually, but it makes almost every integration receive an HTTP/500 error in the UI.

Another issue is - Cannot reload configuration.yaml using Developer Tools - YAML - Restart
Need to stop HA via DSM Package center

@davesc63
Copy link

davesc63 commented Jan 14, 2023

Ok - I think I have resolved my python / installation issues.

Issue:
No integrations were installing their dependencies.

Error messages:
When initiating the installation of an integration from the GUI:
Defaulting to user installation because normal site-packages is not writeable

Then in the HA log:
Unable to install package packageName==0.0.15: ERROR: Will not install to the user site because it will lack sys.path precedence to "dependancy" in /volume1/@appstore/homeassistant/env/lib/python3.10/site-packages

I noticed that /volume1/@appstore/homeassistant/env/lib/python3.10/site-packages has "root" as the owner

Home Assistant user is "sc-homeassistant"

Resolution:
I ran sudo chown -R sc-homeassistant /volume1/@appstore/homeassistant/env/lib/python3.10/site-packages

I was then able to add integrations from the GUI and they would resolve/install their dependencies as required.

Two packages I was having issues adding:

  • Enphase Envoy
  • Aussie Broadband

Both integrations would return a "config flow" error when attempting to add via the HA GUI, then looking in the logs would give the error around the python user-site

@hgy59
Copy link
Contributor Author

hgy59 commented Jan 14, 2023

@davesc63 thank you for looking into this and finding a solution. I will fix the installer.

@hgy59
Copy link
Contributor Author

hgy59 commented Jan 14, 2023

@davesc63 installation issue is fixed now (was for DSM < 7)

@davesc63
Copy link

@hgy59 Great work!

I still cannot restart homeassistant from Developer Tools - YAML - Restart

It hangs, DSM shows homeassistant as stopped and I need to start it from DSM. Haven't got much more info yet

@hgy59
Copy link
Contributor Author

hgy59 commented Jan 14, 2023

It hangs, DSM shows homeassistant as stopped and I need to start it from DSM. Haven't got much more info yet

HA Core has changed. It does not have an option to create a pid-file anymore and you can only start and stop it within the DSM Package Center.

@hgy59
Copy link
Contributor Author

hgy59 commented Jan 15, 2023

I had to install python module "natsort" by my own to get work one of the "helpers" - I guess it was the "utility meter" or "Riemann sum integral" helper.

After trying to add all integrations, natsort==8.2.0 was installed on the fly.


Now almost all integrations that can be configured in the Web UI are working (see the updated wiki page

The follwing integrationes do not work

  • Google Nest
  • IKEA TRÅDFRI
  • SMS notifications via GSM-modem
  • Tasmota (may run, can't verify without a compatible device)
  • WiLight

IKEA TRÅDFRI runs with the current SynoCommunity Package (v2021.9.7-15)
Is this a blocker for releasing this package as is?

@davesc63
Copy link

Ship it! :)

- update dependencies
- adjust service-setup for command line parameters that are not supported anymore (--pid-file, --daemon)
- avoid use of install_python_wheels function, as we want to install whl files from wheelhouse
- abort installation when default_config installation failed (fail fast)
- increase expected installation time up to 60 minutes (it took 55 min. on a DS115j)
- update requirements (crossenv and pure, remove abi3)
- move requirements of default_configuration to requirements-pure.txt
- homeassistant core, web and default_config are working without errors
- some integrations work already (synology dsm/srm, hue, brother, ipp)
- update package icon with higher resolution
- add hacs integration (from archive file)
- add pycryptodomex (requirements-abi3.txt)
- save/restore pip-cache on package update
- fix dependencies
- fix psutil for qoriq (again)
- remove duplicate requirements
- multidict<6.0.0,>=5.1.0 required
- package user needs access to created virtual environment
- package user needs access to installed site-packages
- Add requirements-custom.txt for custom requirements that will be reinstalled on package update
- add websockets to crossenv reqirements
- add pycryptodome
@hgy59 hgy59 merged commit 661ac47 into SynoCommunity:master Jan 22, 2023
@hgy59 hgy59 deleted the update_homeassistant branch January 22, 2023 18:11
@hgy59
Copy link
Contributor Author

hgy59 commented Jan 22, 2023

@th0ma7 the github action fails to build, but my local builds succeed.
It seems to be related to the "setup of rust" as the errors are:

ERROR: Could not build wheels for maturin, which is required to install pyproject.toml-based projects

Probably related to #5508 ?

EDIT:
And #5570 fails to build deluge with:

$ make arch-x64-6.1 -C ./spk/deluge
      If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs)/ is the recommended way to download and update the Rust compiler toolchain.
      [end of output]

@chickenandpork
Copy link
Member

@th0ma7 the github action fails to build, but my local builds succeed. It seems to be related to the "setup of rust" as the errors are:

ERROR: Could not build wheels for maturin, which is required to install pyproject.toml-based projects

Probably related to #5508 ?

was rustc added to the standard build image? When I tried a while back it wasn’t.

@hgy59
Copy link
Contributor Author

hgy59 commented Jan 22, 2023

was rustc added to the standard build image? When I tried a while back it wasn’t.

In #5508 the rust toolchains where removed from the image and should be installed on the fly. I have the same image and it works locally, but probably rustc is installed already in the distrib folder.
It works with the distrib folder mounted to a local volume (containing distrib/cargo/bin/rustc), but it might not work wirth an empty distrib folder when running from scratch.

@th0ma7
Copy link
Contributor

th0ma7 commented Jan 23, 2023

The rust toolchain is now downloaded per arch based on spksrc.tc.mk.

I just tested it 2 weeks ago for py310-311 upgrade pr and all was working all right. Perhaps this is only a temporary github networking issue or due to a new commit since then?

@hgy59
Copy link
Contributor Author

hgy59 commented Jan 23, 2023

Error from github build log (vim, x64-6.1) when building the maturin wheel with cross/python310:

2023-01-22T22:04:43.1539069Z       running build_ext
2023-01-22T22:04:43.1539302Z       running build_rust
2023-01-22T22:04:43.1539599Z       error: can't find Rust compiler

EDIT:
and I find 30x CARGO_HOME="" RUSTUP_HOME="" in the log file (and no other occurencies of CARGO_HOME and RUSTUP_HOME

@hgy59 hgy59 added the status/published Published and activated (may take up to 48h until visible in DSM package manager) label Jan 23, 2023
@rdagger
Copy link

rdagger commented Jan 25, 2023

@hgy59 Thanks for all the hard work on the update! So far, it's working great, but I have 1 small issue. Every time I restart Home Assistant, it stops the package and I have to log into the Synology and run the Home Assistant Core package manually.

@hgy59
Copy link
Contributor Author

hgy59 commented Jan 25, 2023

Every time I restart Home Assistant, it stops the package and I have to log into the Synology and run the Home Assistant Core package manually.

As I described in https://github.com/SynoCommunity/spksrc/wiki/FAQ-HomeAssistant/ under Trouble shooting, it is not possible to restart Home Assistant in the HA UI anymore. You have to restart it in the DSM Package Center (or on the command line).

@RedEarth1
Copy link

I had to install python module "natsort" by my own to get work one of the "helpers" - I guess it was the "utility meter" or "Riemann sum integral" helper.

After trying to add all integrations, natsort==8.2.0 was installed on the fly.


Now almost all integrations that can be configured in the Web UI are working (see the updated wiki page

The follwing integrationes do not work

  • Google Nest
  • IKEA TRÅDFRI
  • SMS notifications via GSM-modem
  • Tasmota (may run, can't verify without a compatible device)
  • WiLight

IKEA TRÅDFRI runs with the current SynoCommunity Package (v2021.9.7-15)
Is this a blocker for releasing this package as is?

Is IKEA Tradfri broken for good now then?

@hgy59
Copy link
Contributor Author

hgy59 commented Jan 27, 2023

Is IKEA Tradfri broken for good now then?

In the current package, IKEA Tradfri does not run out of the box. You have to update aiocoap manually (see #5578)

In the next package (#5579) I try to fix this. But there is an unresolvable conflict. Actual HA does not support concurrently installation of the apple homekit and the IKEA Tradfri Integrations.

@RedEarth1
Copy link

Is IKEA Tradfri broken for good now then?

In the current package, IKEA Tradfri does not run out of the box. You have to update aiocoap manually (see #5578)

In the next package (#5579) I try to fix this. But there is an unresolvable conflict. Actual HA does not support concurrently installation of the apple homekit and the IKEA Tradfri Integrations.

Ah OK thanks, as long as it's still on the radar ;-)
I'll have a go at updating aiocoap manually

@hgy59 hgy59 mentioned this pull request Jan 28, 2023
@MNoso
Copy link

MNoso commented Feb 5, 2023

Description

Since we can now build Cryptography wheel with rust, it is time to update homeassistant.

Fixes #4977, fixes #4189, fixes #5469, fixes #5362 Closes #4969, closes #3638, closes #4183, closes #5064

Checklist

* [x]  Build rule `all-supported` completed successfully

* [x]  New installation of package completed successfully

* [x]  Package upgrade completed successfully (Manually install the package again)

* [x]  Package [functionality was tested](https://github.com/SynoCommunity/spksrc/wiki/Update-Policy#tests-checks)

* [x]  Any needed [documentation](https://github.com/SynoCommunity/spksrc/wiki/Create-documentation) is updated/created

Type of change

* [x]  Package update

* [x]  Includes small framework changes (fix python virtualenv creation for DSM<7)

* [x]  This change requires a documentation update (e.g. Wiki)

HI! Sorry, i have a couple problems after update on my Synology. Some integrations does not work anymore. How can i rollback?

@marcofranssen
Copy link

@hgy59 I'm running into a Aborted (core dump). error log on my DS413 which is PPC architecture (6.1 qoriq package). What can I do to provide more info to see if we can fix this?

@mreid-tt
Copy link
Contributor

mreid-tt commented Feb 8, 2023

@hgy59 I'm running into a Aborted (core dump). error log on my DS413 which is PPC architecture (6.1 qoriq package). What can I do to provide more info to see if we can fix this?

@marcofranssen, I would suggest you open a new issue for this. The template will guide you though what logs and other information should be provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment