Reputation: 14924
Is there a way to get the python package distribution (wheel) name for a given module (python object given by import ...
)?
I know that it's possible to get meta-information about installed packages via importlib.metadata
(as mentioned here). It's also possible to get a filename for the calling function via inspect.getframeinfo.
What I'm looking for is a way to determine the package name and version of either the calling function or a module object supplied as an argument.
Yes I know that sounds like a very strange requirement.. The primary goal of this is for monitoring purposes to know what is actually deployed, right down to installed pacakges. Maintaining the mapping of module name to package name manually in code is risky because these things do change occasionally.
Upvotes: 1
Views: 84