Skip to content

Expose pynxtools version#738

Merged
mkuehbach merged 11 commits into
masterfrom
get_setuptool_version
Mar 16, 2026
Merged

Expose pynxtools version#738
mkuehbach merged 11 commits into
masterfrom
get_setuptool_version

Conversation

@mkuehbach
Copy link
Copy Markdown
Collaborator

@mkuehbach mkuehbach commented Feb 12, 2026

Add creator, and creator_version to root and allow other modules to get pynxtools version, using scm

… writer used, useful cuz knowing only which commit of the NeXus definitions was used does not necessarily pin that pynxtools and in which version it was used. Admittedly, yes the dev strategy has been that a specific pynxtools version always uses one specific NeXus version but there could be development version which use the same NeXus version so concluding backwards is not uniquely possible
Copy link
Copy Markdown
Collaborator

@lukaspie lukaspie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same applies here as in FAIRmat-NFDI/pynxtools-plugin-template#25 (review): why do we not rather determine the pynxtools version runtime using importlib.metadata (a part of the standard lib) rather than relying on a version determined at build time?

Here's my reasoning in a longer form:
When writing the NeXus file, the goal should be to record the version of the pynxtools (and its plugin) that actually produced the data. Retrieving the version via importlib.metadata achieves this by reading the version information from the installed distribution metadata, independent of the presence of a Git repository or build environment. In contrast, the setuptools_scm configuration derives the version from the state of the source repository at build time and relies on Git metadata being available. While this is appropriate for generating package versions during packaging, it can become unreliable once the package is installed from a wheel or source distribution, executed in containerized or deployed environments without Git, or run outside the original repository. Using importlib.metadata therefore ensures that the recorded version always corresponds to the installed pynxtools package that generated the output.

Again, I support to record this information, the question is rather how we obtain it.

@rettigl
Copy link
Copy Markdown
Collaborator

rettigl commented Feb 12, 2026

Ho about
__version__ = importlib.metadata.version("pynxtools")

in init.py?

@lukaspie
Copy link
Copy Markdown
Collaborator

lukaspie commented Feb 12, 2026

Ho about __version__ = importlib.metadata.version("pynxtools")

in init.py?

Yes, that would probably a clean solution. Then again, we don't even need that, we can just call importlib.metadata.version("pynxtools") when we need it.

For a discussion around this, see https://discuss.python.org/t/please-make-package-version-go-away/58501

@mkuehbach mkuehbach requested a review from lukaspie February 13, 2026 11:51
@mkuehbach
Copy link
Copy Markdown
Collaborator Author

Pipeline failures related exclusively to ref logs of plugins not having creator

Copy link
Copy Markdown
Collaborator

@lukaspie lukaspie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the failing plugin tests, we should do this in FAIRmat-NFDI/pynxtools-plugin-template#25 and then on cruft update, we have to regenerate the example files.

Please, before merging, could you append to this test as well? https://github.com/FAIRmat-NFDI/pynxtools/blob/master/tests/dataconverter/test_helpers.py#L155

@mkuehbach
Copy link
Copy Markdown
Collaborator Author

For the failing plugin tests, we should do this in FAIRmat-NFDI/pynxtools-plugin-template#25 and then on cruft update, we have to regenerate the example files.

Please, before merging, could you append to this test as well? https://github.com/FAIRmat-NFDI/pynxtools/blob/master/tests/dataconverter/test_helpers.py#L155

Test and documentation was added, feature complete.

@mkuehbach mkuehbach requested a review from lukaspie February 13, 2026 13:10
@lukaspie
Copy link
Copy Markdown
Collaborator

lukaspie commented Feb 13, 2026

For the failing plugin tests, we should do this in FAIRmat-NFDI/pynxtools-plugin-template#25 and then on cruft update, we have to regenerate the example files.
Please, before merging, could you append to this test as well? master/tests/dataconverter/test_helpers.py#L155

Test and documentation was added, feature complete.

Thanks, but can you please add to the specific tests (i.e. test_writing_of_root_attributes) mentioned as well? That checks that creator(_version) are properly populated.

Copy link
Copy Markdown
Collaborator

@lukaspie lukaspie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, assuming the other test is added. Thanks!

@mkuehbach mkuehbach merged commit bb6cb21 into master Mar 16, 2026
10 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants