[PEAK] Accessing PKG-INFO at runtime

Phillip J. Eby pje at telecommunity.com
Fri Sep 19 23:08:55 EDT 2008

At 11:03 PM 9/18/2008, Pavel Repin wrote:
>Hi, Phillip,
>That works nice. Is there a way to derive 'MyPackageName' from the 
>available metadata on the fly instead of hard-coding the package 
>name within some python code inside the package itself?

No.  But you could certainly define a constant somewhere and import 
it everywhere else, if you're that worried about it.

>I ask because I want to keep things DRY (Don't Repeat Yourself).
>On Thu, Sep 18, 2008 at 6:49 AM, Phillip J. Eby 
><<mailto:pje at telecommunity.com>pje at telecommunity.com> wrote:
>At 01:08 AM 9/18/2008 -0700, Pavel Repin wrote:
>Is there a recommended way to obtain version information of an 
>executing application?
>For instance, if my application script wants to write a log message 
>containing its own version, I'd like to get the version info stored 
>in its PKG-INFO file.
>Hopefully, this runtime version info access method should work both 
>in developer mode for apps installed with "setup.py develop" 
>command, and when running them as eggs installed with easy_install script.
>Any ideas?
>Something like pkg_resources.require('MyProjectName')[0].version should work.
>Pavel Repin
>PEAK mailing list
>PEAK at eby-sarna.com

More information about the PEAK mailing list