python-sdbus / python-sdbus-networkmanager

python-sdbus binds for NetworkManager
GNU Lesser General Public License v2.1
28 stars 6 forks source link

Add __about__.py providing package metadata such as __version__ #33

Closed bernhardkaindl closed 2 years ago

bernhardkaindl commented 2 years ago

It is common that python packages export package.__version__:

A complete description is in sdbus_async/networkmanager/__about__.py

bernhardkaindl commented 2 years ago

Hi @igo95862, thanks for #14, I'd like to check and show the package version in my project so I'd like to add package.__version__ which many packages provide too.

igo95862 commented 2 years ago

I looked if this was somehow standardized and this is what I found.

https://peps.python.org/pep-0396/#pep-rejection

It looks like the __version__ attribute was a draft at some point but got rejected.

The proper way of querying the package version is importlib.metadata.version

The package.__version__ is not going to break anything but I need to think about adding it.

bernhardkaindl commented 2 years ago

https://peps.python.org/pep-0396/#pep-rejection

Yes, while it was rejected, many many packages use it.

The proper way of querying the package version is importlib.metadata.version

This is only available with python >=3.8, but since I use at least 3.8, that's ok for me, works and no additional code.

Users of 3.7 have pkg_resources.get_distribution('sdbus-networkmanager').version (which is said to be slow) and the backport importlib_metadata for 3.7. So, ok with me.