Commit 84e38e9
authored
Add PEP 440 version comparison for pypi scheme (#26)
* Add PEP 440 version comparison for pypi scheme
parseDotSeparated silently dropped non-numeric segment suffixes, so
5.2b1 parsed as 5.0.0 and every PEP 440 prerelease form collapsed to
the release. There was also no pypi case in CompareWithScheme, and
Range.Contains used generic comparison regardless of scheme.
Add a PEP 440 comparator covering epoch, release padding, pre/post/dev
ordering, spelling and separator normalization, and local version
segments. Store the scheme on Range so Contains can dispatch to it.
Split trailing letter suffixes in parseDotSeparated instead of
discarding them.
Fixes #24
* Address review findings on PEP 440 comparison
Range.IsEmpty used generic comparison, so a pypi range like
[1.0.dev1, 1.0a1) reported empty and serialized as vers:pypi/.
Use the scheme comparator there too.
Scheme was not set on ranges from the wildcard path, ParseNative
sub-parsers that bypass parseConstraints (including pypi ~=), or
the results of Union/Intersect/Exclude. Stamp it in each of those
places so Contains and IsEmpty on the result use the right rules.
Replace the 1<<30 positive-infinity sentinel in the PEP 440
comparator with explicit hasPre/hasPost/hasDev flags. Numeric
components are unbounded in PEP 440 and a large enough dev number
sorted the wrong side of an absent one.
* Thread scheme comparator through interval algebra; compare PEP 440 numerics as strings
Range.Intersect and Range.Union built results using generic
comparison, so intersecting >=1.0.dev1 with <1.0a1 under pypi
discarded the resulting interval as empty. Add cmp-taking variants
of Interval.Intersect/Union/Overlaps/Adjacent and mergeIntervals,
and have Range.Intersect/Union use the scheme comparator.
Store PEP 440 numeric components (epoch, release segments, pre/post/
dev numbers, numeric local segments) as digit strings and compare
them by length then lexically. Values that overflow int no longer
collapse to zero, and large local segments stay numeric.
* Derive pypi ~= upper bound from PEP 440 release segments; use scheme equality for Union exclusions
parsePypiRange delegated ~= to the gem pessimistic algorithm, which
counts raw dots (so .dev/.post added phantom segments) and drops the
epoch. ~=1.4.dev1 produced <1.5 instead of <2, and ~=1!1.4.5 lost the
epoch on the upper bound. Add a pypi-specific handler that reads the
release segments and epoch via parsePEP440 and increments the
second-last release segment. Stop trimming trailing zeros from the
parsed release so ~=2.0.dev1 sees two segments; cmpNumStrSlice already
treats missing segments as zero so comparison is unchanged.
Range.Union intersected exclusions by string equality, so unioning
ranges that exclude 1.5 and 1.5.0 respectively dropped the exclusion
even though those are the same version under PEP 440. Compare with
the scheme comparator instead.
* Parse comma-separated pypi specifiers individually and intersect
parsePypiRange checked for a leading ~= before splitting on comma,
so ~=1.4.2,!=1.4.5 fed the whole tail into the compatible-release
handler and lost the exclusion. The comma path also rewrote parts to
pipe-separated constraints, which never re-entered ~= handling, so
>=1.0,~=1.4 treated ~=1.4 as an exact version and left the range
unbounded above.
Split on comma first, parse each part on its own (so ~= is handled
per part), and Range.Intersect the results. Comma is AND in PEP 440.
* Set pypi scheme on ~= result before intersection
parsePypiCompatibleRelease returned a Range with an empty Scheme,
relying on the ParseNative wrapper to stamp it afterwards. When ~=
was the first clause in a comma-separated set, the subsequent
Intersect ran under generic comparison and discarded intervals like
[1.0.dev1, 1.0a1) as empty. Set the scheme on the ~= result (and its
fallback) so intersection order does not matter.1 parent fa68a6c commit 84e38e9
6 files changed
Lines changed: 979 additions & 70 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
51 | 55 | | |
52 | | - | |
53 | | - | |
| 56 | + | |
| 57 | + | |
54 | 58 | | |
55 | 59 | | |
56 | | - | |
| 60 | + | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
| |||
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
70 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
71 | 79 | | |
72 | 80 | | |
73 | 81 | | |
| |||
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
79 | | - | |
| 87 | + | |
80 | 88 | | |
81 | | - | |
| 89 | + | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
85 | | - | |
| 93 | + | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
89 | 97 | | |
90 | 98 | | |
91 | 99 | | |
92 | 100 | | |
93 | | - | |
| 101 | + | |
94 | 102 | | |
95 | | - | |
| 103 | + | |
96 | 104 | | |
97 | 105 | | |
98 | 106 | | |
99 | | - | |
| 107 | + | |
100 | 108 | | |
101 | 109 | | |
102 | 110 | | |
| |||
107 | 115 | | |
108 | 116 | | |
109 | 117 | | |
110 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
111 | 123 | | |
112 | 124 | | |
113 | 125 | | |
| |||
116 | 128 | | |
117 | 129 | | |
118 | 130 | | |
119 | | - | |
| 131 | + | |
120 | 132 | | |
121 | | - | |
| 133 | + | |
122 | 134 | | |
123 | 135 | | |
124 | | - | |
| 136 | + | |
125 | 137 | | |
126 | 138 | | |
127 | 139 | | |
| |||
139 | 151 | | |
140 | 152 | | |
141 | 153 | | |
142 | | - | |
| 154 | + | |
143 | 155 | | |
144 | | - | |
| 156 | + | |
145 | 157 | | |
146 | 158 | | |
147 | | - | |
| 159 | + | |
148 | 160 | | |
149 | 161 | | |
150 | 162 | | |
| |||
164 | 176 | | |
165 | 177 | | |
166 | 178 | | |
167 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
168 | 184 | | |
169 | 185 | | |
170 | | - | |
| 186 | + | |
171 | 187 | | |
172 | 188 | | |
173 | 189 | | |
174 | 190 | | |
175 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
176 | 196 | | |
177 | 197 | | |
178 | 198 | | |
179 | | - | |
| 199 | + | |
180 | 200 | | |
181 | 201 | | |
182 | 202 | | |
183 | | - | |
| 203 | + | |
184 | 204 | | |
185 | 205 | | |
186 | 206 | | |
| |||
189 | 209 | | |
190 | 210 | | |
191 | 211 | | |
192 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
193 | 217 | | |
194 | 218 | | |
195 | | - | |
| 219 | + | |
196 | 220 | | |
197 | 221 | | |
198 | 222 | | |
199 | | - | |
| 223 | + | |
200 | 224 | | |
201 | 225 | | |
202 | 226 | | |
| |||
207 | 231 | | |
208 | 232 | | |
209 | 233 | | |
210 | | - | |
| 234 | + | |
211 | 235 | | |
212 | | - | |
| 236 | + | |
213 | 237 | | |
214 | 238 | | |
215 | | - | |
| 239 | + | |
216 | 240 | | |
217 | 241 | | |
218 | 242 | | |
| |||
226 | 250 | | |
227 | 251 | | |
228 | 252 | | |
229 | | - | |
| 253 | + | |
230 | 254 | | |
231 | | - | |
| 255 | + | |
232 | 256 | | |
233 | 257 | | |
234 | | - | |
| 258 | + | |
235 | 259 | | |
236 | 260 | | |
237 | 261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
39 | 49 | | |
40 | 50 | | |
41 | 51 | | |
42 | 52 | | |
43 | 53 | | |
44 | | - | |
| 54 | + | |
45 | 55 | | |
46 | 56 | | |
47 | 57 | | |
| |||
215 | 225 | | |
216 | 226 | | |
217 | 227 | | |
218 | | - | |
| 228 | + | |
219 | 229 | | |
220 | 230 | | |
221 | 231 | | |
| |||
226 | 236 | | |
227 | 237 | | |
228 | 238 | | |
| 239 | + | |
229 | 240 | | |
230 | 241 | | |
231 | 242 | | |
232 | 243 | | |
233 | 244 | | |
234 | 245 | | |
235 | | - | |
| 246 | + | |
236 | 247 | | |
237 | 248 | | |
238 | 249 | | |
239 | 250 | | |
240 | 251 | | |
241 | 252 | | |
242 | 253 | | |
| 254 | + | |
| 255 | + | |
243 | 256 | | |
244 | 257 | | |
245 | 258 | | |
| |||
252 | 265 | | |
253 | 266 | | |
254 | 267 | | |
255 | | - | |
| 268 | + | |
256 | 269 | | |
257 | 270 | | |
258 | 271 | | |
| |||
295 | 308 | | |
296 | 309 | | |
297 | 310 | | |
298 | | - | |
| 311 | + | |
299 | 312 | | |
300 | 313 | | |
301 | 314 | | |
| |||
572 | 585 | | |
573 | 586 | | |
574 | 587 | | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
575 | 605 | | |
576 | 606 | | |
577 | 607 | | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
| 608 | + | |
586 | 609 | | |
587 | 610 | | |
588 | 611 | | |
589 | 612 | | |
590 | 613 | | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
591 | 635 | | |
592 | 636 | | |
593 | 637 | | |
| |||
701 | 745 | | |
702 | 746 | | |
703 | 747 | | |
704 | | - | |
| 748 | + | |
705 | 749 | | |
706 | 750 | | |
707 | 751 | | |
| |||
0 commit comments