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,437 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import os
|
|
3
|
+
import datetime
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import List, Optional
|
|
6
|
+
|
|
7
|
+
from rattler.package.package_name import PackageName
|
|
8
|
+
from rattler.rattler import PyIndexJson
|
|
9
|
+
from rattler.version.version import Version
|
|
10
|
+
from rattler.version.with_source import VersionWithSource
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class IndexJson:
|
|
14
|
+
_inner: PyIndexJson
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
def from_path(path: os.PathLike[str]) -> IndexJson:
|
|
18
|
+
"""
|
|
19
|
+
Parses an `index.json` file pointed to by the path.
|
|
20
|
+
|
|
21
|
+
Examples
|
|
22
|
+
--------
|
|
23
|
+
```python
|
|
24
|
+
>>> idx_json = IndexJson.from_path(
|
|
25
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
26
|
+
... )
|
|
27
|
+
>>> idx_json
|
|
28
|
+
IndexJson()
|
|
29
|
+
>>>
|
|
30
|
+
```
|
|
31
|
+
"""
|
|
32
|
+
return IndexJson._from_py_index_json(PyIndexJson.from_path(path))
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def from_package_archive(path: os.PathLike[str]) -> IndexJson:
|
|
36
|
+
"""
|
|
37
|
+
Parses the package file from archive.
|
|
38
|
+
Note: If you want to extract multiple `info/*` files then this will be slightly
|
|
39
|
+
slower than manually iterating over the archive entries with
|
|
40
|
+
custom logic as this skips over the rest of the archive
|
|
41
|
+
"""
|
|
42
|
+
return IndexJson._from_py_index_json(PyIndexJson.from_package_archive(path))
|
|
43
|
+
|
|
44
|
+
@staticmethod
|
|
45
|
+
def from_package_directory(path: os.PathLike[str]) -> IndexJson:
|
|
46
|
+
"""
|
|
47
|
+
Parses the object by looking up the appropriate file from the root of the
|
|
48
|
+
specified Conda archive directory, using a format appropriate for the file
|
|
49
|
+
type.
|
|
50
|
+
|
|
51
|
+
For example, if the file is in JSON format, this function reads the
|
|
52
|
+
appropriate file from the archive, parse the JSON string and return the
|
|
53
|
+
resulting object. If the file is not in a parsable format or if the file
|
|
54
|
+
could not be read, this function returns an error.
|
|
55
|
+
"""
|
|
56
|
+
return IndexJson._from_py_index_json(PyIndexJson.from_package_directory(Path(path)))
|
|
57
|
+
|
|
58
|
+
@staticmethod
|
|
59
|
+
def from_str(string: str) -> IndexJson:
|
|
60
|
+
"""
|
|
61
|
+
Parses the object from a string, using a format appropriate for the file
|
|
62
|
+
type.
|
|
63
|
+
|
|
64
|
+
For example, if the file is in JSON format, this function parses the JSON
|
|
65
|
+
string and returns the resulting object. If the file is not in a parsable
|
|
66
|
+
format, this function returns an error.
|
|
67
|
+
"""
|
|
68
|
+
return IndexJson._from_py_index_json(PyIndexJson.from_str(string))
|
|
69
|
+
|
|
70
|
+
@staticmethod
|
|
71
|
+
def package_path() -> Path:
|
|
72
|
+
"""
|
|
73
|
+
Returns the path to the file within the Conda archive.
|
|
74
|
+
|
|
75
|
+
The path is relative to the root of the archive and includes any necessary
|
|
76
|
+
directories.
|
|
77
|
+
"""
|
|
78
|
+
return PyIndexJson.package_path()
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def version(self) -> Version:
|
|
82
|
+
"""
|
|
83
|
+
The version of the package.
|
|
84
|
+
|
|
85
|
+
Examples
|
|
86
|
+
--------
|
|
87
|
+
```python
|
|
88
|
+
>>> idx_json = IndexJson.from_path(
|
|
89
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
90
|
+
... )
|
|
91
|
+
>>> idx_json.version
|
|
92
|
+
VersionWithSource(version="22.11.1", source="22.11.1")
|
|
93
|
+
>>> idx_json.version = VersionWithSource("1.02.3")
|
|
94
|
+
>>> idx_json.version
|
|
95
|
+
VersionWithSource(version="1.2.3", source="1.02.3")
|
|
96
|
+
>>>
|
|
97
|
+
```
|
|
98
|
+
"""
|
|
99
|
+
version, source = self._inner.version
|
|
100
|
+
return VersionWithSource._from_py_version(version, source)
|
|
101
|
+
|
|
102
|
+
@version.setter
|
|
103
|
+
def version(self, value: VersionWithSource) -> None:
|
|
104
|
+
self._inner.version = (value._version, value._source)
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def arch(self) -> Optional[str]:
|
|
108
|
+
"""
|
|
109
|
+
Optionally, the architecture the package is build for.
|
|
110
|
+
|
|
111
|
+
Examples
|
|
112
|
+
--------
|
|
113
|
+
```python
|
|
114
|
+
>>> idx_json = IndexJson.from_path(
|
|
115
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
116
|
+
... )
|
|
117
|
+
>>> idx_json.arch
|
|
118
|
+
'x86_64'
|
|
119
|
+
>>>
|
|
120
|
+
```
|
|
121
|
+
"""
|
|
122
|
+
if arch := self._inner.arch:
|
|
123
|
+
return arch
|
|
124
|
+
|
|
125
|
+
return None
|
|
126
|
+
|
|
127
|
+
@arch.setter
|
|
128
|
+
def arch(self, value: Optional[str]) -> None:
|
|
129
|
+
self._inner.arch = value
|
|
130
|
+
|
|
131
|
+
@property
|
|
132
|
+
def build(self) -> str:
|
|
133
|
+
"""
|
|
134
|
+
The build string of the package.
|
|
135
|
+
|
|
136
|
+
Examples
|
|
137
|
+
--------
|
|
138
|
+
```python
|
|
139
|
+
>>> idx_json = IndexJson.from_path(
|
|
140
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
141
|
+
... )
|
|
142
|
+
>>> idx_json.build
|
|
143
|
+
'py38haa244fe_1'
|
|
144
|
+
>>>
|
|
145
|
+
```
|
|
146
|
+
"""
|
|
147
|
+
return self._inner.build
|
|
148
|
+
|
|
149
|
+
@build.setter
|
|
150
|
+
def build(self, value: str) -> None:
|
|
151
|
+
self._inner.build = value
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def build_number(self) -> int:
|
|
155
|
+
"""
|
|
156
|
+
The build number of the package.
|
|
157
|
+
This is also included in the build string.
|
|
158
|
+
|
|
159
|
+
Examples
|
|
160
|
+
--------
|
|
161
|
+
```python
|
|
162
|
+
>>> idx_json = IndexJson.from_path(
|
|
163
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
164
|
+
... )
|
|
165
|
+
>>> idx_json.build_number
|
|
166
|
+
1
|
|
167
|
+
>>>
|
|
168
|
+
```
|
|
169
|
+
"""
|
|
170
|
+
return self._inner.build_number
|
|
171
|
+
|
|
172
|
+
@build_number.setter
|
|
173
|
+
def build_number(self, value: int) -> None:
|
|
174
|
+
self._inner.build_number = value
|
|
175
|
+
|
|
176
|
+
@property
|
|
177
|
+
def constrains(self) -> List[str]:
|
|
178
|
+
"""
|
|
179
|
+
The package constraints of the package.
|
|
180
|
+
|
|
181
|
+
Examples
|
|
182
|
+
--------
|
|
183
|
+
```python
|
|
184
|
+
>>> idx_json = IndexJson.from_path(
|
|
185
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
186
|
+
... )
|
|
187
|
+
>>> idx_json.constrains # doctest: +ELLIPSIS
|
|
188
|
+
['conda-content-trust >=0.1.1', ..., 'conda-env >=2.6', 'conda-build >=3']
|
|
189
|
+
>>>
|
|
190
|
+
```
|
|
191
|
+
"""
|
|
192
|
+
return self._inner.constrains
|
|
193
|
+
|
|
194
|
+
@constrains.setter
|
|
195
|
+
def constrains(self, value: List[str]) -> None:
|
|
196
|
+
self._inner.constrains = value
|
|
197
|
+
|
|
198
|
+
@property
|
|
199
|
+
def depends(self) -> List[str]:
|
|
200
|
+
"""
|
|
201
|
+
The dependencies of the package.
|
|
202
|
+
|
|
203
|
+
Examples
|
|
204
|
+
--------
|
|
205
|
+
```python
|
|
206
|
+
>>> idx_json = IndexJson.from_path(
|
|
207
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
208
|
+
... )
|
|
209
|
+
>>> idx_json.depends # doctest: +ELLIPSIS
|
|
210
|
+
['conda-package-handling >=1.3.0', ..., 'tqdm >=4']
|
|
211
|
+
>>>
|
|
212
|
+
```
|
|
213
|
+
"""
|
|
214
|
+
return self._inner.depends
|
|
215
|
+
|
|
216
|
+
@depends.setter
|
|
217
|
+
def depends(self, value: List[str]) -> None:
|
|
218
|
+
self._inner.set_depends(value)
|
|
219
|
+
|
|
220
|
+
@property
|
|
221
|
+
def features(self) -> Optional[str]:
|
|
222
|
+
"""
|
|
223
|
+
Features are a deprecated way to specify different feature sets for the conda solver. This is not
|
|
224
|
+
supported anymore and should not be used. Instead, `mutex` packages should be used to specify
|
|
225
|
+
mutually exclusive features.
|
|
226
|
+
|
|
227
|
+
Examples
|
|
228
|
+
--------
|
|
229
|
+
```python
|
|
230
|
+
>>> idx_json = IndexJson.from_path(
|
|
231
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
232
|
+
... )
|
|
233
|
+
>>> idx_json.features
|
|
234
|
+
>>>
|
|
235
|
+
```
|
|
236
|
+
"""
|
|
237
|
+
if features := self._inner.features:
|
|
238
|
+
return features
|
|
239
|
+
|
|
240
|
+
return None
|
|
241
|
+
|
|
242
|
+
@features.setter
|
|
243
|
+
def features(self, value: Optional[str]) -> None:
|
|
244
|
+
self._inner.set_features(value)
|
|
245
|
+
|
|
246
|
+
@property
|
|
247
|
+
def license(self) -> Optional[str]:
|
|
248
|
+
"""
|
|
249
|
+
Optionally, the license.
|
|
250
|
+
|
|
251
|
+
Examples
|
|
252
|
+
--------
|
|
253
|
+
```python
|
|
254
|
+
>>> idx_json = IndexJson.from_path(
|
|
255
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
256
|
+
... )
|
|
257
|
+
>>> idx_json.license
|
|
258
|
+
'BSD-3-Clause'
|
|
259
|
+
>>>
|
|
260
|
+
```
|
|
261
|
+
"""
|
|
262
|
+
if license := self._inner.license:
|
|
263
|
+
return license
|
|
264
|
+
|
|
265
|
+
return None
|
|
266
|
+
|
|
267
|
+
@license.setter
|
|
268
|
+
def license(self, value: Optional[str]) -> None:
|
|
269
|
+
self._inner.set_license(value)
|
|
270
|
+
|
|
271
|
+
@property
|
|
272
|
+
def license_family(self) -> Optional[str]:
|
|
273
|
+
"""
|
|
274
|
+
Optionally, the license.
|
|
275
|
+
|
|
276
|
+
Examples
|
|
277
|
+
--------
|
|
278
|
+
```python
|
|
279
|
+
>>> idx_json = IndexJson.from_path(
|
|
280
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
281
|
+
... )
|
|
282
|
+
>>> idx_json.license_family
|
|
283
|
+
>>>
|
|
284
|
+
```
|
|
285
|
+
"""
|
|
286
|
+
if license_family := self._inner.license_family:
|
|
287
|
+
return license_family
|
|
288
|
+
|
|
289
|
+
return None
|
|
290
|
+
|
|
291
|
+
@license_family.setter
|
|
292
|
+
def license_family(self, value: Optional[str]) -> None:
|
|
293
|
+
self._inner.set_license_family(value)
|
|
294
|
+
|
|
295
|
+
@property
|
|
296
|
+
def name(self) -> PackageName:
|
|
297
|
+
"""
|
|
298
|
+
The lowercase name of the package.
|
|
299
|
+
|
|
300
|
+
Examples
|
|
301
|
+
--------
|
|
302
|
+
```python
|
|
303
|
+
>>> idx_json = IndexJson.from_path(
|
|
304
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
305
|
+
... )
|
|
306
|
+
>>> idx_json.name
|
|
307
|
+
PackageName("conda")
|
|
308
|
+
>>> idx_json.name = PackageName("rattler")
|
|
309
|
+
>>> idx_json.name
|
|
310
|
+
PackageName("rattler")
|
|
311
|
+
>>>
|
|
312
|
+
```
|
|
313
|
+
"""
|
|
314
|
+
return PackageName._from_py_package_name(self._inner.name)
|
|
315
|
+
|
|
316
|
+
@name.setter
|
|
317
|
+
def name(self, value: PackageName) -> None:
|
|
318
|
+
self._inner.name = value._name
|
|
319
|
+
|
|
320
|
+
@property
|
|
321
|
+
def platform(self) -> Optional[str]:
|
|
322
|
+
"""
|
|
323
|
+
Optionally, the OS the package is build for.
|
|
324
|
+
|
|
325
|
+
Examples
|
|
326
|
+
--------
|
|
327
|
+
```python
|
|
328
|
+
>>> idx_json = IndexJson.from_path(
|
|
329
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
330
|
+
... )
|
|
331
|
+
>>> idx_json.platform
|
|
332
|
+
'win'
|
|
333
|
+
>>>
|
|
334
|
+
```
|
|
335
|
+
"""
|
|
336
|
+
if platform := self._inner.platform:
|
|
337
|
+
return platform
|
|
338
|
+
|
|
339
|
+
return None
|
|
340
|
+
|
|
341
|
+
@platform.setter
|
|
342
|
+
def platform(self, value: Optional[str]) -> None:
|
|
343
|
+
self._inner.set_platform(value)
|
|
344
|
+
|
|
345
|
+
@property
|
|
346
|
+
def subdir(self) -> Optional[str]:
|
|
347
|
+
"""
|
|
348
|
+
The subdirectory that contains this package.
|
|
349
|
+
|
|
350
|
+
Examples
|
|
351
|
+
--------
|
|
352
|
+
```python
|
|
353
|
+
>>> idx_json = IndexJson.from_path(
|
|
354
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
355
|
+
... )
|
|
356
|
+
>>> idx_json.subdir
|
|
357
|
+
'win-64'
|
|
358
|
+
>>>
|
|
359
|
+
```
|
|
360
|
+
"""
|
|
361
|
+
if subdir := self._inner.subdir:
|
|
362
|
+
return subdir
|
|
363
|
+
|
|
364
|
+
return None
|
|
365
|
+
|
|
366
|
+
@subdir.setter
|
|
367
|
+
def subdir(self, value: Optional[str]) -> None:
|
|
368
|
+
self._inner.set_subdir(value)
|
|
369
|
+
|
|
370
|
+
@property
|
|
371
|
+
def timestamp(self) -> Optional[datetime.datetime]:
|
|
372
|
+
"""
|
|
373
|
+
The timestamp when this package was created
|
|
374
|
+
|
|
375
|
+
Examples
|
|
376
|
+
--------
|
|
377
|
+
```python
|
|
378
|
+
>>> idx_json = IndexJson.from_path(
|
|
379
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
380
|
+
... )
|
|
381
|
+
>>> idx_json.timestamp
|
|
382
|
+
datetime.datetime(2022, 12, 7, 23, 45, 42, 50000, tzinfo=datetime.timezone.utc)
|
|
383
|
+
>>> idx_json.timestamp = datetime.datetime(2021, 1, 1, 1, 1, 1, 50000, tzinfo=datetime.timezone.utc)
|
|
384
|
+
>>> idx_json.timestamp
|
|
385
|
+
datetime.datetime(2021, 1, 1, 1, 1, 1, 50000, tzinfo=datetime.timezone.utc)
|
|
386
|
+
>>>
|
|
387
|
+
```
|
|
388
|
+
"""
|
|
389
|
+
if timestamp := self._inner.timestamp:
|
|
390
|
+
return datetime.datetime.fromtimestamp(timestamp / 1000.0, tz=datetime.timezone.utc)
|
|
391
|
+
|
|
392
|
+
return None
|
|
393
|
+
|
|
394
|
+
@timestamp.setter
|
|
395
|
+
def timestamp(self, value: Optional[datetime.datetime]) -> None:
|
|
396
|
+
if value is None:
|
|
397
|
+
self._inner.timestamp = None
|
|
398
|
+
else:
|
|
399
|
+
# convert to integer milliseconds
|
|
400
|
+
self._inner.timestamp = int(value.timestamp() * 1000.0)
|
|
401
|
+
|
|
402
|
+
@property
|
|
403
|
+
def track_features(self) -> List[str]:
|
|
404
|
+
"""
|
|
405
|
+
Track features are nowadays only used to downweight packages (ie. give them less priority). To
|
|
406
|
+
that effect, the number of track features is counted (number of commas) and the package is downweighted
|
|
407
|
+
by the number of track_features.
|
|
408
|
+
|
|
409
|
+
Examples
|
|
410
|
+
--------
|
|
411
|
+
```python
|
|
412
|
+
>>> idx_json = IndexJson.from_path(
|
|
413
|
+
... "../test-data/conda-22.11.1-py38haa244fe_1-index.json"
|
|
414
|
+
... )
|
|
415
|
+
>>> idx_json.track_features
|
|
416
|
+
[]
|
|
417
|
+
>>>
|
|
418
|
+
```
|
|
419
|
+
"""
|
|
420
|
+
return self._inner.track_features
|
|
421
|
+
|
|
422
|
+
@track_features.setter
|
|
423
|
+
def track_features(self, value: List[str]) -> None:
|
|
424
|
+
self._inner.set_track_features(value)
|
|
425
|
+
|
|
426
|
+
@classmethod
|
|
427
|
+
def _from_py_index_json(cls, py_index_json: PyIndexJson) -> IndexJson:
|
|
428
|
+
index_json = cls.__new__(cls)
|
|
429
|
+
index_json._inner = py_index_json
|
|
430
|
+
|
|
431
|
+
return index_json
|
|
432
|
+
|
|
433
|
+
def __repr__(self) -> str:
|
|
434
|
+
"""
|
|
435
|
+
Returns a representation of the IndexJson.
|
|
436
|
+
"""
|
|
437
|
+
return "IndexJson()"
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import Literal, Optional
|
|
3
|
+
|
|
4
|
+
from rattler.rattler import PyNoArchType
|
|
5
|
+
|
|
6
|
+
NoArchLiteral = Optional[Literal["python", "generic", True]]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class NoArchType:
|
|
10
|
+
_noarch: PyNoArchType
|
|
11
|
+
|
|
12
|
+
def __init__(self, noarch: NoArchLiteral = None) -> None:
|
|
13
|
+
if noarch is None:
|
|
14
|
+
self._noarch = PyNoArchType.none()
|
|
15
|
+
elif noarch == "python":
|
|
16
|
+
self._noarch = PyNoArchType.python()
|
|
17
|
+
elif noarch == "generic" or noarch is True:
|
|
18
|
+
self._noarch = PyNoArchType.generic()
|
|
19
|
+
else:
|
|
20
|
+
raise ValueError(f"NoArchType constructor received unsupported value {noarch} for the `noarch` parameter")
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def _from_py_no_arch_type(cls, py_no_arch_type: PyNoArchType) -> NoArchType:
|
|
24
|
+
"""Construct Rattler NoArchType from FFI PyNoArchType object."""
|
|
25
|
+
no_arch_type = cls.__new__(cls)
|
|
26
|
+
no_arch_type._noarch = py_no_arch_type
|
|
27
|
+
return no_arch_type
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def generic(self) -> bool:
|
|
31
|
+
"""
|
|
32
|
+
Return whether this NoArchType is 'generic'
|
|
33
|
+
>>> NoArchType('generic').generic
|
|
34
|
+
True
|
|
35
|
+
>>> NoArchType('generic').python
|
|
36
|
+
False
|
|
37
|
+
>>>
|
|
38
|
+
"""
|
|
39
|
+
return self._noarch.is_generic
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def none(self) -> bool:
|
|
43
|
+
"""
|
|
44
|
+
Return whether this NoArchType is set
|
|
45
|
+
>>> NoArchType(None).none
|
|
46
|
+
True
|
|
47
|
+
>>> NoArchType(None).python
|
|
48
|
+
False
|
|
49
|
+
>>>
|
|
50
|
+
"""
|
|
51
|
+
return self._noarch.is_none
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def python(self) -> bool:
|
|
55
|
+
"""
|
|
56
|
+
Return whether this NoArchType is 'python'
|
|
57
|
+
>>> NoArchType('python').python
|
|
58
|
+
True
|
|
59
|
+
>>> NoArchType('python').generic
|
|
60
|
+
False
|
|
61
|
+
>>>
|
|
62
|
+
"""
|
|
63
|
+
return self._noarch.is_python
|
|
64
|
+
|
|
65
|
+
def __hash__(self) -> int:
|
|
66
|
+
"""
|
|
67
|
+
Computes the hash of this instance.
|
|
68
|
+
|
|
69
|
+
Examples
|
|
70
|
+
--------
|
|
71
|
+
```python
|
|
72
|
+
>>> hash(NoArchType("python")) == hash(NoArchType("python"))
|
|
73
|
+
True
|
|
74
|
+
>>> hash(NoArchType("python")) == hash(NoArchType("generic"))
|
|
75
|
+
False
|
|
76
|
+
>>>
|
|
77
|
+
```
|
|
78
|
+
"""
|
|
79
|
+
return self._noarch.__hash__()
|
|
80
|
+
|
|
81
|
+
def __eq__(self, other: object) -> bool:
|
|
82
|
+
"""
|
|
83
|
+
Returns True if this instance represents the same NoArchType as `other`.
|
|
84
|
+
|
|
85
|
+
Examples
|
|
86
|
+
--------
|
|
87
|
+
```python
|
|
88
|
+
>>> NoArchType("python") == NoArchType("generic")
|
|
89
|
+
False
|
|
90
|
+
>>> NoArchType("python") == NoArchType("python")
|
|
91
|
+
True
|
|
92
|
+
>>> NoArchType("generic") == NoArchType("generic")
|
|
93
|
+
True
|
|
94
|
+
>>> NoArchType("python") == "python"
|
|
95
|
+
False
|
|
96
|
+
>>>
|
|
97
|
+
```
|
|
98
|
+
"""
|
|
99
|
+
if not isinstance(other, NoArchType):
|
|
100
|
+
return False
|
|
101
|
+
|
|
102
|
+
return self._noarch == other._noarch
|
|
103
|
+
|
|
104
|
+
def __ne__(self, other: object) -> bool:
|
|
105
|
+
"""
|
|
106
|
+
Returns True if this instance does not represents the same NoArchType as `other`.
|
|
107
|
+
|
|
108
|
+
Examples
|
|
109
|
+
--------
|
|
110
|
+
```python
|
|
111
|
+
>>> NoArchType("python") != NoArchType("python")
|
|
112
|
+
False
|
|
113
|
+
>>> NoArchType("python") != "python"
|
|
114
|
+
True
|
|
115
|
+
>>>
|
|
116
|
+
```
|
|
117
|
+
"""
|
|
118
|
+
if not isinstance(other, NoArchType):
|
|
119
|
+
return True
|
|
120
|
+
|
|
121
|
+
return self._noarch != other._noarch
|
|
122
|
+
|
|
123
|
+
def __repr__(self) -> str:
|
|
124
|
+
"""
|
|
125
|
+
Returns a representation of the NoArchType.
|
|
126
|
+
|
|
127
|
+
Examples
|
|
128
|
+
--------
|
|
129
|
+
```python
|
|
130
|
+
>>> p = NoArchType("python")
|
|
131
|
+
>>> p
|
|
132
|
+
NoArchType("python")
|
|
133
|
+
>>>
|
|
134
|
+
```
|
|
135
|
+
"""
|
|
136
|
+
|
|
137
|
+
if self._noarch.is_python:
|
|
138
|
+
return 'NoArchType("python")'
|
|
139
|
+
elif self._noarch.is_generic:
|
|
140
|
+
return 'NoArchType("generic")'
|
|
141
|
+
else:
|
|
142
|
+
return "NoArchType(None)"
|