IAEA-NDS / endf-parserpy

Python package for reading, writing, verifying and translating ENDF-6 formatted files
Other
9 stars 4 forks source link

Version in Python #5

Closed marquezj closed 1 month ago

marquezj commented 3 months ago

Hi Georg. Congratulations on the new release.

I think it would be useful to make the version of the package available in Python, for instance as endf_parserpy.__version__.

(If it is available somewhere else in the code, I could not find it)

Best, Ignacio

marquezj commented 3 months ago

One more comment: the package metadata shows version 0.0.0, likely from here.

gschnabel commented 3 months ago

Hi Ignacio, Thanks for your nice words regarding the new release.

I think it is a good idea to put the version number into the code so that it is accessible via endf_parserpy.__version__ for convenience and I will do that. One option that is already available now for retrieving the version number (requiring Python 3.8 or higher) is using the importlib package functionality:

import importlib.metadata
importlib.metadata.version("endf_parserpy")

The version number in the pyproject.toml file is intentionally kept at 0.0.0 and is dynamically updated based on the current git tag during the release and PyPI publishing workflow defined here . Yesterday, there was a bit of trial and error involved to set up the publishing workflow correctly and I yanked versions 0.10.0, 0.10.1, 0.10.2. So if you happened to install the package during this time when the workflow was not properly established, maybe there was an error in correctly setting up the package meta information. In any case, it should work now.

Thinking more about it, it will be good to have the version number hard-coded in the code for traceability because git tags can be moved around and deleted on a whim. I will think how I can implement that so that the git tag and the code is guaranteed to be in sync during the git tag creation.

gschnabel commented 1 month ago

The version number is now stored in the __version__ variable in endf_parserpy/__init__.py and therefore accessible via endf_parserpy.__version__. The version number in the pyproject.toml file is automatically updated using the __version__ variable during the build process launched via pip install or similar. In this way, an appropriate version string is accessible irrespective of whether the package has been cloned or installed via a package manager. The commit implementing these changes is 37b094e.