Skip to content

(zigpy_znp.__version__) not available #205

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

Closed
pipiche38 opened this issue Mar 6, 2023 · 3 comments
Closed

(zigpy_znp.__version__) not available #205

pipiche38 opened this issue Mar 6, 2023 · 3 comments

Comments

@pipiche38
Copy link
Contributor

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

@puddly
Copy link
Collaborator

puddly commented Mar 6, 2023

You can read it with importlib.metadata.version:

from importlib.metadata import version

version("zigpy-znp")

This works for all packages.

@puddly puddly closed this as completed Mar 6, 2023
@zerodat
Copy link

zerodat commented Mar 26, 2023

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

@puddly
Copy link
Collaborator

puddly commented Mar 27, 2023

I can't replicate this problem by just pip installing the package in a clean environment. Perhaps the Arch re-packaging is breaking things?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants