[Distutils] Single version number
Marius Gedminas
marius at pov.lt
Fri Jul 10 14:58:32 CEST 2009
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)
Marius Gedminas
--
In order to get a loan you must first prove you don't need it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20090710/0e928f39/attachment.pgp>
More information about the Distutils-SIG
mailing list