[Distutils] RFC : Version comparison

P.J. Eby pje at telecommunity.com
Thu May 14 18:11:47 CEST 2009


At 10:59 AM 5/14/2009 +0200, Tarek Ziadé wrote:
>2009/5/14 P.J. Eby <pje at telecommunity.com>:
> > At 02:34 PM 5/13/2009 +0200, Tarek Ziadé wrote:
> >>
> >> Any feedback on this "dev version of post release" use case
> >
> > It looks like the 'suggest' function doesn't handle svn revisions properly
> > for conversion from setuptools versions.  Setuptools '-r###' is a
> > post-release tag, as is any alpha string alphabetically after 
> 'final'.  That
> > is, '0.4a1.r10' is actually '0.4a1.post10'.  (Notice, for example, that
> > setuptools' trunk version is '0.7a1dev-r66608'.)
> >
> > See
> > 
> http://peak.telecommunity.com/DevCenter/setuptools#specifying-your-project-s-version
> > for the full syntax; I'm a bit concerned that there may be other incorrect
> > interpretations taking place in this function.  (Notice, for 
> example, that a
> > '-' in a version number indicates a post-release, but your code is treating
> > '-' as identical to '.'.)
>
>Ok, I have changed the suggest function accordingly,
>
>
>     def test_suggest_rational_version(self):
>
>         self.assertEquals(suggest('1.0'), '1.0')
>         self.assertEquals(suggest('1.0-alpha1'), '1.0a1')
>         self.assertEquals(suggest('1.0rc2'), '1.0c2')
>         self.assertEquals(suggest('walla walla washington'), None)
>
>         # from setuptools
>         self.assertEquals(suggest('0.4a1.r10'), '0.4a1.post10')
>         self.assertEquals(suggest('0.7a1dev-r66608'), '0.7a1.dev66608')
>         self.assertEquals(suggest('0.6a9.dev-r41475'), '0.6a9.dev41475')
>         self.assertEquals(suggest('2.4preview1'), '2.4c1')
>         self.assertEquals(suggest('2.4rc1'), '2.4c1')
>         self.assertEquals(suggest('2.4pre1') , '2.4c1')

All looking pretty good, except:

>         self.assertEquals(suggest('2.1-rc2'), None)         # no suggestion

This should be equivalent to '2.1c2':

 >>> from pkg_resources import parse_version as pv
 >>> pv('2.1-rc2')==pv('2.1c2')
True



More information about the Distutils-SIG mailing list