Skip to content

Conversation

@nat-n
Copy link
Collaborator

@nat-n nat-n commented Aug 4, 2020

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.

boukeversteegh
boukeversteegh previously approved these changes Aug 6, 2020
@abn
Copy link
Collaborator

abn commented Aug 6, 2020

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

@nat-n
Copy link
Collaborator Author

nat-n commented Aug 6, 2020

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.

Copy link
Collaborator

@cetanu cetanu left a 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
cetanu previously approved these changes Mar 31, 2021
Copy link
Collaborator

@cetanu cetanu left a 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.

@cetanu cetanu force-pushed the version branch 2 times, most recently from dd75cc7 to 980e83f Compare March 31, 2021 00:29
cetanu
cetanu previously approved these changes Mar 31, 2021
@cetanu cetanu merged commit 7a358a6 into master Mar 31, 2021
@cetanu cetanu deleted the version branch March 31, 2021 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants