Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add __version__ to python module #122

Open
lgsmith opened this issue Jul 26, 2024 · 3 comments
Open

add __version__ to python module #122

lgsmith opened this issue Jul 26, 2024 · 3 comments

Comments

@lgsmith
Copy link
Contributor

lgsmith commented Jul 26, 2024

Is your feature request related to a problem? Please describe

I just like to be able to check the software version from the python import, as opposed to querying conda or rooting around in an install dir. Makes reporting other issues easier too.

Describe the solution you'd like

Add a __version__ attribute to the python module, which is customary for python modules.

Describe alternatives you've considered

You can currently solve this problem with conda list | grep loos...

Additional context

None

@agrossfield
Copy link
Member

I think the right way to do this is to get the information from Cmake into the c++ library at compile time, then export that function to the python.

This website (https://community.gigperformer.com/t/getting-cmake-variables-from-c/17711) documents a way to have CMake generate a version.hpp file with the necessary information. Creating a function to return the info would be easy, as would exporting the info to python.

Not sure about how we'd get the function called to set version, though.

@lgsmith
Copy link
Contributor Author

lgsmith commented Jul 26, 2024

I think we just need to literally put it in the python module swig creates at the top level, and also in the pyloos. We could probably use a shell script to sed it in, or a python script that replaces it in, after those files are created during the build process. There are comments about this in PEP8.

So it could be as simple as putting:

__version__ = 'VERSION'

in the module files, then having a script that build runs replace VERSION with the correct version number.

@agrossfield
Copy link
Member

@tromo committed 3a3d2f3, which should fix this. Once you've confirmed it works for you, you can close the issue.

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

No branches or pull requests

2 participants