[Distutils] Single version number
Barry Warsaw
barry at python.org
Fri Jul 10 20:15:55 CEST 2009
On Jul 10, 2009, at 2:07 PM, P.J. Eby wrote:
> At 09:24 AM 7/10/2009 -0400, Barry Warsaw wrote:
>> On Jul 10, 2009, at 8:58 AM, Marius Gedminas 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()
>>
>> This is generally what I do and it seems to work pretty well for me.
>> I remember talking with Gary Poster about some problems with this,
>> related to our open source lazr packages, but I don't recall the
>> details.
>
> You'll have problems with this in the case where your __init__.py
> imports any of your dependencies (directly or indirectly), since it
> will effectively mean your setup.py will need its dependencies
> installed before it even says what they are. ;-)
>
> In such cases, putting a separate version.py or version.txt in the
> package, and execfile-ing it from setup.py is a better choice.
>
> Personally, I don't even bother putting version info in the package
> code; that's what pkg_resources is for. ;-)
Gotcha. I generally don't put /anything/ except __version__ in my top
level package __init__.py, but this is good to keep in mind. Still, I
should probably be using pkg_resources instead.
Thanks,
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 832 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20090710/99fd951a/attachment.pgp>
More information about the Distutils-SIG
mailing list