You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
__version__ is an old magic spell that has been cargo-culted to modern times without need. Some people even derived more magic from it like __author__, but nothing caught on so tenaciously as __version__.
Much breath has been wasted over purported health benefits such as “performance”. I won’t repeat all that here, just trust me: we shouldn’t propagate this vestige.
People can and should just use importlib.metadata.version('pkgname').
While I agree that people should use importlib, there's still a lot of functionality built around this convention.
I don't think it's wrong providing backwards-compatibility with this approach for such a little cost.
There’s only session-info AFAIK, which not only is very old, but also very tenuously maintained (don’t look at its code 😨). I built session-info2 to replace it and it seems to hold up nicely, there has been exactly one bug so far (around .pth handling, was fixed quickly).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
__version__is an old magic spell that has been cargo-culted to modern times without need. Some people even derived more magic from it like__author__, but nothing caught on so tenaciously as__version__.Much breath has been wasted over purported health benefits such as “performance”. I won’t repeat all that here, just trust me: we shouldn’t propagate this vestige.
People can and should just use
importlib.metadata.version('pkgname').compatibiliy
this is backwards-compatible, as
__version__is neither in the docs nor in__all__and therefore not a public API.