OpenTerrace / openterrace-python

OpenTerrace: A fast, flexible and extendable Python framework for packed bed thermal energy storage simulations
https://openterrace.github.io/openterrace-python/
GNU General Public License v3.0
20 stars 2 forks source link

'openterrace' has no attribute '__version__' #114

Closed AdamRJensen closed 8 months ago

AdamRJensen commented 8 months ago

It's fairly standard for python packages to support returning the pacake version by the command .__version__. This currently isn't supported by the package.

    import openterrace
    openterrace.__version__
    >>> AttributeError: module 'openterrace' has no attribute '__version__'
jakobhaervig commented 8 months ago

Thanks!

On purpose the version number is kept in the metadata file, e.g. pyproject.toml. In there the dummy value of 0.0.0 is automatically updated when a new wheel is created. The value to reverted back to 0.0.0. The version however shows up correctly in the metadata of PyPI wheel being generated: https://pypi.org/project/openterrace/#files

Screenshot from 2024-02-26 13-02-03

I found some additional information on the topic here: https://stackoverflow.com/questions/72167802/adding-version-attribute-to-python-module

While some people actually advise not to add a version attribute, I still see its relevance. I'll look into how to automatically update a _version.py file using dynamic versioning provided by Poetry.

jakobhaervig commented 8 months ago

The version number can be retrieved from metadata by:

from importlib import metadata metadata.metadata('openterrace')['version']

AdamRJensen commented 8 months ago

The version number can be retrieved from metadata by:

from importlib import metadata metadata.metadata('openterrace')['version']

This doesn't seem like an ideal solution. I still think I would prefer being able to do .__version__

jakobhaervig commented 8 months ago

The __version__ attribute has now been added from v0.0.11 onwards.

Closing this one.

AdamRJensen commented 8 months ago

Addressed in #132