[TriZPUG] Reference The Current Version Of Your Python Egg In Your Modules

Joseph S. Tate dragonstrider at gmail.com
Fri Jan 24 09:13:32 CET 2014


I do something similar, I don't know of a way to read the package version
from setuptools, though it's likely there somewhere.

I usually have a 'version.py' file that contains "VERSION="1.0.3r9" (or
whatever).

Then in my setup.py I run "execfile(os.path.join('PKGNAME',
'version.py'))". Then VERSION is available locally. Where I need to use it
in code, I'll from pkg.version import VERSION.


On Thu, Jan 23, 2014 at 9:29 PM, Philip Semanchuk <philip at semanchuk.com>wrote:

>
> On Jan 23, 2014, at 7:40 PM, Josh Johnson wrote:
>
> > So I've got an app. It's packaged as an egg. I want to do stuff like
> write
> > to the log file "starting MyApp version 1.2.3332". What's the best way to
> > store that information?
> >
> > In the past I've set a 'constant' at the root of the egg, something like
> > APPVERSION, and I reference it as MyApp.APPVERSION. I just have to
> remember
> > to keep it in line with the version in setup.py.
> >
> > Is there a better way?
>
> Hi Josh,
> I dunno if this is quite what you are looking for, but my app packages
> always contain a file called VERSION which contains (surprisingly) the
> version string and nothing else. That's the only place the version resides;
> all other code reads it from there. For instance, I have this in my
> setup.py --
>
> VERSION = open("VERSION").read().strip()
>
>
> That value also gets compiled into my C code via a .h file (which is
> written by setup.py), it's used by the code that builds my tarballs, etc.
>
> This also has the advantage of putting the version in a discrete, clearly
> marked file so that someone can see the package version even if its
> directory name (which typically contains the version info) gets changed.
>
> Hope this helps,
> Philip
>
> _______________________________________________
> TriZPUG mailing list
> TriZPUG at python.org
> https://mail.python.org/mailman/listinfo/trizpug
> http://trizpug.org is the Triangle Zope and Python Users Group
>



-- 
Joseph Tate
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/trizpug/attachments/20140124/49c98192/attachment.html>


More information about the TriZPUG mailing list