<p>I've produced a python egg using setuptools and would like to access it's metadata at runtime. I currently got working this:</p>

<pre><code>import pkg_resources
dist = pkg_resources.get_distribution("my_project")
print(dist.version)
</code></pre>

<p>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. </p>

<p>So, how do I get metadata for <em>my</em> egg not some random matching egg installed on my system? </p>

I am somewhat new to Python as well, but from what I understand:
Although you can install multiple versions of the "same" egg (having the same name), only one of them will be available to any particular piece of code at runtime (based on your discovery method).  So if your egg is the one calling this code, it must have already been selected as
the
version of
```
my_project
```
for this code, and your access will be to your own version.