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

Does bless have a versionID that can be retrieved? #98

Closed
WouterJD opened this issue Nov 18, 2022 · 5 comments
Closed

Does bless have a versionID that can be retrieved? #98

WouterJD opened this issue Nov 18, 2022 · 5 comments

Comments

@WouterJD
Copy link
Contributor

WouterJD commented Nov 18, 2022

Describe the solution you'd like
Please support a __version__ so that the version of the used library can be printed in a logfile
Of course any other option serving the purpose is OK.

Describe alternatives you've considered
n/a.

Additional context
print(bless.__version__) is helpfull when debugging

@kevincar
Copy link
Owner

Rather than hardcoding the version number, which could introduce human error if the version number is not updated with each new iteration. Would something like this work for you?

from importlib.metadata import version
version("bless")  # outputs: 0.2.4

@WouterJD
Copy link
Contributor Author

Hi @kevincar

Thanks for this option; it sure works: logfile.Write(s % ('bless', importlib_metadata_version("bless") ))

Do you have an explanation why this option works for numpy, but not the others?

       #logfile.Write(s % ('argparse',     importlib_metadata_version("argparse") ))
       #logfile.Write(s % ('binascii',     importlib_metadata_version("binascii") ))
       #logfile.Write(s % ('math',         importlib_metadata_version("math") ))
        logfile.Write(s % ('numpy',        importlib_metadata_version("numpy") ))
       #logfile.Write(s % ('os',           importlib_metadata_version("os") ))

@WouterJD
Copy link
Contributor Author

WouterJD commented Nov 19, 2022

PS. numpy.__version__ and version("numpy") both produce the same result (in my case 1.21.4).
I do not have the python (environment) knowledge to understand where the values come from and/or whether they are fundamentally identical.

Google on "python _version" does not help me, still wondering why not all packages have a version, or should I use another package name since it's coming with some other module?

@kevincar
Copy link
Owner

kevincar commented Nov 19, 2022

The version("<pkg_name>") should work for install packages via pip or conda into your current python environment. Modules such as os, math, argparse, etc are builtin modules that are part of the Python Standard Library, so you can roughly say that the version for os or math is the same as your current python version.

@kevincar
Copy link
Owner

kevincar commented Nov 19, 2022

Closing this for now. Feel free to list ideas if this posted solution is not sufficient.

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