Operating environment (Hass.io/Docker/Windows/etc.):
GNU/Linux
Description of problem:
In https://www.home-assistant.io/docs/installation/fedora/, which was updated by @fabaff in https://github.com/home-assistant/home-assistant.io/pull/10665 there is suggested to use Python 3.8, but in this repo in files e.g. setup.cfg I see there is just support for Python 3.7.
I tried to install Home Assistant 0.104.2 on machine with Python 3.8, but I can not run Home Assistant.
# /usr/bin/hass
Traceback (most recent call last):
File "/usr/bin/hass", line 6, in <module>
from pkg_resources import load_entry_point
File "/__init__.py", line 3251, in <module>
File "/__init__.py", line 3234, in _call_aside
File "/__init__.py", line 3263, in _initialize_master_working_set
File "/__init__.py", line 583, in _build_master
File "/__init__.py", line 900, in require
File "/__init__.py", line 786, in resolve
pkg_resources.DistributionNotFound: The 'importlib-metadata==1.3.0' distribution was not found and is required by homeassistant
From the documentation https://importlib-metadata.readthedocs.io/en/latest/:
importlib_metadata is a backport of Python 3.8鈥檚 standard library importlib.metadata module for Python 2.7, and 3.4 through 3.7. Users of Python 3.8 and beyond are encouraged to use the standard library module. When imported on Python 3.8 and later, importlib_metadata replaces the DistributionFinder behavior from the stdlib, but leaves the API in tact
Simply test which indicates there is importlib.metadata and there should not be additional dependency for import-metadata on Python 3.8.
Python 3.8.1 (default, Jan 11 2020, 00:31:22)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.metadata import version
>>> version('homeassistant')
'0.104.2'
FYI there is an ongoing PR (https://github.com/home-assistant/home-assistant/pull/29999) which will add support for python 3.8.
Also you don't seem to have follows the install guide. You did not install homeassistant in a virtual env. (Hass binary have ended up in system install location)
@elupus I think there is some misunderstanding. I pointed the documentation as an example of the bug (and to create this issue as bug explained later), because it was updated by one of members of the Home Assistant organization and that you should use virtualenv for Python 3.8, but Home Assistant does not officially support Python 3.8.. You can check docs for other GNU/Linux distros and you will see there Python 3.7. On the other hand, when you will create an issue in this repository, you will see a few options.
(Yesterday it was slightly different, but as showcase, it is enough).
Support for Python 3.8 can be also feature request, but what I describe is a bug even it is not officially supported. Even it somehow works for me, there should official support for Python 3.8. I got it running, but it needs to have installed package importlib-metadata from pypi even importlib-metadata is part of Python 3.8 and this is all about it.
However, feature requests should be created on the forum and there was nothing about Python 3.8 and for devs or people who are working with Git issue is preferred to see the progress of it and track it. Who is going to look at the blog carefully to check if there is something written about Python 3.8? After creating this issue found article from 11th December on Haas blog about upcoming Python 3.8.
I will like to keep you assured that I would write it differently when I would follow it. ;-) Anyway, in the docs, you can that other methods like not installing it in virtual env are supported looking to Armbian, macOS, Synology and so on. ;-)
I could be wrong. I see no official mention that 3.8 is not supported. The issue you mention is moving automatic CI to 3.8.
As you mention you just had to install one package to get it to run. Which is why I mention that it was not done in venv.
"importlib-metadata==1.4.0" is in the setup.py, so if that was not installed, something went wrong on install.
Hello! Misunderstandings aside, may I ask if importlib_metadata is still necessary if the user has Python 3.8 installed? As the documentation @BKPepe quoted says, users of (and I would assume, applications running on) Python 3.8 are encouraged to use the standard library module instead of the package. (The documentation also says the package replaces the DistributionFinder behaviour on Python 3.8 or later, not sure if Home Assistant relies on this different behaviour?)
These are questions for us because @BKPepe (and others) are working on packaging Home Assistant for OpenWrt (openwrt/packages#8750). Part of this process is packaging Home Assistant's dependencies as well. (OpenWrt users generally expect, and are generally expected to, use opkg instead of other package management tools or installers.)
If importlib_metadata isn't necessary for Python 3.8 users, then that's one less package we need to create and maintain. (That would also be one less package your Python 3.8 users would need to install.)
We also need to support other Python versions.
We also need to support other Python versions.
Changing the requirement to 'importlib-metadata==1.4.0;python_version<"3.8"'
should suffice.
Specifically, updating this line in setup.py to 'importlib-metadata==1.4.0;python_version<"3.8"'
should cause importlib_metadata to be installed for users with older versions of Python.
Unless you mean other Python implementations like IronPython and PyPy?
ping @frenck
Not sure why you pinged me there @BKPepe?
@frenck I ping you because you commented this PR as Home Assistant developer and you replied that you need to support other Python versions as well. However, @jefferyto provided a solution for that and it was left without a reply and PR which was mention by @springstan was closed without any further details.
Should I do a pull request with proposed change?
Yes, that was a general comment. I did not state to work on any of this.
If you think you can contribute a positive change to our codebase, we definitely welcome that.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 馃憤
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
No, this still happens.
Nothing is going to be done about this I think until python 3.7 support is dropped. (When python 3.9 is out)
I've opened #36225 to use the built-in importlib.metadata for Python 3.8 and newer (and use importlib_metadata for Python 3.7 and older). I would appreciate it if someone can take a look.
Thanks!
Most helpful comment
I've opened #36225 to use the built-in importlib.metadata for Python 3.8 and newer (and use importlib_metadata for Python 3.7 and older). I would appreciate it if someone can take a look.