tabmat icon indicating copy to clipboard operation
tabmat copied to clipboard

tabmat has no attribute __version__

Open mathurinm opened this issue 3 years ago • 3 comments

I find it convenient to be able to check directly inside a python shell.

In [1]: import tabmat

In [2]: tabmat.__version__
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-aae82a909ca3> in <module>
----> 1 tabmat.__version__

AttributeError: module 'tabmat' has no attribute '__version__'

this is tabmat 3.0.7 installed via PyPI

mathurinm avatar Nov 24 '21 07:11 mathurinm

Please use the built-in importlib for this, this works for all packages.

Python 3.10.0 | packaged by conda-forge | (default, Nov 20 2021, 02:27:15) [Clang 11.1.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.metadata import version
>>> version('tabmat')
'3.0.7'

xhochy avatar Nov 24 '21 15:11 xhochy

It's clearly not critical, but I thought it was somehow a convention of python packages to expose this attribute directly. numpy, scipy, sklearn, matplotlib, pandas all do it I believe.

mathurinm avatar Nov 25 '21 08:11 mathurinm

That all stems from a time where importlib was not available. We also had this in tabmat but that increases the import time considerably.

xhochy avatar Nov 25 '21 08:11 xhochy