py-rattler 0.22.0__cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py_rattler-0.22.0.dist-info/METADATA +208 -0
- py_rattler-0.22.0.dist-info/RECORD +68 -0
- py_rattler-0.22.0.dist-info/WHEEL +4 -0
- rattler/__init__.py +114 -0
- rattler/channel/__init__.py +5 -0
- rattler/channel/channel.py +94 -0
- rattler/channel/channel_config.py +43 -0
- rattler/channel/channel_priority.py +14 -0
- rattler/exceptions.py +120 -0
- rattler/explicit_environment/__init__.py +3 -0
- rattler/explicit_environment/environment.py +69 -0
- rattler/index/__init__.py +3 -0
- rattler/index/index.py +112 -0
- rattler/install/__init__.py +3 -0
- rattler/install/installer.py +96 -0
- rattler/lock/__init__.py +23 -0
- rattler/lock/channel.py +52 -0
- rattler/lock/environment.py +213 -0
- rattler/lock/hash.py +33 -0
- rattler/lock/lock_file.py +118 -0
- rattler/lock/package.py +302 -0
- rattler/match_spec/__init__.py +4 -0
- rattler/match_spec/match_spec.py +294 -0
- rattler/match_spec/nameless_match_spec.py +185 -0
- rattler/networking/__init__.py +21 -0
- rattler/networking/client.py +74 -0
- rattler/networking/fetch_repo_data.py +103 -0
- rattler/networking/middleware.py +234 -0
- rattler/package/__init__.py +26 -0
- rattler/package/about_json.py +329 -0
- rattler/package/index_json.py +437 -0
- rattler/package/no_arch_type.py +142 -0
- rattler/package/package_name.py +204 -0
- rattler/package/package_name_matcher.py +81 -0
- rattler/package/paths_json.py +696 -0
- rattler/package/run_exports_json.py +268 -0
- rattler/package_streaming/__init__.py +26 -0
- rattler/platform/__init__.py +4 -0
- rattler/platform/arch.py +59 -0
- rattler/platform/platform.py +217 -0
- rattler/prefix/__init__.py +4 -0
- rattler/prefix/prefix_paths.py +442 -0
- rattler/prefix/prefix_record.py +234 -0
- rattler/pty/__init__.py +25 -0
- rattler/pty/pty_process.py +391 -0
- rattler/pty/pty_session.py +241 -0
- rattler/py.typed +0 -0
- rattler/rattler.abi3.so +0 -0
- rattler/repo_data/__init__.py +19 -0
- rattler/repo_data/gateway.py +337 -0
- rattler/repo_data/package_record.py +938 -0
- rattler/repo_data/patch_instructions.py +22 -0
- rattler/repo_data/record.py +164 -0
- rattler/repo_data/repo_data.py +74 -0
- rattler/repo_data/source.py +85 -0
- rattler/repo_data/sparse.py +356 -0
- rattler/shell/__init__.py +3 -0
- rattler/shell/shell.py +134 -0
- rattler/solver/__init__.py +3 -0
- rattler/solver/solver.py +220 -0
- rattler/utils/rattler_version.py +19 -0
- rattler/version/__init__.py +5 -0
- rattler/version/version.py +591 -0
- rattler/version/version_spec.py +184 -0
- rattler/version/with_source.py +80 -0
- rattler/virtual_package/__init__.py +4 -0
- rattler/virtual_package/generic.py +136 -0
- rattler/virtual_package/virtual_package.py +201 -0
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import List, Optional, Tuple, Union
|
|
4
|
+
|
|
5
|
+
from rattler.rattler import PyVersion, InvalidVersionError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Version:
|
|
9
|
+
"""
|
|
10
|
+
This class implements an order relation between version strings.
|
|
11
|
+
Version strings can contain the usual alphanumeric characters
|
|
12
|
+
(A-Za-z0-9), separated into segments by dots and underscores.
|
|
13
|
+
Empty segments (i.e. two consecutive dots, a leading/trailing
|
|
14
|
+
underscore) are not permitted. An optional epoch number - an
|
|
15
|
+
integer followed by '!' - can precede the actual version string
|
|
16
|
+
(this is useful to indicate a change in the versioning scheme itself).
|
|
17
|
+
Version comparison is case-insensitive.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
_version: PyVersion
|
|
21
|
+
|
|
22
|
+
def __init__(self, version: str) -> None:
|
|
23
|
+
if isinstance(version, str):
|
|
24
|
+
self._version = PyVersion(version)
|
|
25
|
+
else:
|
|
26
|
+
raise TypeError(
|
|
27
|
+
f"Version constructor received unsupported type {type(version).__name__!r} for the `version` parameter"
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def _from_py_version(cls, py_version: PyVersion) -> Version:
|
|
32
|
+
"""Construct Rattler version from FFI PyVersion object."""
|
|
33
|
+
version = cls.__new__(cls)
|
|
34
|
+
version._version = py_version
|
|
35
|
+
return version
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def epoch(self) -> Optional[str]:
|
|
39
|
+
"""
|
|
40
|
+
Gets the epoch of the version or `None` if the epoch was not defined.
|
|
41
|
+
|
|
42
|
+
Examples
|
|
43
|
+
--------
|
|
44
|
+
```python
|
|
45
|
+
>>> v = Version('2!1.0')
|
|
46
|
+
>>> v.epoch
|
|
47
|
+
2
|
|
48
|
+
>>>
|
|
49
|
+
```
|
|
50
|
+
"""
|
|
51
|
+
return self._version.epoch()
|
|
52
|
+
|
|
53
|
+
def bump_major(self) -> Version:
|
|
54
|
+
"""
|
|
55
|
+
Returns a new version where the major segment of this version has
|
|
56
|
+
been bumped.
|
|
57
|
+
|
|
58
|
+
Examples
|
|
59
|
+
--------
|
|
60
|
+
```python
|
|
61
|
+
>>> v = Version('1.0')
|
|
62
|
+
>>> v.bump_major()
|
|
63
|
+
Version("2.0")
|
|
64
|
+
>>> v = Version('9d')
|
|
65
|
+
>>> v.bump_major()
|
|
66
|
+
Version("10a")
|
|
67
|
+
>>>
|
|
68
|
+
```
|
|
69
|
+
"""
|
|
70
|
+
return Version._from_py_version(self._version.bump_major())
|
|
71
|
+
|
|
72
|
+
def bump_minor(self) -> Version:
|
|
73
|
+
"""
|
|
74
|
+
Returns a new version where the minor segment of this version has
|
|
75
|
+
been bumped.
|
|
76
|
+
|
|
77
|
+
Examples
|
|
78
|
+
--------
|
|
79
|
+
```python
|
|
80
|
+
>>> v = Version('1.0')
|
|
81
|
+
>>> v.bump_minor()
|
|
82
|
+
Version("1.1")
|
|
83
|
+
>>>
|
|
84
|
+
>>> Version("1").bump_minor()
|
|
85
|
+
Version("1.1")
|
|
86
|
+
>>>
|
|
87
|
+
```
|
|
88
|
+
"""
|
|
89
|
+
return Version._from_py_version(self._version.bump_minor())
|
|
90
|
+
|
|
91
|
+
def bump_patch(self) -> Version:
|
|
92
|
+
"""
|
|
93
|
+
Returns a new version where the patch segment of this version has
|
|
94
|
+
been bumped.
|
|
95
|
+
|
|
96
|
+
Examples
|
|
97
|
+
--------
|
|
98
|
+
```python
|
|
99
|
+
>>> v = Version('1.0.5')
|
|
100
|
+
>>> v.bump_patch()
|
|
101
|
+
Version("1.0.6")
|
|
102
|
+
>>> v = Version('1.1.1e')
|
|
103
|
+
>>> v.bump_patch()
|
|
104
|
+
Version("1.1.2a")
|
|
105
|
+
>>>
|
|
106
|
+
>>> Version("1.5").bump_patch()
|
|
107
|
+
Version("1.5.1")
|
|
108
|
+
>>>
|
|
109
|
+
```
|
|
110
|
+
"""
|
|
111
|
+
return Version._from_py_version(self._version.bump_patch())
|
|
112
|
+
|
|
113
|
+
def bump_last(self) -> Version:
|
|
114
|
+
"""
|
|
115
|
+
Returns a new version where the last segment of this version has
|
|
116
|
+
been bumped.
|
|
117
|
+
|
|
118
|
+
Examples
|
|
119
|
+
--------
|
|
120
|
+
```python
|
|
121
|
+
>>> v = Version('1.0')
|
|
122
|
+
>>> v.bump_last()
|
|
123
|
+
Version("1.1")
|
|
124
|
+
>>>
|
|
125
|
+
```
|
|
126
|
+
"""
|
|
127
|
+
return Version._from_py_version(self._version.bump_last())
|
|
128
|
+
|
|
129
|
+
def bump_segment(self, index: int) -> Version:
|
|
130
|
+
"""
|
|
131
|
+
Returns a new version where the last segment of this version has
|
|
132
|
+
been bumped.
|
|
133
|
+
|
|
134
|
+
Examples
|
|
135
|
+
--------
|
|
136
|
+
```python
|
|
137
|
+
>>> v = Version('1.0')
|
|
138
|
+
>>> v.bump_segment(index=1)
|
|
139
|
+
Version("1.1")
|
|
140
|
+
>>>
|
|
141
|
+
>>> Version("1.5").bump_segment(-5) # doctest: +IGNORE_EXCEPTION_DETAIL
|
|
142
|
+
Traceback (most recent call last):
|
|
143
|
+
exceptions.VersionBumpException
|
|
144
|
+
>>> Version("1.5").bump_segment(5)
|
|
145
|
+
Version("1.5.0.0.0.1")
|
|
146
|
+
>>>
|
|
147
|
+
```
|
|
148
|
+
"""
|
|
149
|
+
return Version._from_py_version(self._version.bump_segment(index))
|
|
150
|
+
|
|
151
|
+
def with_alpha(self) -> Version:
|
|
152
|
+
"""
|
|
153
|
+
Returns a new version where the last segment of this version has
|
|
154
|
+
been bumped with an alpha character. If the last segment contains a
|
|
155
|
+
character, nothing is added.
|
|
156
|
+
|
|
157
|
+
Examples
|
|
158
|
+
--------
|
|
159
|
+
```python
|
|
160
|
+
>>> v = Version('1.0')
|
|
161
|
+
>>> v.with_alpha()
|
|
162
|
+
Version("1.0.0a0")
|
|
163
|
+
>>> v = Version('1.0.f')
|
|
164
|
+
>>> v.with_alpha()
|
|
165
|
+
Version("1.0.f")
|
|
166
|
+
>>>
|
|
167
|
+
```
|
|
168
|
+
"""
|
|
169
|
+
return Version._from_py_version(self._version.with_alpha())
|
|
170
|
+
|
|
171
|
+
def remove_local(self) -> Version:
|
|
172
|
+
"""
|
|
173
|
+
Returns a new version where the local segment of the version has been removed.
|
|
174
|
+
Leaves the version unchanged if it does not have a local segment.
|
|
175
|
+
|
|
176
|
+
Examples
|
|
177
|
+
--------
|
|
178
|
+
```python
|
|
179
|
+
>>> v = Version('1.0+3.4')
|
|
180
|
+
>>> v.remove_local()
|
|
181
|
+
Version("1.0")
|
|
182
|
+
>>> v = Version('1.0')
|
|
183
|
+
>>> v.remove_local()
|
|
184
|
+
Version("1.0")
|
|
185
|
+
>>>
|
|
186
|
+
```
|
|
187
|
+
"""
|
|
188
|
+
return Version._from_py_version(self._version.remove_local())
|
|
189
|
+
|
|
190
|
+
def extend_to_length(self, length: int) -> Version:
|
|
191
|
+
"""
|
|
192
|
+
Returns a new version that is extended with `0s` to the specified length.
|
|
193
|
+
|
|
194
|
+
Examples
|
|
195
|
+
--------
|
|
196
|
+
```python
|
|
197
|
+
>>> v = Version('1')
|
|
198
|
+
>>> v.extend_to_length(3)
|
|
199
|
+
Version("1.0.0")
|
|
200
|
+
>>> v = Version('4!1.2+3.4')
|
|
201
|
+
>>> v.extend_to_length(4)
|
|
202
|
+
Version("4!1.2.0.0+3.4")
|
|
203
|
+
>>>
|
|
204
|
+
```
|
|
205
|
+
"""
|
|
206
|
+
return Version._from_py_version(self._version.extend_to_length(length))
|
|
207
|
+
|
|
208
|
+
@property
|
|
209
|
+
def has_local(self) -> bool:
|
|
210
|
+
"""
|
|
211
|
+
Returns true if this version has a local segment defined.
|
|
212
|
+
The local part of a version is the part behind the (optional) `+`.
|
|
213
|
+
|
|
214
|
+
Examples
|
|
215
|
+
--------
|
|
216
|
+
```python
|
|
217
|
+
>>> v = Version('1.0+3.2-alpha0')
|
|
218
|
+
>>> v.has_local
|
|
219
|
+
True
|
|
220
|
+
>>> v2 = Version('1.0')
|
|
221
|
+
>>> v2.has_local
|
|
222
|
+
False
|
|
223
|
+
>>>
|
|
224
|
+
```
|
|
225
|
+
"""
|
|
226
|
+
return self._version.has_local()
|
|
227
|
+
|
|
228
|
+
def segments(self) -> List[List[Union[str, int]]]:
|
|
229
|
+
"""
|
|
230
|
+
Returns a list of segments of the version. It does not contain
|
|
231
|
+
the local segment of the version.
|
|
232
|
+
|
|
233
|
+
Examples
|
|
234
|
+
--------
|
|
235
|
+
```python
|
|
236
|
+
>>> v = Version("1.2dev.3-alpha4.5+6.8")
|
|
237
|
+
>>> v.segments()
|
|
238
|
+
[[1], [2, 'dev'], [3], [0, 'alpha', 4], [5]]
|
|
239
|
+
>>>
|
|
240
|
+
```
|
|
241
|
+
"""
|
|
242
|
+
return self._version.segments()
|
|
243
|
+
|
|
244
|
+
def local_segments(self) -> List[List[Union[str, int]]]:
|
|
245
|
+
"""
|
|
246
|
+
Returns a list of local segments of the version. It does not
|
|
247
|
+
contain the non-local segment of the version.
|
|
248
|
+
|
|
249
|
+
Examples
|
|
250
|
+
--------
|
|
251
|
+
```python
|
|
252
|
+
>>> v = Version("1.2dev.3-alpha4.5+6.8")
|
|
253
|
+
>>> v.local_segments()
|
|
254
|
+
[[6], [8]]
|
|
255
|
+
>>>
|
|
256
|
+
```
|
|
257
|
+
"""
|
|
258
|
+
return self._version.local_segments()
|
|
259
|
+
|
|
260
|
+
def as_major_minor(self) -> Optional[Tuple[int, int]]:
|
|
261
|
+
"""
|
|
262
|
+
Returns the major and minor segments from the version.
|
|
263
|
+
Requires a minimum of 2 segments in version to be split
|
|
264
|
+
into major and minor, returns `None` otherwise.
|
|
265
|
+
|
|
266
|
+
Examples
|
|
267
|
+
--------
|
|
268
|
+
```python
|
|
269
|
+
>>> v = Version('1.0')
|
|
270
|
+
>>> v.as_major_minor()
|
|
271
|
+
(1, 0)
|
|
272
|
+
>>>
|
|
273
|
+
```
|
|
274
|
+
"""
|
|
275
|
+
return self._version.as_major_minor()
|
|
276
|
+
|
|
277
|
+
@property
|
|
278
|
+
def is_dev(self) -> bool:
|
|
279
|
+
"""
|
|
280
|
+
Returns true if the version contains a component name "dev",
|
|
281
|
+
dev versions are sorted before non-dev version.
|
|
282
|
+
|
|
283
|
+
Examples
|
|
284
|
+
--------
|
|
285
|
+
```python
|
|
286
|
+
>>> v = Version('1.0.1dev')
|
|
287
|
+
>>> v.is_dev
|
|
288
|
+
True
|
|
289
|
+
>>> v_non_dev = Version('1.0.1')
|
|
290
|
+
>>> v_non_dev >= v
|
|
291
|
+
True
|
|
292
|
+
>>>
|
|
293
|
+
```
|
|
294
|
+
"""
|
|
295
|
+
return self._version.is_dev()
|
|
296
|
+
|
|
297
|
+
def starts_with(self, other: Version) -> bool:
|
|
298
|
+
"""
|
|
299
|
+
Checks if the version and local segment start
|
|
300
|
+
same as other version.
|
|
301
|
+
|
|
302
|
+
Examples
|
|
303
|
+
--------
|
|
304
|
+
```python
|
|
305
|
+
>>> v1 = Version('1.0.1')
|
|
306
|
+
>>> v2 = Version('1.0')
|
|
307
|
+
>>> v1.starts_with(v2)
|
|
308
|
+
True
|
|
309
|
+
>>>
|
|
310
|
+
```
|
|
311
|
+
"""
|
|
312
|
+
return self._version.starts_with(other._version)
|
|
313
|
+
|
|
314
|
+
def compatible_with(self, other: Version) -> bool:
|
|
315
|
+
"""
|
|
316
|
+
Checks if this version is compatible with other version.
|
|
317
|
+
Minor versions changes are compatible with older versions,
|
|
318
|
+
major version changes are breaking and will not be compatible.
|
|
319
|
+
|
|
320
|
+
Examples
|
|
321
|
+
--------
|
|
322
|
+
```python
|
|
323
|
+
>>> v1 = Version('1.0')
|
|
324
|
+
>>> v2 = Version('1.2')
|
|
325
|
+
>>> v_major = Version('2.0')
|
|
326
|
+
>>> v1.compatible_with(v2)
|
|
327
|
+
False
|
|
328
|
+
>>> v2.compatible_with(v1)
|
|
329
|
+
True
|
|
330
|
+
>>> v_major.compatible_with(v2)
|
|
331
|
+
False
|
|
332
|
+
>>> v2.compatible_with(v_major)
|
|
333
|
+
False
|
|
334
|
+
>>>
|
|
335
|
+
```
|
|
336
|
+
"""
|
|
337
|
+
return self._version.compatible_with(other._version)
|
|
338
|
+
|
|
339
|
+
def pop_segments(self, n: int = 1) -> Version:
|
|
340
|
+
"""
|
|
341
|
+
Pops `n` number of segments from the version and returns
|
|
342
|
+
the new version. Raises `InvalidVersionError` if version
|
|
343
|
+
becomes invalid due to the operation.
|
|
344
|
+
|
|
345
|
+
Examples
|
|
346
|
+
--------
|
|
347
|
+
```python
|
|
348
|
+
>>> v = Version('2!1.0.1')
|
|
349
|
+
>>> v.pop_segments() # `n` defaults to 1 if left empty
|
|
350
|
+
Version("2!1.0")
|
|
351
|
+
>>> v.pop_segments(2) # old version is still usable
|
|
352
|
+
Version("2!1")
|
|
353
|
+
>>> v.pop_segments(3) # doctest: +IGNORE_EXCEPTION_DETAIL
|
|
354
|
+
Traceback (most recent call last):
|
|
355
|
+
exceptions.InvalidVersionException: new Version must have atleast 1 valid
|
|
356
|
+
segment
|
|
357
|
+
>>>
|
|
358
|
+
```
|
|
359
|
+
"""
|
|
360
|
+
new_py_version = self._version.pop_segments(n)
|
|
361
|
+
if new_py_version:
|
|
362
|
+
return self._from_py_version(new_py_version)
|
|
363
|
+
else:
|
|
364
|
+
raise InvalidVersionError("new Version must have atleast 1 valid segment")
|
|
365
|
+
|
|
366
|
+
def with_segments(self, start: int, stop: int) -> Version:
|
|
367
|
+
"""
|
|
368
|
+
Returns new version with with segments ranging from `start` to `stop`.
|
|
369
|
+
`stop` is exclusive. Raises `InvalidVersionError` if the provided range
|
|
370
|
+
is invalid.
|
|
371
|
+
|
|
372
|
+
Examples
|
|
373
|
+
--------
|
|
374
|
+
```python
|
|
375
|
+
>>> v = Version('2!1.2.3')
|
|
376
|
+
>>> v.with_segments(0, 2)
|
|
377
|
+
Version("2!1.2")
|
|
378
|
+
>>>
|
|
379
|
+
```
|
|
380
|
+
"""
|
|
381
|
+
new_py_version = self._version.with_segments(start, stop)
|
|
382
|
+
if new_py_version:
|
|
383
|
+
return self._from_py_version(new_py_version)
|
|
384
|
+
else:
|
|
385
|
+
raise InvalidVersionError("Invalid segment range provided")
|
|
386
|
+
|
|
387
|
+
@property
|
|
388
|
+
def segment_count(self) -> int:
|
|
389
|
+
"""
|
|
390
|
+
Returns the number of segments in the version.
|
|
391
|
+
This does not include epoch or local segment of the version
|
|
392
|
+
|
|
393
|
+
Examples
|
|
394
|
+
--------
|
|
395
|
+
```python
|
|
396
|
+
>>> v = Version('2!1.2.3')
|
|
397
|
+
>>> v.segment_count
|
|
398
|
+
3
|
|
399
|
+
>>>
|
|
400
|
+
```
|
|
401
|
+
"""
|
|
402
|
+
return self._version.segment_count()
|
|
403
|
+
|
|
404
|
+
def strip_local(self) -> Version:
|
|
405
|
+
"""
|
|
406
|
+
Returns a new version with local segment stripped.
|
|
407
|
+
|
|
408
|
+
Examples
|
|
409
|
+
--------
|
|
410
|
+
```python
|
|
411
|
+
>>> v = Version('1.2.3+4.alpha-5')
|
|
412
|
+
>>> v.strip_local()
|
|
413
|
+
Version("1.2.3")
|
|
414
|
+
>>>
|
|
415
|
+
```
|
|
416
|
+
"""
|
|
417
|
+
return self._from_py_version(self._version.strip_local())
|
|
418
|
+
|
|
419
|
+
def __str__(self) -> str:
|
|
420
|
+
"""
|
|
421
|
+
Returns the string representation of the version
|
|
422
|
+
|
|
423
|
+
Examples
|
|
424
|
+
--------
|
|
425
|
+
```python
|
|
426
|
+
>>> str(Version("1.2.3"))
|
|
427
|
+
'1.2.3'
|
|
428
|
+
>>>
|
|
429
|
+
```
|
|
430
|
+
"""
|
|
431
|
+
return self._version.as_str()
|
|
432
|
+
|
|
433
|
+
def __repr__(self) -> str:
|
|
434
|
+
"""
|
|
435
|
+
Returns a representation of the version
|
|
436
|
+
|
|
437
|
+
Examples
|
|
438
|
+
--------
|
|
439
|
+
```python
|
|
440
|
+
>>> Version("1.2.3")
|
|
441
|
+
Version("1.2.3")
|
|
442
|
+
>>>
|
|
443
|
+
```
|
|
444
|
+
"""
|
|
445
|
+
return f'Version("{self._version.as_str()}")'
|
|
446
|
+
|
|
447
|
+
def __hash__(self) -> int:
|
|
448
|
+
"""
|
|
449
|
+
Computes the hash of this instance.
|
|
450
|
+
|
|
451
|
+
Examples
|
|
452
|
+
--------
|
|
453
|
+
```python
|
|
454
|
+
>>> hash(Version("1.2.3")) == hash(Version("1.2.3"))
|
|
455
|
+
True
|
|
456
|
+
>>> hash(Version("1.2.3")) == hash(Version("3.2.1"))
|
|
457
|
+
False
|
|
458
|
+
>>> hash(Version("1")) == hash(Version("1.0.0"))
|
|
459
|
+
True
|
|
460
|
+
>>>
|
|
461
|
+
```
|
|
462
|
+
"""
|
|
463
|
+
return self._version.__hash__()
|
|
464
|
+
|
|
465
|
+
def __eq__(self, other: Version) -> bool: # type: ignore[override]
|
|
466
|
+
"""
|
|
467
|
+
Returns True if this instance represents the same version as `other`.
|
|
468
|
+
|
|
469
|
+
Examples
|
|
470
|
+
--------
|
|
471
|
+
```python
|
|
472
|
+
>>> Version("1.2.3") == Version("1.2.3")
|
|
473
|
+
True
|
|
474
|
+
>>> Version("3.2.1") == Version("1.2.3")
|
|
475
|
+
False
|
|
476
|
+
>>> Version("1") == Version("1.0.0")
|
|
477
|
+
True
|
|
478
|
+
>>>
|
|
479
|
+
```
|
|
480
|
+
"""
|
|
481
|
+
return self._version == other._version
|
|
482
|
+
|
|
483
|
+
def __ne__(self, other: Version) -> bool: # type: ignore[override]
|
|
484
|
+
"""
|
|
485
|
+
Returns False if this instance represents the same version as `other`.
|
|
486
|
+
|
|
487
|
+
Examples
|
|
488
|
+
--------
|
|
489
|
+
```python
|
|
490
|
+
>>> Version("1.2.3") != Version("1.2.3")
|
|
491
|
+
False
|
|
492
|
+
>>> Version("3.2.1") != Version("1.2.3")
|
|
493
|
+
True
|
|
494
|
+
>>> Version("1") != Version("1.0.0")
|
|
495
|
+
False
|
|
496
|
+
>>>
|
|
497
|
+
```
|
|
498
|
+
"""
|
|
499
|
+
return self._version != other._version
|
|
500
|
+
|
|
501
|
+
def __gt__(self, other: Version) -> bool:
|
|
502
|
+
"""
|
|
503
|
+
Returns True if this instance should be ordered *after* `other`.
|
|
504
|
+
|
|
505
|
+
Examples
|
|
506
|
+
--------
|
|
507
|
+
```python
|
|
508
|
+
>>> Version("1.2.3") > Version("1.2.3")
|
|
509
|
+
False
|
|
510
|
+
>>> Version("1.2.4") > Version("1.2.3")
|
|
511
|
+
True
|
|
512
|
+
>>> Version("1.2.3.1") > Version("1.2.3")
|
|
513
|
+
True
|
|
514
|
+
>>> Version("3.2.1") > Version("1.2.3")
|
|
515
|
+
True
|
|
516
|
+
>>> Version("1") > Version("1.0.0")
|
|
517
|
+
False
|
|
518
|
+
>>>
|
|
519
|
+
```
|
|
520
|
+
"""
|
|
521
|
+
return self._version > other._version
|
|
522
|
+
|
|
523
|
+
def __lt__(self, other: Version) -> bool:
|
|
524
|
+
"""
|
|
525
|
+
Returns True if this instance should be ordered *before* `other`.
|
|
526
|
+
|
|
527
|
+
Examples
|
|
528
|
+
--------
|
|
529
|
+
```python
|
|
530
|
+
>>> Version("1.2.3") < Version("1.2.3")
|
|
531
|
+
False
|
|
532
|
+
>>> Version("1.2.3") < Version("1.2.4")
|
|
533
|
+
True
|
|
534
|
+
>>> Version("1.2.3") < Version("1.2.3.1")
|
|
535
|
+
True
|
|
536
|
+
>>> Version("3.2.1") < Version("1.2.3")
|
|
537
|
+
False
|
|
538
|
+
>>> Version("1") < Version("1.0.0")
|
|
539
|
+
False
|
|
540
|
+
>>>
|
|
541
|
+
```
|
|
542
|
+
"""
|
|
543
|
+
return self._version < other._version
|
|
544
|
+
|
|
545
|
+
def __ge__(self, other: Version) -> bool:
|
|
546
|
+
"""
|
|
547
|
+
Returns True if this instance should be ordered *after* or at the same location
|
|
548
|
+
as `other`.
|
|
549
|
+
|
|
550
|
+
Examples
|
|
551
|
+
--------
|
|
552
|
+
```python
|
|
553
|
+
>>> Version("1.2.3") >= Version("1.2.3")
|
|
554
|
+
True
|
|
555
|
+
>>> Version("1.2.4") >= Version("1.2.3")
|
|
556
|
+
True
|
|
557
|
+
>>> Version("1.2.3.1") >= Version("1.2.3")
|
|
558
|
+
True
|
|
559
|
+
>>> Version("3.2.1") >= Version("1.2.3")
|
|
560
|
+
True
|
|
561
|
+
>>> Version("1.2.3") >= Version("3.2.1")
|
|
562
|
+
False
|
|
563
|
+
>>> Version("1") >= Version("1.0.0")
|
|
564
|
+
True
|
|
565
|
+
>>>
|
|
566
|
+
```
|
|
567
|
+
"""
|
|
568
|
+
return self._version >= other._version
|
|
569
|
+
|
|
570
|
+
def __le__(self, other: Version) -> bool:
|
|
571
|
+
"""
|
|
572
|
+
Returns True if this instance should be ordered *before* or at the same
|
|
573
|
+
location as `other`.
|
|
574
|
+
|
|
575
|
+
Examples
|
|
576
|
+
--------
|
|
577
|
+
```python
|
|
578
|
+
>>> Version("1.2.3") <= Version("1.2.3")
|
|
579
|
+
True
|
|
580
|
+
>>> Version("1.2.3") <= Version("1.2.4")
|
|
581
|
+
True
|
|
582
|
+
>>> Version("1.2.3") <= Version("1.2.3.1")
|
|
583
|
+
True
|
|
584
|
+
>>> Version("3.2.1") <= Version("1.2.3")
|
|
585
|
+
False
|
|
586
|
+
>>> Version("1") <= Version("1.0.0")
|
|
587
|
+
True
|
|
588
|
+
>>>
|
|
589
|
+
```
|
|
590
|
+
"""
|
|
591
|
+
return self._version <= other._version
|