Closed pipiche38 closed 1 year ago
You can read it with importlib.metadata.version
:
from importlib.metadata import version
version("zigpy-znp")
This works for all packages.
I'm hitting an error in zigpy_znp itself, which seems to be related to this packaging change. In the latest version of Home Assistant installed from the Arch Linux package repositories, it throws an exception, at line 139 of zigpy_znp/api.py
, which is this code:
package_version = pkg_resources.get_distribution("zigpy_znp").version
Note that in HA, zigpy_znp is installed in a python venv, not in /usr/lib/python3.10/site-packages
, which might be related.
I was able to fix the problem and make HA work again by changing that line in zigpy_znp/api.py
to:
from importlib.metadata import distribution
package_version = distribution("zigpy_znp").version
I can't replicate this problem by just pip install
ing the package in a clean environment. Perhaps the Arch re-packaging is breaking things?
Previously it was possible to check the zigpy_znp version with zigpy_znp.version as for the other libraries. looks like since the move to the new packaging model , this version attribute is not available any more.
I wouldn't say it is a regression, as it doesn't impact the behaviour and the runing of the library, but it was good to be able to cross-check the package version in order to make sure that the above program layer is relying on a consistent set and tested pack of libraries.
Yes, using requirements.txt will help to control that, but will not prevent users to do what ever they want, so the version atrtribute was a great value