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.
Files changed (68) hide show
  1. py_rattler-0.22.0.dist-info/METADATA +208 -0
  2. py_rattler-0.22.0.dist-info/RECORD +68 -0
  3. py_rattler-0.22.0.dist-info/WHEEL +4 -0
  4. rattler/__init__.py +114 -0
  5. rattler/channel/__init__.py +5 -0
  6. rattler/channel/channel.py +94 -0
  7. rattler/channel/channel_config.py +43 -0
  8. rattler/channel/channel_priority.py +14 -0
  9. rattler/exceptions.py +120 -0
  10. rattler/explicit_environment/__init__.py +3 -0
  11. rattler/explicit_environment/environment.py +69 -0
  12. rattler/index/__init__.py +3 -0
  13. rattler/index/index.py +112 -0
  14. rattler/install/__init__.py +3 -0
  15. rattler/install/installer.py +96 -0
  16. rattler/lock/__init__.py +23 -0
  17. rattler/lock/channel.py +52 -0
  18. rattler/lock/environment.py +213 -0
  19. rattler/lock/hash.py +33 -0
  20. rattler/lock/lock_file.py +118 -0
  21. rattler/lock/package.py +302 -0
  22. rattler/match_spec/__init__.py +4 -0
  23. rattler/match_spec/match_spec.py +294 -0
  24. rattler/match_spec/nameless_match_spec.py +185 -0
  25. rattler/networking/__init__.py +21 -0
  26. rattler/networking/client.py +74 -0
  27. rattler/networking/fetch_repo_data.py +103 -0
  28. rattler/networking/middleware.py +234 -0
  29. rattler/package/__init__.py +26 -0
  30. rattler/package/about_json.py +329 -0
  31. rattler/package/index_json.py +437 -0
  32. rattler/package/no_arch_type.py +142 -0
  33. rattler/package/package_name.py +204 -0
  34. rattler/package/package_name_matcher.py +81 -0
  35. rattler/package/paths_json.py +696 -0
  36. rattler/package/run_exports_json.py +268 -0
  37. rattler/package_streaming/__init__.py +26 -0
  38. rattler/platform/__init__.py +4 -0
  39. rattler/platform/arch.py +59 -0
  40. rattler/platform/platform.py +217 -0
  41. rattler/prefix/__init__.py +4 -0
  42. rattler/prefix/prefix_paths.py +442 -0
  43. rattler/prefix/prefix_record.py +234 -0
  44. rattler/pty/__init__.py +25 -0
  45. rattler/pty/pty_process.py +391 -0
  46. rattler/pty/pty_session.py +241 -0
  47. rattler/py.typed +0 -0
  48. rattler/rattler.abi3.so +0 -0
  49. rattler/repo_data/__init__.py +19 -0
  50. rattler/repo_data/gateway.py +337 -0
  51. rattler/repo_data/package_record.py +938 -0
  52. rattler/repo_data/patch_instructions.py +22 -0
  53. rattler/repo_data/record.py +164 -0
  54. rattler/repo_data/repo_data.py +74 -0
  55. rattler/repo_data/source.py +85 -0
  56. rattler/repo_data/sparse.py +356 -0
  57. rattler/shell/__init__.py +3 -0
  58. rattler/shell/shell.py +134 -0
  59. rattler/solver/__init__.py +3 -0
  60. rattler/solver/solver.py +220 -0
  61. rattler/utils/rattler_version.py +19 -0
  62. rattler/version/__init__.py +5 -0
  63. rattler/version/version.py +591 -0
  64. rattler/version/version_spec.py +184 -0
  65. rattler/version/with_source.py +80 -0
  66. rattler/virtual_package/__init__.py +4 -0
  67. rattler/virtual_package/generic.py +136 -0
  68. rattler/virtual_package/virtual_package.py +201 -0
