[Distutils] Requirent specifiers specified? :)

Jim Fulton jim at zope.com
Thu Jun 22 22:08:28 CEST 2006

```On Jun 22, 2006, at 3:44 PM, Phillip J. Eby wrote:

> At 03:20 PM 6/22/2006 -0400, Jim Fulton wrote:
>
>>> The implementation scans from left to right until it's *sure* that
>>> the version is either accepted or rejected.  Each condition is a
>>> point, a bound, or a point and a bound.  If the version matches the
>>> "point" part of condition, it's an exact match and you are *sure*
>>> of an accept, unless it's a "!=", in which case you're *sure* it's
>>> a reject.
>>>
>>> If the version falls below an upper bound (< or <=), you are also
>>> *sure* that it's accepted.  If it is above an upper bound, it is
>>> *tentatively* rejected.
>>
>> So given:    >1, <3, >5, <7
>> You are sure that 4 is accepted?
>
> Scanning left to right, >1 is a lower bound and 4 is above it, so
> that's a tentative accept.  Next we see <3, and it is an upper
> bound, and we fall below it, so it is a sure accept at that point,
> and we stop scanning.

Huh? 4 is below 3?

>
>> Given:  <2, <5
>> Is 3 accepted or rejected?
>
> <2, upper bound, 3 is above, tentative reject.  <5, upper bound, 3
> is below it, sure accept.  (Intuitively -- at least for me -- <5 is
> paired with >-infinity here.)

OK.  I think that many people would find this non-obvious.

>
>>> If the version falls below a lower bound (> or >=), you are *sure*
>>> that it's rejected.  If it is above a lower bound, it is
>>> *tentatively* accepted.
>>
>> So given:    >1, <3, >5, <7
>> You are sure that 2 is rejected?
>
> >1, lower bound, 2 is above, tentative accept.  <3, upper bound, 2
> is below, sure accept, scanning stops.

Ah, so in your explanation above, "f the version falls below a lower
bound"
only applies to a scanning position.  OK, that clarifies this case.

>
>>> A simple state machine is used to implement this:
>>>
>>> state_machine = {
>>>     #       =><
>>>     '<' :  '--T',
>>>     '<=':  'T-T',
>>>     '>' :  'F+F',
>>>     '>=':  'T+F',
>>>     '==':  'T..',
>>>     '!=':  'F++',
>>> }
>>>
>>> cmp() is used to determine whether the version is =, >, or < than
>>> the condition's version, and the appropriate row and column is
>>> pulled from the above table.  "T" means "sure accept", "F" means
>>> "sure reject", "+" means "tentative accept", and "-" means
>>> "tentative reject".  ("." means "don't care".)  The state machine
>>> simply compares versions until its sure or there are no more to
>>> compare.
>>
>> I don't understand the meaning of the values in the dictionary above.
>> Do the character positions reflect states somehow?
>
> It's a truth table: the rows are condition operators, and the
> columns are cmp() results.  It is simply a transcription of the
> rules about points and bounds that I spelled out verbally, reduced
> to a table lookup on the condition and the comparison results.

OK, than makes sense.  So, with the requirement: >1, <3, >5, <7
So let's see, with 4, we get +-F and we reject it.  OK, that makes
sense.

The state machine helps a lot.   My question is now answered.

I think that the fact that you need to understand a non-trivial
algorithm
with a state machine to understand how non-trivial specifications are
interpreted is a problem.  Maybe it's enough to tell people "don't
use complex specifications", but maybe it would be better to use a
simpler system.

Jim

--
Jim Fulton			mailto:jim at zope.com		Python Powered!
CTO 				(540) 361-1714			http://www.python.org
Zope Corporation	http://www.zope.com		http://www.zope.org

```