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,268 @@
1
+ from __future__ import annotations
2
+ import os
3
+ from pathlib import Path
4
+ from typing import List
5
+
6
+ from rattler.rattler import PyRunExportsJson
7
+
8
+
9
+ class RunExportsJson:
10
+ """
11
+ A representation of the `run_exports.json` file found in package archives.
12
+ The `run_exports.json` file contains information about the run exports of a package
13
+ """
14
+
15
+ _inner: PyRunExportsJson
16
+
17
+ def __init__(
18
+ self,
19
+ weak: List[str] | None = None,
20
+ strong: List[str] | None = None,
21
+ noarch: List[str] | None = None,
22
+ weak_constrains: List[str] | None = None,
23
+ strong_constrains: List[str] | None = None,
24
+ ) -> None:
25
+ """
26
+ Create a new RunExportsJson instance.
27
+
28
+ Parameters
29
+ ----------
30
+ weak : List[str] | None, optional
31
+ Weak run exports apply a dependency from host to run
32
+ strong : List[str] | None, optional
33
+ Strong run exports apply a dependency from build to host and run
34
+ noarch : List[str] | None, optional
35
+ Noarch run exports apply a run export only to noarch packages
36
+ weak_constrains : List[str] | None, optional
37
+ Weak constrains apply a constrain dependency from host to build, or run to host
38
+ strong_constrains : List[str] | None, optional
39
+ Strong constrains apply a constrain dependency from build to host and run
40
+
41
+ Examples
42
+ --------
43
+ ```python
44
+ >>> run_exports = RunExportsJson(
45
+ ... weak=["weak_dep 1.0"],
46
+ ... strong=["strong_dep 2.0"],
47
+ ... noarch=["noarch_dep 3.0"],
48
+ ... weak_constrains=["weak_constrain 4.0"],
49
+ ... strong_constrains=["strong_constrain 5.0"]
50
+ ... )
51
+ >>> run_exports
52
+ RunExportsJson(weak=['weak_dep 1.0'], strong=['strong_dep 2.0'], noarch=['noarch_dep 3.0'], weak_constrains=['weak_constrain 4.0'], strong_constrains=['strong_constrain 5.0'])
53
+ >>>
54
+ ```
55
+ """
56
+ self._inner = PyRunExportsJson(
57
+ weak or [], strong or [], noarch or [], weak_constrains or [], strong_constrains or []
58
+ )
59
+
60
+ @staticmethod
61
+ def from_package_archive(path: os.PathLike[str]) -> RunExportsJson:
62
+ """
63
+ Parses the package file from archive.
64
+ Note: If you want to extract multiple `info/*` files then this will be slightly
65
+ slower than manually iterating over the archive entries with
66
+ custom logic as this skips over the rest of the archive
67
+ """
68
+ return RunExportsJson._from_py_run_exports_json(PyRunExportsJson.from_package_archive(path))
69
+
70
+ @staticmethod
71
+ def from_path(path: os.PathLike[str]) -> RunExportsJson:
72
+ """
73
+ Parses the object from a file specified by a `path`, using a format
74
+ appropriate for the file type.
75
+
76
+ For example, if the file is in JSON format, this function reads the data
77
+ from the file at the specified path, parse the JSON string and return the
78
+ resulting object. If the file is not in a parsable format or if the file
79
+ could not read, this function returns an error.
80
+
81
+ Examples
82
+ --------
83
+ ```python
84
+ >>> run_exports = RunExportsJson.from_path(
85
+ ... "../test-data/python-3.10.6-h2c4edbf_0_cpython-run_exports.json"
86
+ ... )
87
+ >>> run_exports
88
+ RunExportsJson(weak=['python_abi 3.10.* *_cp310'], strong=[], noarch=['python'], weak_constrains=[], strong_constrains=[])
89
+ >>>
90
+ ```
91
+ """
92
+ return RunExportsJson._from_py_run_exports_json(PyRunExportsJson.from_path(Path(path)))
93
+
94
+ @staticmethod
95
+ def from_package_directory(path: os.PathLike[str]) -> RunExportsJson:
96
+ """
97
+ Parses the object by looking up the appropriate file from the root of the
98
+ specified Conda archive directory, using a format appropriate for the file
99
+ type.
100
+
101
+ For example, if the file is in JSON format, this function reads the
102
+ appropriate file from the archive, parse the JSON string and return the
103
+ resulting object. If the file is not in a parsable format or if the file
104
+ could not be read, this function returns an error.
105
+ """
106
+ return RunExportsJson._from_py_run_exports_json(PyRunExportsJson.from_package_directory(Path(path)))
107
+
108
+ @staticmethod
109
+ def from_str(string: str) -> RunExportsJson:
110
+ """
111
+ Parses the object from a string, using a format appropriate for the file
112
+ type.
113
+
114
+ For example, if the file is in JSON format, this function parses the JSON
115
+ string and returns the resulting object. If the file is not in a parsable
116
+ format, this function returns an error.
117
+ """
118
+ return RunExportsJson._from_py_run_exports_json(PyRunExportsJson.from_str(string))
119
+
120
+ @staticmethod
121
+ def package_path() -> Path:
122
+ """
123
+ Returns the path to the file within the Conda archive.
124
+
125
+ The path is relative to the root of the archive and includes any necessary
126
+ directories.
127
+ """
128
+ return PyRunExportsJson.package_path()
129
+
130
+ @property
131
+ def weak(self) -> List[str]:
132
+ """
133
+ Weak run exports apply a dependency from host to run.
134
+
135
+ Examples
136
+ --------
137
+ ```python
138
+ >>> run_exports = RunExportsJson.from_path(
139
+ ... "../test-data/python-3.10.6-h2c4edbf_0_cpython-run_exports.json"
140
+ ... )
141
+ >>> run_exports.weak
142
+ ['python_abi 3.10.* *_cp310']
143
+ >>> run_exports.weak = ['new_dep 1.0']
144
+ >>> run_exports.weak
145
+ ['new_dep 1.0']
146
+ >>>
147
+ ```
148
+ """
149
+ return self._inner.weak
150
+
151
+ @weak.setter
152
+ def weak(self, value: List[str]) -> None:
153
+ self._inner.weak = value
154
+
155
+ @property
156
+ def strong(self) -> List[str]:
157
+ """
158
+ Strong run exports apply a dependency from build to host and run.
159
+
160
+ Examples
161
+ --------
162
+ ```python
163
+ >>> run_exports = RunExportsJson.from_path(
164
+ ... "../test-data/python-3.10.6-h2c4edbf_0_cpython-run_exports.json"
165
+ ... )
166
+ >>> run_exports.strong
167
+ []
168
+ >>> run_exports.strong = ['strong_dep 2.0']
169
+ >>> run_exports.strong
170
+ ['strong_dep 2.0']
171
+ >>>
172
+ ```
173
+ """
174
+ return self._inner.strong
175
+
176
+ @strong.setter
177
+ def strong(self, value: List[str]) -> None:
178
+ self._inner.strong = value
179
+
180
+ @property
181
+ def noarch(self) -> List[str]:
182
+ """
183
+ NoArch run exports apply a run export only to noarch packages (other run exports are ignored).
184
+ For example, python uses this to apply a dependency on python to all noarch packages, but not to
185
+ the python_abi package.
186
+
187
+ Examples
188
+ --------
189
+ ```python
190
+ >>> run_exports = RunExportsJson.from_path(
191
+ ... "../test-data/python-3.10.6-h2c4edbf_0_cpython-run_exports.json"
192
+ ... )
193
+ >>> run_exports.noarch
194
+ ['python']
195
+ >>> run_exports.noarch = ['noarch_dep 3.0']
196
+ >>> run_exports.noarch
197
+ ['noarch_dep 3.0']
198
+ >>>
199
+ ```
200
+ """
201
+ return self._inner.noarch
202
+
203
+ @noarch.setter
204
+ def noarch(self, value: List[str]) -> None:
205
+ self._inner.noarch = value
206
+
207
+ @property
208
+ def weak_constrains(self) -> List[str]:
209
+ """
210
+ Weak constrains apply a constrain dependency from host to build, or run to host.
211
+
212
+ Examples
213
+ --------
214
+ ```python
215
+ >>> run_exports = RunExportsJson.from_path(
216
+ ... "../test-data/python-3.10.6-h2c4edbf_0_cpython-run_exports.json"
217
+ ... )
218
+ >>> run_exports.weak_constrains
219
+ []
220
+ >>> run_exports.weak_constrains = ['weak_constrain 4.0']
221
+ >>> run_exports.weak_constrains
222
+ ['weak_constrain 4.0']
223
+ >>>
224
+ ```
225
+ """
226
+ return self._inner.weak_constrains
227
+
228
+ @weak_constrains.setter
229
+ def weak_constrains(self, value: List[str]) -> None:
230
+ self._inner.weak_constrains = value
231
+
232
+ @property
233
+ def strong_constrains(self) -> List[str]:
234
+ """
235
+ Strong constrains apply a constrain dependency from build to host and run.
236
+
237
+ Examples
238
+ --------
239
+ ```python
240
+ >>> run_exports = RunExportsJson.from_path(
241
+ ... "../test-data/python-3.10.6-h2c4edbf_0_cpython-run_exports.json"
242
+ ... )
243
+ >>> run_exports.strong_constrains
244
+ []
245
+ >>> run_exports.strong_constrains = ['strong_constrain 5.0']
246
+ >>> run_exports.strong_constrains
247
+ ['strong_constrain 5.0']
248
+ >>>
249
+ ```
250
+ """
251
+ return self._inner.strong_constrains
252
+
253
+ @strong_constrains.setter
254
+ def strong_constrains(self, value: List[str]) -> None:
255
+ self._inner.strong_constrains = value
256
+
257
+ @classmethod
258
+ def _from_py_run_exports_json(cls, py_run_exports_json: PyRunExportsJson) -> RunExportsJson:
259
+ run_exports_json = cls.__new__(cls)
260
+ run_exports_json._inner = py_run_exports_json
261
+
262
+ return run_exports_json
263
+
264
+ def __repr__(self) -> str:
265
+ """
266
+ Returns a representation of the RunExportsJson.
267
+ """
268
+ return f"RunExportsJson(weak={self.weak}, strong={self.strong}, noarch={self.noarch}, weak_constrains={self.weak_constrains}, strong_constrains={self.strong_constrains})"
@@ -0,0 +1,26 @@
1
+ from typing import Tuple, Optional
2
+ from os import PathLike
3
+ from rattler.networking.client import Client
4
+
5
+ from rattler.rattler import (
6
+ extract as py_extract,
7
+ extract_tar_bz2 as py_extract_tar_bz2,
8
+ download_and_extract as py_download_and_extract,
9
+ )
10
+
11
+
12
+ def extract(path: PathLike[str], dest: PathLike[str]) -> Tuple[bytes, bytes]:
13
+ """Extract a file to a destination."""
14
+ return py_extract(path, dest)
15
+
16
+
17
+ def extract_tar_bz2(path: PathLike[str], dest: PathLike[str]) -> Tuple[bytes, bytes]:
18
+ """Extract a tar.bz2 file to a destination."""
19
+ return py_extract_tar_bz2(path, dest)
20
+
21
+
22
+ async def download_and_extract(
23
+ client: Client, url: str, dest: PathLike[str], expected_sha: Optional[bytes] = None
24
+ ) -> Tuple[bytes, bytes]:
25
+ """Download a file from a URL and extract it to a destination."""
26
+ return await py_download_and_extract(client._client, url, dest, expected_sha)
@@ -0,0 +1,4 @@
1
+ from rattler.platform.platform import Platform, PlatformLiteral
2
+ from rattler.platform.arch import Arch
3
+
4
+ __all__ = ["Platform", "PlatformLiteral", "Arch"]
@@ -0,0 +1,59 @@
1
+ from __future__ import annotations
2
+
3
+ from rattler.rattler import PyArch
4
+
5
+ from typing import Literal
6
+
7
+ ArchLiteral = Literal[
8
+ "x86",
9
+ "x86_64",
10
+ "aarch64",
11
+ "armv6l",
12
+ "armv7l",
13
+ "loongarch64",
14
+ "ppc64le",
15
+ "ppc64",
16
+ "s390x",
17
+ "riscv32",
18
+ "riscv64",
19
+ ]
20
+
21
+
22
+ class Arch:
23
+ def __init__(self, value: ArchLiteral) -> None:
24
+ self._inner = PyArch(value)
25
+
26
+ @classmethod
27
+ def _from_py_arch(cls, py_arch: PyArch) -> Arch:
28
+ """Construct Rattler version from FFI PyArch object."""
29
+ arch = cls.__new__(cls)
30
+ arch._inner = py_arch
31
+ return arch
32
+
33
+ def __str__(self) -> str:
34
+ """
35
+ Returns a string representation of the architecture.
36
+
37
+ Examples
38
+ --------
39
+ ```python
40
+ >>> str(Arch("x86_64"))
41
+ 'x86_64'
42
+ >>>
43
+ ```
44
+ """
45
+ return self._inner.as_str()
46
+
47
+ def __repr__(self) -> str:
48
+ """
49
+ Returns a representation of the architecture.
50
+
51
+ Examples
52
+ --------
53
+ ```python
54
+ >>> Arch("aarch64")
55
+ Arch(aarch64)
56
+ >>>
57
+ ```
58
+ """
59
+ return f"Arch({self._inner.as_str()})"
@@ -0,0 +1,217 @@
1
+ from __future__ import annotations
2
+ from collections.abc import Iterator
3
+ from typing import Any, Dict, Literal, Tuple, Optional
4
+
5
+ from rattler.rattler import PyPlatform
6
+ from rattler.platform.arch import Arch
7
+
8
+ PlatformLiteral = Literal[
9
+ "noarch",
10
+ "unknown",
11
+ "linux-32",
12
+ "linux-64",
13
+ "linux-aarch64",
14
+ "linux-armv6l",
15
+ "linux-armv7l",
16
+ "linux-loongarch64",
17
+ "linux-ppc64le",
18
+ "linux-ppc64",
19
+ "linux-ppc",
20
+ "linux-s390x",
21
+ "linux-riscv32",
22
+ "linux-riscv64",
23
+ "freebsd-64",
24
+ "osx-64",
25
+ "osx-arm64",
26
+ "win-32",
27
+ "win-64",
28
+ "win-arm64",
29
+ "emscripten-wasm32",
30
+ "wasi-wasm32",
31
+ "zos-z",
32
+ ]
33
+
34
+
35
+ class PlatformSingleton(type):
36
+ _instances: Dict[str, Platform]
37
+
38
+ def __init__(cls, *args: Tuple[Any], **kwargs: Dict[Any, Any]) -> None:
39
+ cls._instances = {}
40
+
41
+ def __call__(cls, platform: str, *args: Tuple[Any], **kwargs: Dict[Any, Any]) -> Platform:
42
+ try:
43
+ return cls._instances[platform]
44
+ except KeyError:
45
+ pass
46
+
47
+ instance = super().__call__(platform, *args, **kwargs)
48
+ cls._instances[platform] = instance
49
+ return instance
50
+
51
+
52
+ class Platform(metaclass=PlatformSingleton):
53
+ def __init__(self, value: PlatformLiteral | str):
54
+ self._inner = PyPlatform(value)
55
+
56
+ @classmethod
57
+ def _from_py_platform(cls, py_platform: PyPlatform) -> Platform:
58
+ """Construct Rattler version from FFI PyArch object."""
59
+ try:
60
+ platform = cls._instances[py_platform.name]
61
+ except KeyError:
62
+ platform = cls.__new__(cls)
63
+ platform._inner = py_platform
64
+ cls._instances[str(platform)] = platform
65
+ return platform
66
+
67
+ def __str__(self) -> str:
68
+ """
69
+ Returns a string representation of the platform.
70
+
71
+ Examples
72
+ --------
73
+ ```python
74
+ >>> str(Platform("linux-64"))
75
+ 'linux-64'
76
+ >>>
77
+ ```
78
+ """
79
+ return self._inner.name
80
+
81
+ def __repr__(self) -> str:
82
+ """
83
+ Returns a representation of the platform.
84
+
85
+ Examples
86
+ --------
87
+ ```python
88
+ >>> Platform("linux-64")
89
+ Platform(linux-64)
90
+ >>>
91
+ ```
92
+ """
93
+ return f"Platform({self._inner.name})"
94
+
95
+ @classmethod
96
+ def current(cls) -> Platform:
97
+ """
98
+ Returns the current platform.
99
+ """
100
+ return cls._from_py_platform(PyPlatform.current())
101
+
102
+ @classmethod
103
+ def all(cls) -> Iterator[Platform]:
104
+ """
105
+ Returns all supported platforms.
106
+
107
+ Examples
108
+ --------
109
+ ```python
110
+ >>> next(Platform.all())
111
+ Platform(noarch)
112
+ >>> len(list(Platform.all()))
113
+ 23
114
+ >>>
115
+ """
116
+ return (cls._from_py_platform(p) for p in PyPlatform.all())
117
+
118
+ @property
119
+ def is_linux(self) -> bool:
120
+ """
121
+ Return True if the platform is linux.
122
+
123
+ Examples
124
+ --------
125
+ ```python
126
+ >>> Platform("linux-64").is_linux
127
+ True
128
+ >>> Platform("osx-64").is_linux
129
+ False
130
+ >>>
131
+ ```
132
+ """
133
+ return self._inner.is_linux
134
+
135
+ @property
136
+ def is_osx(self) -> bool:
137
+ """
138
+ Return True if the platform is osx.
139
+
140
+ Examples
141
+ --------
142
+ ```python
143
+ >>> Platform("osx-64").is_osx
144
+ True
145
+ >>> Platform("linux-64").is_osx
146
+ False
147
+ >>>
148
+ ```
149
+ """
150
+ return self._inner.is_osx
151
+
152
+ @property
153
+ def is_windows(self) -> bool:
154
+ """
155
+ Return True if the platform is win.
156
+
157
+ Examples
158
+ --------
159
+ ```python
160
+ >>> Platform("win-64").is_windows
161
+ True
162
+ >>> Platform("linux-64").is_windows
163
+ False
164
+ >>>
165
+ ```
166
+ """
167
+ return self._inner.is_windows
168
+
169
+ @property
170
+ def is_unix(self) -> bool:
171
+ """
172
+ Return True if the platform is unix.
173
+
174
+ Examples
175
+ --------
176
+ ```python
177
+ >>> Platform("linux-64").is_unix
178
+ True
179
+ >>> Platform("win-64").is_unix
180
+ False
181
+ >>>
182
+ ```
183
+ """
184
+ return self._inner.is_unix
185
+
186
+ @property
187
+ def arch(self) -> Optional[Arch]:
188
+ """
189
+ Return the architecture of the platform.
190
+
191
+ Examples
192
+ --------
193
+ ```python
194
+ >>> Platform("linux-64").arch
195
+ Arch(x86_64)
196
+ >>> Platform("linux-aarch64").arch
197
+ Arch(aarch64)
198
+ >>>
199
+ ```
200
+ """
201
+ arch = self._inner.arch()
202
+ return Arch._from_py_arch(arch) if arch is not None else None
203
+
204
+ @property
205
+ def only_platform(self) -> Optional[str]:
206
+ """
207
+ Return the platform without the architecture.
208
+
209
+ Examples
210
+ --------
211
+ ```python
212
+ >>> Platform("linux-64").only_platform
213
+ 'linux'
214
+ >>>
215
+ ```
216
+ """
217
+ return self._inner.only_platform
@@ -0,0 +1,4 @@
1
+ from rattler.prefix.prefix_record import PrefixRecord, Link, LinkType
2
+ from rattler.prefix.prefix_paths import PrefixPaths, PrefixPathsEntry, PrefixPathType
3
+
4
+ __all__ = ["PrefixRecord", "PrefixPaths", "PrefixPathsEntry", "PrefixPathType", "Link", "LinkType"]