I've produced a python egg using setuptools and would like to access it's metadata at runtime. I currently got working this:
import pkg_resources
dist = pkg_resources.get_distribution("my_project")
print(dist.version)
but this would probably work incorrectly if I had multiple versions of the same egg installed. And if I have both installed egg and development version, then running this code from development version would pick up version of the installed egg.
So, how do I get metadata for my egg not some random matching egg installed on my system?