Until something better comes along, I’ve uploaded a refined version of the
example above on GitHub, along with documentation and installation via
pip/PyPI, licensed under MIT, available here:

   - https://github.com/mottosso/iscompatible
   - http://iscompatible.readthedocs.org

I adapted the documentation to include the same requirements as the Rez
example, posted above, so we can compare between them.
Basic usage

$ pip install iscompatible
$ python

>>> from iscompatible import iscompatible>>> iscompatible("foo>=5", (5, 6, 
>>> 1))True>>> iscompatible("foo>=5.6.1, <5.7", (5, 0, 0))False>>> MyPlugin = 
>>> type("MyPlugin", (), {'version': (5, 6, 1)})>>> iscompatible("foo==5.6.1", 
>>> MyPlugin.version)True

Best,
Marcus
​

On 9 October 2014 08:30, Marcus Ottosson <[email protected]> wrote:

> Here's a little more details regarding the specific requirements I'm
> looking for.
> https://groups.google.com/forum/#!topic/pyblish/qCgYvlIi3WE
>
> On 9 October 2014 08:21, Marcus Ottosson <[email protected]> wrote:
>
>> Chad, are you familiar with the requirements.txt
>> <https://pip.readthedocs.org/en/1.1/requirements.html> syntax? Would it
>> be possible to provide a brief overview of the differences between it and
>> the Rez syntax, illustrated here
>> <http://nerdvegas.github.io/rez/#versioning>?
>>
>> On 9 October 2014 06:56, Marcus Ottosson <[email protected]> wrote:
>>
>>> Are you looking for something that handles the parsing of the range
>>> format and the operators for you?
>>>
>>> Precisely. And it doesn’t have to be in requirements.txt format either,
>>> any scheme that handles ranges should work equally fine. I rolled my own
>>> here, and that’s fine, but if there is something already out there then I’d
>>> like to know and possibly use it instead of an ad-hoc solution. In fact,
>>> I'm expecting someone to say something along the lines of "Have a look at
>>> distutils.IsCompatible"
>>>
>>> In case it helps, the versioning module of Rez will soon become its own
>>> independent module that can be installed via pip/pypi.
>>>
>>> Yes, that would help. :) The fact that you guys are rolling your own,
>>> and that it’s enough of an effort to offer up as an individual package, is
>>> to me an indicator that there isn’t anything already out there that does
>>> this. Particularly considering that Rez has been around for years and I’m
>>> sure you must have been through the same treasure hunt as I am today.
>>>
>>> I did try to dig out the versioning mechanism a while back but couldn’t
>>> find it. Do you have any pointers as to where I should start looking? Which
>>> branch, for instance?
>>>
>>> Best,
>>> Marcus
>>> ​
>>>
>>> On 8 October 2014 23:44, Chad Dombrova <[email protected]> wrote:
>>>
>>>> In case it helps, the versioning module of Rez will soon become its own
>>>> independent module that can be installed via pip/pypi.
>>>>
>>>> Sent from my iPhone
>>>>
>>>> On Oct 8, 2014, at 1:17 PM, 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/84CE8E4F-DCFC-49E0-BCFE-78F1575ECE69%40gmail.com
>>>> <https://groups.google.com/d/msgid/python_inside_maya/84CE8E4F-DCFC-49E0-BCFE-78F1575ECE69%40gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> --
>>> *Marcus Ottosson*
>>> [email protected]
>>>
>>
>>
>>
>> --
>> *Marcus Ottosson*
>> [email protected]
>>
>
>
>
> --
> *Marcus Ottosson*
> [email protected]
>



-- 
*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/CAFRtmOAPS21my5p4pLf%2BxBc41VPPnYchO6V6G5EmnveOxPXcvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to