[Distutils] finding my own version with setuptools

Ashley Walsh ashleywalsh at gmail.com
Thu Nov 10 01:03:29 CET 2005

On 10/11/2005, at 2:29 AM, Ian Bicking wrote:

> Phillip J. Eby wrote:
>> At 01:55 PM 11/9/2005 +1000, Ashley Walsh wrote:
>>> Hi,
>>> Is there an easy way for a module to uses its __name__ to identify
>>> the Distribution it comes from?  I had a look through pkg_resources
>>> but I couldn't see a straight forward way to do it, so I thought I'd
>>> ask.
>>> The reason is that I want a console script log its version.
>> Well, if you know the *project* name, you can just do:
>>      pkg_resources.get_distribution("ProjectName").version
> Incidentally, I use ('%s from %s' % (dist, dist.location)) for my  
> version strings, as I find it useful to know where on disk it is  
> coming from, in addition to what version.
> -- 
> Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org

Yup, I'm also logging repr(dist) ('setuptools 0.6a7 (/Library/Python/ 
2.3/site-packages/setuptools-0.6a7-py2.3.egg)' ) of both the  
Environment and the working_set (via add_activation_listener).


More information about the Distutils-SIG mailing list