davidusb-geek / emhass

emhass: Energy Management for Home Assistant, is a Python module designed to optimize your home energy interfacing with Home Assistant.
MIT License
263 stars 51 forks source link

Upgrade to python 3.11 #131

Closed pail23 closed 7 months ago

pail23 commented 8 months ago
davidusb-geek commented 7 months ago

Tests are failing, probably related to those changes on TZ and datetimes?

pail23 commented 7 months ago

Many thanks for your reviews. The tests should be fixed now and docs/requirements.txt is updated.

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (52064b0) 88.11% compared to head (1719b54) 88.11%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #131 +/- ## ======================================= Coverage 88.11% 88.11% ======================================= Files 6 6 Lines 1422 1422 ======================================= Hits 1253 1253 Misses 169 169 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

davidusb-geek commented 7 months ago

There are a lot of errors with Python 3.11. The Numpy version is not backwards compatible with Python 3.9 for example. How can we solve this? @pail23

davidusb-geek commented 7 months ago

Python are getting these errors: https://community.home-assistant.io/t/emhass-an-energy-management-for-home-assistant/338126/1566

pail23 commented 7 months ago

As a quick thought: Would it be possible to migrate the emhass addon to python 3.11?

According this the release notes of numpy 1.26, this version should be compatible with python 3.9-3.12.

I will have a look at the error messages an see if there are other options.

davidusb-geek commented 7 months ago

As a quick thought: Would it be possible to migrate the emhass addon to python 3.11?

Ok, but how to do this?

davidusb-geek commented 7 months ago

The problem seems to be with the pvlib package using the h5py package...

pail23 commented 7 months ago

I did not test, but we might be able to update to python 3.11 by replaceing bullseye with bookworm in emhass-add-on/emhass/build.yaml


build_from:
  amd64: ghcr.io/home-assistant/amd64-base-debian:bookworm
  armhf: ghcr.io/home-assistant/armhf-base-debian:bookworm
  armv7: ghcr.io/home-assistant/armv7-base-debian:bookworm
  aarch64: ghcr.io/home-assistant/aarch64-base-debian:bookworm
codenotary:
  signer: notary@home-assistant.io
  base_image: notary@home-assistant.io

bookworm is shipped with python 3.11 by default

davidusb-geek commented 7 months ago

Ok I will try that. Thanks!

pail23 commented 7 months ago

As an alternative:

According to this article, it might help to explcitly install a newer h5py version (h5py==3.10.0)

davidusb-geek commented 7 months ago

I added h5py==3.10.0 as a hard requirement but that does not seems to be the only problem. There seems to be an issue with pip3 and PEP 668. For now a solution was found using the flag --break-system-packages on pip3 install commands. Let's see if it works.

davidusb-geek commented 6 months ago

Builds are failing for the armhf architectures. It is a shame to leave those out, there is no full support for Python3.11 yet on that architecture I guess. https://github.com/davidusb-geek/emhass-add-on/actions/runs/7241702872