Right. You would still have to parse your expression into min/max vers. And
then you can use LooseVersion for the comparison:

minVer = LooseVersion("1.0.0")
maxVer = LooseVersion("1.3")
print minVer <= LooseVersion("1.2.5b") < maxVer
# True

Are you looking for something that handles the parsing of the range format
and the operators for you?



On Thu, Oct 9, 2014 at 8:20 AM, Marcus Ottosson <[email protected]>
wrote:

> But for what you are asking, have you seen the StrictVersion and
> LooseVersion classes available in distutils?
>
> Yeah, but they don’t handle ranges and they’re essentially the equivalent
> of comparing plain tuples, aside from the alpha/beta extras.
>
> assert (1, 0, 5) > (1, 0, 4)
>
> ​
>
> On 8 October 2014 19:31, Justin Israel <[email protected]> wrote:
>
>> I'm actually getting into this area a bit for some work related to env
>> and package management. But for what you are asking, have you seen the
>> StrictVersion and LooseVersion classes available in distutils?
>>
>> http://epydoc.sourceforge.net/stdlib/distutils.version.Version-class.html
>>
>> You can instantiate those with your version strings and compare them. I
>> use those in various code that needs to confirm min versions of available
>> libs
>>  On 9/10/2014 6:17 AM, "Marcus Ottosson" <[email protected]> wrote:
>>
>>> Hi guys,
>>>
>>> I’m looking for a method of evaluating the version of a Python object
>>> and comparing it with another.
>>>
>>> The object may have a range of versions, such as “Anything above 1.0,
>>> but below 1.3.1” whereas the comparison version is fixed, such as “1.0.3”
>>>
>>> The object may look something like this:
>>>
>>> class MyObject(object):
>>>     requires = "mylibrary>=1.0.0, <1.3"
>>>
>>> Whereas a function would compare the *requirement* with a fixed
>>> version, like this:
>>>
>>> assert is_compatible(MyObject.requires, (1, 0, 6)) is True
>>>
>>> This syntax is from the requirements.txt-style of syntaxes and is the
>>> one used with Python libraries in general. I implemented an example of this
>>> here:
>>> https://gist.github.com/mottosso/f4cb1c636fae3fc63ab0
>>>
>>> Another syntax I’m interested in trying was the Rez syntax, but they
>>> seem to fulfil much of the same requirements.
>>> http://nerdvegas.github.io/rez/#versioning
>>>
>>> Have anyone had experience with this sort of versioning? How are you
>>> dealing with this currently? What issues have you encountered?
>>>
>>> Best,
>>> Marcus
>>> ​
>>> --
>>> *Marcus Ottosson*
>>> [email protected]
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODaKuESgGtsc48rNVWmFQc67WkHCoO2KTETTpMTqM7SQA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODaKuESgGtsc48rNVWmFQc67WkHCoO2KTETTpMTqM7SQA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3h%2Bm-Kny_YELm6JjQcJY4X4QK-wwOkXB8a8ijVTN%3DZQg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3h%2Bm-Kny_YELm6JjQcJY4X4QK-wwOkXB8a8ijVTN%3DZQg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> *Marcus Ottosson*
> [email protected]
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAL8Bj1-XfeJzEBF3kdMg-sPK1kYFfBkaicUJVvASenkQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAL8Bj1-XfeJzEBF3kdMg-sPK1kYFfBkaicUJVvASenkQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1eWWXjC86LXPtJ1wvzYMHu96Dn036mPUO9V_wSiD6v8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to