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 more accessible version information #6086

Merged
merged 1 commit into from Aug 10, 2020

Conversation

stuartarchibald
Copy link
Contributor

As title.

Opened this largely for feedback on the subject! Motivation is that a simple "check if Numba version is high enough to support some feature or other" involves doing something like:

from numba import __version__
assert tuple(int(x) for x in __version__.split('.')[:2]) >= (0, 51)

The currently present numba.__version__ gives something like:

In [1]: import numba                                                                                                            

In [2]: numba.__version__                                                                                                       
Out[2]: '0.52.0dev0+1.g115af3162'

this PR adds version_info which gives this:

In [3]: numba.version_info                                                                                                      
Out[3]: version_info(major=0, minor=52, patch=None, short=(0, 52), full=(0, 52, None), string='0.52.0dev0+1.g115af3162', tuple=('0', '52', '0dev0+1', 'g115af3162'), git_revision='g115af3162')

which makes it much easier to e.g. assert that Numba >= 0.51, e.g.

In [4]: assert numba.version_info.short > (0, 51) 

@esc
Copy link
Member

esc commented Aug 6, 2020

Thanks for patching this up! I tried it and I see:

In [3]: numba.__version__
Out[3]: '0.52.0dev0+1.g115af3162b'

In [4]: numba.version_info
Out[4]: version_info(major=0, minor=52, patch=None, short=(0, 52), full=(0, 52, None), string='0.52.0dev0+1.g115af3162b', tuple=('0', '52', '0dev0+1', 'g115af3162b'), git_revision='g115af3162b')

Though I am asking myself, if patch should be None?

@stuartarchibald
Copy link
Contributor Author

Though I am asking myself, if patch should be None?

I'm wasn't sure so put in None, the patch isn't linear increment/semver like unless its on a tag, open to suggestions.

@esc
Copy link
Member

esc commented Aug 10, 2020

I think if patch is not None on a tag, this should be fine.

@stuartarchibald
Copy link
Contributor Author

I think if patch is not None on a tag, this should be fine.

Just tried it:

$ git tag -a 0.123.4 -m "version 0.123.4"
$ git lg|head -1
* 115af3162 - (HEAD -> wip/version_info, tag: 0.123.4, upstream/pr/6086, origin/wip/version_info) Add more accessible version information (2020-08-06 10:29:45 +0100) <Stuart Archibald>
$ python -c "import numba; print(numba.version_info)"
version_info(major=0, minor=123, patch=4, short=(0, 123), full=(0, 123, 4), string='0.123.4', tuple=('0', '123', '4'), git_revision=None)

@esc
Copy link
Member

esc commented Aug 10, 2020

@stuartarchibald that will suffice for me!

Copy link
Member

@esc esc left a comment

Choose a reason for hiding this comment

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

LGTM

@esc esc added 5 - Ready to merge Review and testing done, is ready to merge and removed 3 - Ready for Review labels Aug 10, 2020
@sklam sklam merged commit 78ce7d7 into numba:master Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to merge Review and testing done, is ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants