Closed bernhardkaindl closed 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.
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.
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.
It is common that python packages export
package.__version__
:setup.py
to read the version for single-sourcing the version.package.__version__
andsetup.py --version
A complete description is in
sdbus_async/networkmanager/__about__.py