[Distutils] RFC : Version comparison
Trent Mick
trentm at gmail.com
Mon Apr 27 18:36:24 CEST 2009
>> Can a constructor which takes each part of the version data
>> as a separate object be added?
>
> Sounds good, I'd be in favor of making RationalVersion using explicit
> version bits,
> and having some kind of function:
>
> str2version(somestring) -> RationalVersion instance
Or we could have:
RationalVersion(...version bits...)
RationalVersion.from_string(s) # this is a @classmethod
> I have pushed the prototype in a bitbucket project so everyone can
> work it out (just join the project)
>
> http://bitbucket.org/tarek/distutilsversion/
Thanks for putting this up.
If we provide a way to construct a RationalVersion with version bits,
then we need to discuss what those "version bits" look like. Currently
the internal tuple data structure (`self.info`) looks like this (from
verlib.py's description of the 'f' marker used to help with sort
ordering, http://bitbucket.org/tarek/distutilsversion/src/cc93f5e1df3f/verlib.py#cl-163):
# A marker used in the second and third parts of the `info` tuple, for
# versions that don't have those segments, to sort properly. A example
# of versions in sort order ('highest' last):
# 1.0b1 ((1,0), ('b',1), ('f',))
# 1.0.dev345 ((1,0), ('f',), ('dev', 345))
# 1.0 ((1,0), ('f',), ('f',))
# 1.0.post345 ((1,0), ('f',), ('post', 345))
# ^ ^
# 'f' < 'b' -------------/ |
# |
# 'dev' < 'f' < 'post' -----------/
# Other letters would do, bug 'f' for 'final' is kind of nice.
Is this what we would want the constructor to take?
RationalVersion( (1,0), ('b', 1) ) # 1.0b1
RationalVersion( (1,0), ('f',), ('post', 345) ) # 1.0.post345
It seems a little too low-level. We could allow something a little nicer:
RationalVersion( (1, 0, 'b', 1) ) # 1.0b1
RationalVersion( (1, 0, 'post', 345) ) # 1.0.post345
If we did this, then we'd probably want these attributes on RationalVersion:
>>> v = RationalVersion((1,0,'b',1))
>>> str(v)
'1.0b1'
>>> v.info
(1, 0, 'b', 1)
>>> v._cmp_info # use for comparison
((1, 0), ('b', 1), ('f',))
Thoughts?
Trent
--
Trent Mick
trentm at gmail.com
More information about the Distutils-SIG
mailing list