detecting version match/mismatch between core/plugins

John Arbash Meinel john at arbash-meinel.com
Tue Aug 15 15:26:31 BST 2006


Aaron Bentley wrote:
> Wichmann, Mats D wrote:
>>>>> It would be easy enough to have a version number in the plugin and
>>>>> fail to load it if it's too low or high, it would just 
>>>>> require someone to write the code :) 
>>>> I think its up to the plugin to do that... keeps them more like regular
>>>> python files.
>>>
>>> Haven't followed up to last few comments, but I
>>> think I agree that it's the plugin that needs to
>>> have most of the "smarts".
> 
> Here's what I'm considering adding to bzrtools:
> 
> import bzrlib
> 
> 
> __version__ = '0.9'
> 
> 
> def check_bzrlib_version(desired_str):
>     """Check that bzrlib is compatible.
> 
>     If version is < bzrtools version, assume incompatible.
>     If version == bzrtools version, assume completely compatible
>     If version == bzrtools version + 1, assume compatible, with deprecations
>     Otherwise, assume incompatible.
>     """
>     desired = tuple([int(num) for num in desired_str.split('.')])
>     desired_plus = (desired[0], desired[1]+1)
>     bzrlib_version = [int(num) for num in bzrlib.__version__.split('.')[:2]]

^-- bzrlib provides 'version_info' which is already a tuple. It is
pretty common to exist, so I would recommend you use
bzrlib.version_info[:2] rather than splitting the string.

Otherwise it seems reasonable.

John
=:->


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060815/52ab48e9/attachment.pgp 


More information about the bazaar mailing list