On Fri, 10 Jul 2009 15:58:32 +0300, Marius Gedminas <[email protected]> wrote:
What do people use to avoid repeating the version number both in the
setup.py as well as in application/library code, when the
application/library wants to know its own version number?

I've seen several options:

 1) put __version__ = '4.2' in yourpackage/__init__.py, have setup.py
    do from yourpackage import __version__ and pass that to setup()

 2) put __version__ = '4.2' in yourpackage/__init__.py, have setup.py
    execfile(os.path.join(os.path.dirname(__file__), 'src', 'yourpackage',
                          '__init__.py'), d), then use d['__version__']

 3) put a file called version.txt in yourpackage/, have setup.py read
    it, make sure it's included in MANIFEST.in

 4) I don't recall actually ever seeing this one, but it should be
    possible to use pkg_resources to query the version of yourpackage
    (downside: if you're running from a source checkout without
    installing, you won't get the right version number)


There was some discussion of this here a couple months ago:

http://mail.python.org/pipermail/distutils-sig/2009-May/011913.html

Jean-Paul
_______________________________________________
Distutils-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to