Getting app version from controllers

4 views
Skip to first unread message

cso...@gmail.com

unread,
Jan 11, 2007, 8:21:40 PM1/11/07
to pylons-discuss
How do I get the version number of my application as defined in
setup.py from within one of my controllers or templates? Is it located
somewhere in the g variable perhaps?

Thanks in advance,
Carlo

Ian Bicking

unread,
Jan 11, 2007, 9:10:30 PM1/11/07
to pylons-...@googlegroups.com
cso...@gmail.com wrote:
> How do I get the version number of my application as defined in
> setup.py from within one of my controllers or templates? Is it located
> somewhere in the g variable perhaps?

you'll have to do:

import pkg_resources
dist = pkg_resources.get_distribution('MyPackageName')

And it'll be in some attribute there, not sure what.

--
Ian Bicking | ia...@colorstudy.com | http://blog.ianbicking.org

cso...@gmail.com

unread,
Jan 12, 2007, 12:34:56 AM1/12/07
to pylons-discuss
Ian Bicking wrote:
>
> you'll have to do:
>
> import pkg_resources
> dist = pkg_resources.get_distribution('MyPackageName')
>
> And it'll be in some attribute there, not sure what.

Thanks. I fount it. It's the attribute

pkg_resources.get_distribution('MyPackageName').version

Cheers,
Carlo

Reply all
Reply to author
Forward
0 new messages