scientific-python / lazy-loader

Populate library namespace without incurring immediate import costs
BSD 3-Clause "New" or "Revised" License
132 stars 20 forks source link

missing __version__ attribute #96

Closed drammock closed 8 months ago

drammock commented 8 months ago

Is the lack of __version__ intentional / necessary?

$ mamba list lazy-loader
# packages in environment at /opt/mambaforge/envs/mnedev:
#
# Name                    Version                   Build  Channel
lazy-loader               0.3                      pypi_0    pypi
In [1]: import lazy_loader
In [2]: lazy_loader.__version__
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 lazy_loader.__version__

AttributeError: module 'lazy_loader' has no attribute '__version__'
stefanv commented 8 months ago

No, that's silly!

drammock commented 8 months ago

No, that's silly!

I thought so, but I'm often surprised by corner cases / some reason I never would have guessed.

effigies commented 8 months ago

Note that for packages that do not provide __version__, you can use importlib.metadata: metadata.version('lazy_loader')