-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Currently makeAutomaticFields() looks for package version numbers via the __version__ attribute. However, while this is widely used, it is not always supported, and there is no formal directive to do so. There was PEP 396 on this topic, but it was withdrawn, and the whole question was left to package managers to deal with.
In Python 3.8, the importlib.metadata module was added, which reads package metadata from places like egg-info. Included in this is a version() function, which gives the package manager's notion of the package version, quite distinct from that found in __version__.
I am unsure whether to use this. However, it seems worth considering, either as the primary or fallback method of getting a version number. It does a few odd things, so needs to be handled with care.
- It raises an exception if it can't find a version number
- The
version()function expects a distribution name, rather than package name. These are often the same, but not always, so one would need to use packages_distributions() to translate between these
I am not going to act on this immediately, but wanted to record the idea, so I remember to investigate it. Any thoughts and comments are welcome.