@@ -0,0 +1,234 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Callable
4
+
5
+ from rattler.rattler import (
6
+ PyAddHeadersMiddleware,
7
+ PyAuthenticationMiddleware,
8
+ PyGCSMiddleware,
9
+ PyMirrorMiddleware,
10
+ PyOciMiddleware,
11
+ PyS3Middleware,
12
+ PyS3Config,
13
+ )
14
+
15
+
16
+ class MirrorMiddleware:
17
+ def __init__(self, mirrors: dict[str, list[str]]) -> None:
18
+ """
19
+ Create a new MirrorMiddleware instance.
20
+ The mirrors argument should be a dictionary where the keys are the
21
+ original mirror URLs and the values are lists of mirror URLs to
22
+ replace the original mirror with.
23
+
24
+ Examples
25
+ --------
26
+ ```python
27
+ >>> from rattler.networking import Client
28
+ >>> middleware = MirrorMiddleware({"https://conda.anaconda.org/conda-forge": ["https://repo.prefix.dev/conda-forge"]})
29
+ >>> middleware
30
+ MirrorMiddleware()
31
+ >>> Client([middleware])
32
+ Client()
33
+ >>>
34
+ ```
35
+ """
36
+ self._middleware = PyMirrorMiddleware(mirrors)
37
+
38
+ def __repr__(self) -> str:
39
+ """
40
+ Returns a representation of the Middleware
41
+
42
+ Examples
43
+ --------
44
+ ```python
45
+ >>> middleware = MirrorMiddleware({"https://conda.anaconda.org/conda-forge": ["https://repo.prefix.dev/conda-forge"]})
46
+ >>> middleware
47
+ MirrorMiddleware()
48
+ >>>
49
+ ```
50
+ """
51
+ return f"{type(self).__name__}()"
52
+
53
+
54
+ class AuthenticationMiddleware:
55
+ """
56
+ Middleware to handle authentication from keychain
57
+ """
58
+
59
+ def __init__(self) -> None:
60
+ self._middleware = PyAuthenticationMiddleware()
61
+
62
+ def __repr__(self) -> str:
63
+ """
64
+ Returns a representation of the Middleware
65
+
66
+ Examples
67
+ --------
68
+ ```python
69
+ >>> from rattler.networking import Client
70
+ >>> middleware = AuthenticationMiddleware()
71
+ >>> middleware
72
+ AuthenticationMiddleware()
73
+ >>> Client([middleware])
74
+ Client()
75
+ >>>
76
+ ```
77
+ """
78
+ return f"{type(self).__name__}()"
79
+
80
+
81
+ class OciMiddleware:
82
+ """
83
+ Middleware to handle `oci://` URLs
84
+ """
85
+
86
+ def __init__(self) -> None:
87
+ self._middleware = PyOciMiddleware()
88
+
89
+ def __repr__(self) -> str:
90
+ """
91
+ Returns a representation of the Middleware
92
+
93
+ Examples
94
+ --------
95
+ ```python
96
+ >>> from rattler.networking import Client
97
+ >>> middleware = OciMiddleware()
98
+ >>> middleware
99
+ OciMiddleware()
100
+ >>> Client([middleware])
101
+ Client()
102
+ >>>
103
+ ```
104
+ """
105
+ return f"{type(self).__name__}()"
106
+
107
+
108
+ class GCSMiddleware:
109
+ """
110
+ Middleware to work with gcs:// URLs
111
+
112
+ Examples
113
+ --------
114
+ ```python
115
+ >>> from rattler.networking import Client
116
+ >>> middleware = GCSMiddleware()
117
+ >>> middleware
118
+ GCSMiddleware()
119
+ >>> Client([middleware])
120
+ Client()
121
+ >>>
122
+ ```
123
+ """
124
+
125
+ def __init__(self) -> None:
126
+ self._middleware = PyGCSMiddleware()
127
+
128
+ def __repr__(self) -> str:
129
+ return f"{type(self).__name__}()"
130
+
131
+
132
+ class S3Config:
133
+ """
134
+ Middleware to work with s3:// URLs
135
+
136
+ Examples
137
+ --------
138
+ ```python
139
+ >>> from rattler.networking import S3Middleware
140
+ >>> config = S3Config("http://localhost:9000", "eu-central-1", True)
141
+ >>> config
142
+ S3Config(http://localhost:9000, eu-central-1, True)
143
+ >>> middleware = S3Middleware({"my-bucket": config})
144
+ >>> middleware
145
+ S3Middleware()
146
+ >>> S3Config()
147
+ S3Config(aws sdk)
148
+ >>>
149
+ ```
150
+ """
151
+
152
+ def __init__(
153
+ self, endpoint_url: str | None = None, region: str | None = None, force_path_style: bool | None = None
154
+ ) -> None:
155
+ self._config = PyS3Config(endpoint_url, region, force_path_style)
156
+ if (endpoint_url is None) != (region is None) or (endpoint_url is None) != (force_path_style is None):
157
+ raise ValueError("Invalid arguments for S3Config")
158
+ self._endpoint_url = endpoint_url
159
+ self._region = region
160
+ self._force_path_style = force_path_style
161
+
162
+ def __repr__(self) -> str:
163
+ inner = (
164
+ f"{self._endpoint_url}, {self._region}, {self._force_path_style}"
165
+ if self._endpoint_url is not None
166
+ else "aws sdk"
167
+ )
168
+ return f"{type(self).__name__}({inner})"
169
+
170
+
171
+ class S3Middleware:
172
+ """
173
+ Middleware to work with s3:// URLs
174
+
175
+ Examples
176
+ --------
177
+ ```python
178
+ >>> from rattler.networking import Client
179
+ >>> middleware = S3Middleware()
180
+ >>> middleware
181
+ S3Middleware()
182
+ >>> Client([middleware])
183
+ Client()
184
+ >>>
185
+ ```
186
+ """
187
+
188
+ def __init__(self, config: dict[str, S3Config] | None = None) -> None:
189
+ if config is None:
190
+ config = dict()
191
+ self._middleware = PyS3Middleware({k: v._config for k, v in config.items()})
192
+
193
+ def __repr__(self) -> str:
194
+ return f"{type(self).__name__}()"
195
+
196
+
197
+ class AddHeadersMiddleware:
198
+ """
199
+ Middleware that adds headers to requests based on a callback function.
200
+
201
+ The callback receives the host and path of the request URL and should return
202
+ a dictionary of headers to add, or None to add no headers.
203
+
204
+ Examples
205
+ --------
206
+ ```python
207
+ >>> from rattler.networking import Client, AddHeadersMiddleware
208
+ >>> def my_callback(host: str, path: str) -> dict[str, str] | None:
209
+ ... if host == "private.example.com":
210
+ ... return {"Authorization": "Bearer my-token"}
211
+ ... return None
212
+ >>> middleware = AddHeadersMiddleware(my_callback)
213
+ >>> middleware
214
+ AddHeadersMiddleware()
215
+ >>> Client([middleware])
216
+ Client()
217
+ >>>
218
+ ```
219
+ """
220
+
221
+ def __init__(self, callback: Callable[[str, str], dict[str, str] | None]) -> None:
222
+ """
223
+ Create a new AddHeadersMiddleware instance.
224
+
225
+ Args:
226
+ callback: A callable that takes (host, path) and returns a dictionary
227
+ of headers to add to the request, or None to add no headers.
228
+ The host is the hostname of the request URL (e.g., "conda.anaconda.org").
229
+ The path is the path component of the URL (e.g., "/conda-forge/linux-64/repodata.json").
230
+ """
231
+ self._middleware = PyAddHeadersMiddleware(callback)
232
+
233
+ def __repr__(self) -> str:
234
+ return f"{type(self).__name__}()"
@@ -0,0 +1,26 @@
1
+ from rattler.package.package_name import PackageName
2
+ from rattler.package.about_json import AboutJson
3
+ from rattler.package.run_exports_json import RunExportsJson
4
+ from rattler.package.paths_json import (
5
+ PathsJson,
6
+ PathsEntry,
7
+ PathType,
8
+ PrefixPlaceholder,
9
+ FileMode,
10
+ )
11
+ from rattler.package.index_json import IndexJson
12
+ from rattler.package.no_arch_type import NoArchType, NoArchLiteral
13
+
14
+ __all__ = [
15
+ "PackageName",
16
+ "AboutJson",
17
+ "RunExportsJson",
18
+ "PathsJson",
19
+ "PathsEntry",
20
+ "PathType",
21
+ "PrefixPlaceholder",
22
+ "FileMode",
23
+ "IndexJson",
24
+ "NoArchLiteral",
25
+ "NoArchType",
26
+ ]
@@ -0,0 +1,329 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ from pathlib import Path
5
+ from typing import List, Optional
6
+
7
+ from rattler.rattler import PyAboutJson
8
+
9
+
10
+ class AboutJson:
11
+ """
12
+ The `about.json` file contains metadata about the package.
13
+ """
14
+
15
+ _inner: PyAboutJson
16
+
17
+ @staticmethod
18
+ def from_path(path: os.PathLike[str]) -> AboutJson:
19
+ """
20
+ Parses the object from a file specified by a `path`, using a format
21
+ appropriate for the file type.
22
+
23
+ For example, if the file is in JSON format, this function reads the data
24
+ from the file at the specified path, parse the JSON string and return the
25
+ resulting object. If the file is not in a parsable format or if the file
26
+ could not read, this function returns an error.
27
+
28
+ Examples
29
+ --------
30
+ ```python
31
+ >>> about = AboutJson.from_path("../test-data/dummy-about.json")
32
+ >>> about
33
+ AboutJson()
34
+ >>>
35
+ ```
36
+ """
37
+ return AboutJson._from_py_about_json(PyAboutJson.from_path(Path(path)))
38
+
39
+ @staticmethod
40
+ def from_package_directory(path: os.PathLike[str]) -> AboutJson:
41
+ """
42
+ Parses the object by looking up the appropriate file from the root of the
43
+ specified Conda archive directory, using a format appropriate for the file
44
+ type.
45
+
46
+ For example, if the file is in JSON format, this function reads the
47
+ appropriate file from the archive, parse the JSON string and return the
48
+ resulting object. If the file is not in a parsable format or if the file
49
+ could not be read, this function returns an error.
50
+ """
51
+ return AboutJson._from_py_about_json(PyAboutJson.from_package_directory(Path(path)))
52
+
53
+ @staticmethod
54
+ def from_str(string: str) -> AboutJson:
55
+ """
56
+ Parses the object from a string, using a format appropriate for the file
57
+ type.
58
+
59
+ For example, if the file is in JSON format, this function parses the JSON
60
+ string and returns the resulting object. If the file is not in a parsable
61
+ format, this function returns an error.
62
+
63
+ Examples
64
+ --------
65
+ ```python
66
+ >>> import json
67
+ >>> with open("../test-data/dummy-about.json", 'r') as file:
68
+ ... json_str = json.dumps(json.load(file))
69
+ >>> about = AboutJson.from_str(json_str)
70
+ >>> about
71
+ AboutJson()
72
+ >>>
73
+ ```
74
+ """
75
+ return AboutJson._from_py_about_json(PyAboutJson.from_str(string))
76
+
77
+ @staticmethod
78
+ def package_path() -> Path:
79
+ """
80
+ Returns the path to the file within the Conda archive.
81
+
82
+ The path is relative to the root of the archive and includes any necessary
83
+ directories.
84
+
85
+ Examples
86
+ --------
87
+ ```python
88
+ >>> str(AboutJson.package_path())
89
+ 'info/about.json'
90
+ >>>
91
+ ```
92
+ """
93
+ return PyAboutJson.package_path()
94
+
95
+ @property
96
+ def channels(self) -> List[str]:
97
+ """
98
+ A list of channels that where used during the build.
99
+
100
+ Examples
101
+ --------
102
+ ```python
103
+ >>> about = AboutJson.from_path("../test-data/dummy-about.json")
104
+ >>> about.channels
105
+ ['https://conda.anaconda.org/conda-forge']
106
+ >>> about.channels = ['https://test.channel']
107
+ >>> about.channels
108
+ ['https://test.channel']
109
+ >>>
110
+ ```
111
+ """
112
+ return self._inner.channels
113
+
114
+ @channels.setter
115
+ def channels(self, value: List[str]) -> None:
116
+ self._inner.channels = value
117
+
118
+ @property
119
+ def description(self) -> Optional[str]:
120
+ """
121
+ Description of the package.
122
+
123
+ Examples
124
+ --------
125
+ ```python
126
+ >>> about = AboutJson.from_path("../test-data/dummy-about.json")
127
+ >>> about.description
128
+ 'A dummy description.'
129
+ >>> about.description = 'New description'
130
+ >>> about.description
131
+ 'New description'
132
+ >>>
133
+ ```
134
+ """
135
+ if description := self._inner.description:
136
+ return description
137
+
138
+ return None
139
+
140
+ @description.setter
141
+ def description(self, value: Optional[str]) -> None:
142
+ self._inner.description = value
143
+
144
+ @property
145
+ def dev_url(self) -> List[str]:
146
+ """
147
+ A list of URLs to the development page of the package.
148
+
149
+ Examples
150
+ --------
151
+ ```python
152
+ >>> about = AboutJson.from_path("../test-data/dummy-about.json")
153
+ >>> about.dev_url
154
+ ['https://github.com/conda/rattler']
155
+ >>> about.dev_url = ['https://test.dev']
156
+ >>> about.dev_url
157
+ ['https://test.dev/']
158
+ >>>
159
+ ```
160
+ """
161
+ return self._inner.dev_url
162
+
163
+ @dev_url.setter
164
+ def dev_url(self, value: List[str]) -> None:
165
+ self._inner.dev_url = value
166
+
167
+ @property
168
+ def doc_url(self) -> List[str]:
169
+ """
170
+ A list of URLs to the documentation of the package.
171
+
172
+ Examples
173
+ --------
174
+ ```python
175
+ >>> about = AboutJson.from_path("../test-data/dummy-about.json")
176
+ >>> about.doc_url
177
+ ['https://conda.github.io/rattler/py-rattler/']
178
+ >>> about.doc_url = ['https://test.docs']
179
+ >>> about.doc_url
180
+ ['https://test.docs/']
181
+ >>>
182
+ ```
183
+ """
184
+ return self._inner.doc_url
185
+
186
+ @doc_url.setter
187
+ def doc_url(self, value: List[str]) -> None:
188
+ self._inner.doc_url = value
189
+
190
+ @property
191
+ def home(self) -> List[str]:
192
+ """
193
+ A list URL to the homepage of the package.
194
+
195
+ Examples
196
+ --------
197
+ ```python
198
+ >>> about = AboutJson.from_path("../test-data/dummy-about.json")
199
+ >>> about.home
200
+ ['http://github.com/conda/rattler']
201
+ >>> about.home = ['https://test.home']
202
+ >>> about.home
203
+ ['https://test.home/']
204
+ >>>
205
+ ```
206
+ """
207
+ return self._inner.home
208
+
209
+ @home.setter
210
+ def home(self, value: List[str]) -> None:
211
+ self._inner.home = value
212
+
213
+ @property
214
+ def license(self) -> Optional[str]:
215
+ """
216
+ The license of the package.
217
+
218
+ Examples
219
+ --------
220
+ ```python
221
+ >>> about = AboutJson.from_path("../test-data/dummy-about.json")
222
+ >>> about.license
223
+ 'BSD-3-Clause'
224
+ >>> about.license = 'MIT'
225
+ >>> about.license
226
+ 'MIT'
227
+ >>>
228
+ ```
229
+ """
230
+ if license := self._inner.license:
231
+ return license
232
+
233
+ return None
234
+
235
+ @license.setter
236
+ def license(self, value: Optional[str]) -> None:
237
+ self._inner.license = value
238
+
239
+ @property
240
+ def license_family(self) -> Optional[str]:
241
+ """
242
+ The license family of the package.
243
+
244
+ Examples
245
+ --------
246
+ ```python
247
+ >>> about = AboutJson.from_path("../test-data/dummy-about.json")
248
+ >>> about.license_family
249
+ >>> type(about.license_family)
250
+ <class 'NoneType'>
251
+ >>> about.license_family = 'BSD'
252
+ >>> about.license_family
253
+ 'BSD'
254
+ >>>
255
+ ```
256
+ """
257
+ if license_family := self._inner.license_family:
258
+ return license_family
259
+
260
+ return None
261
+
262
+ @license_family.setter
263
+ def license_family(self, value: Optional[str]) -> None:
264
+ self._inner.license_family = value
265
+
266
+ @property
267
+ def source_url(self) -> Optional[str]:
268
+ """
269
+ The URL to the latest source code of the package.
270
+
271
+ Examples
272
+ --------
273
+ ```python
274
+ >>> about = AboutJson.from_path("../test-data/dummy-about.json")
275
+ >>> about.source_url
276
+ 'https://github.com/conda/rattler'
277
+ >>> about.source_url = 'https://test.source'
278
+ >>> about.source_url
279
+ 'https://test.source/'
280
+ >>>
281
+ ```
282
+ """
283
+ if source_url := self._inner.source_url:
284
+ return source_url
285
+
286
+ return None
287
+
288
+ @source_url.setter
289
+ def source_url(self, value: Optional[str]) -> None:
290
+ self._inner.source_url = value
291
+
292
+ @property
293
+ def summary(self) -> Optional[str]:
294
+ """
295
+ A Short summary description.
296
+
297
+ Examples
298
+ --------
299
+ ```python
300
+ >>> about = AboutJson.from_path("../test-data/dummy-about.json")
301
+ >>> about.summary
302
+ 'A dummy summary.'
303
+ >>> about.summary = 'New summary'
304
+ >>> about.summary
305
+ 'New summary'
306
+ >>>
307
+ ```
308
+ """
309
+ if summary := self._inner.summary:
310
+ return summary
311
+
312
+ return None
313
+
314
+ @summary.setter
315
+ def summary(self, value: Optional[str]) -> None:
316
+ self._inner.summary = value
317
+
318
+ @classmethod
319
+ def _from_py_about_json(cls, py_about_json: PyAboutJson) -> AboutJson:
320
+ about_json = cls.__new__(cls)
321
+ about_json._inner = py_about_json
322
+
323
+ return about_json
324
+
325
+ def __repr__(self) -> str:
326
+ """
327
+ Returns a representation of the AboutJson.
328
+ """
329
+ return "AboutJson()"