-
Notifications
You must be signed in to change notification settings - Fork 231
Add __version__ attribute to package #134
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
Conversation
|
I this really required? Is this information placed in the generated dataclasses and do we expect something along the lines of min version required for compatibility between runtime vs compile time versions? I just feel this adds more things to keep in sync if we do not have a clear use case. If someone really wanted wouldn't something like this be sufficient? __import__('pkg_resources').get_distribution("betterproto").version |
It's not really required. It's a convenience, and I think it's quite a common convention, to be able to do "import some_lib; some_lib.version". Good to know that there's a general purpose solution. I suspect I'll have to check back here or google though next time I need it. It adds an extra step to the process of updating the version, but at least the test means you can't forget. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I am 100% okay with the __import__('pkg_resources').get_distribution("betterproto").version implementation.
I don't know exactly what magic __import__() is doing though.
I use some variation of this in one of my repos:
from pkg_resources import get_distribution
__versionstr__ = get_distribution('betterproto').version
__version__ = tuple(int(i) for i in __versionstr__.split('.'))I just find it easier to compare tuples...
I don't think it adds any harm or unnecessary overheads/maintenance to the library.
cetanu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made changes to derive the version from the current distribution.
No point in not merging this. It gives users a shortcut that is very obviously seen from perusing the source.
dd75cc7 to
980e83f
Compare
This allows users to check which version of betterproto they're using be evaluating
betterproto.__version__.Includes a test to prevent the value from being incorrect in a release.