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,118 @@
1
+ from __future__ import annotations
2
+ import os
3
+ from typing import Dict, List, Optional, Tuple
4
+ from rattler.lock.environment import Environment
5
+
6
+ from rattler.rattler import PyLockFile
7
+
8
+
9
+ class LockFile:
10
+ """
11
+ Represents a lock-file for both Conda packages and Pypi packages.
12
+ Lock-files can store information for multiple platforms and for multiple environments.
13
+ """
14
+
15
+ _lock_file: PyLockFile
16
+
17
+ def __init__(self, envs: Dict[str, Environment]) -> None:
18
+ """
19
+ Create a new rattler-lock file.
20
+
21
+ `envs` maps each environment to its name.
22
+ """
23
+ self._lock_file = PyLockFile({name: env._env for (name, env) in envs.items()})
24
+
25
+ @staticmethod
26
+ def from_path(path: os.PathLike[str]) -> LockFile:
27
+ """
28
+ Parses a rattler-lock file from a file.
29
+
30
+ Examples
31
+ --------
32
+ ```python
33
+ >>> lock_file = LockFile.from_path("./pixi.lock")
34
+ >>> lock_file
35
+ LockFile()
36
+ >>>
37
+ ```
38
+ """
39
+ return LockFile._from_py_lock_file(PyLockFile.from_path(path))
40
+
41
+ def to_path(self, path: os.PathLike[str]) -> None:
42
+ """
43
+ Writes the rattler-lock to a file.
44
+
45
+ Examples
46
+ --------
47
+ ```python
48
+ >>> import tempfile
49
+ >>> lock_file = LockFile.from_path("./pixi.lock")
50
+ >>> with tempfile.NamedTemporaryFile() as fp:
51
+ ... lock_file.to_path(fp.name)
52
+ >>>
53
+ ```
54
+ """
55
+ return self._lock_file.to_path(path)
56
+
57
+ def environments(self) -> List[Tuple[str, Environment]]:
58
+ """
59
+ Returns an iterator over all environments defined in the lock-file.
60
+
61
+ Examples
62
+ --------
63
+ ```python
64
+ >>> lock_file = LockFile.from_path("./pixi.lock")
65
+ >>> sorted(lock_file.environments())
66
+ [('default', Environment()), ('docs', Environment()), ('repl', Environment()), ('test', Environment())]
67
+ >>>
68
+ ```
69
+ """
70
+ return [(name, Environment._from_py_environment(e)) for (name, e) in self._lock_file.environments()]
71
+
72
+ def environment(self, name: str) -> Optional[Environment]:
73
+ """
74
+ Returns the environment with the given name.
75
+
76
+ Examples
77
+ --------
78
+ ```python
79
+ >>> lock_file = LockFile.from_path("./pixi.lock")
80
+ >>> lock_file.environment("default")
81
+ Environment()
82
+ >>> lock_file.environment("doesnt-exist")
83
+ >>>
84
+ ```
85
+ """
86
+ if env := self._lock_file.environment(name):
87
+ return Environment._from_py_environment(env)
88
+ return None
89
+
90
+ def default_environment(self) -> Optional[Environment]:
91
+ """
92
+ Returns the environment with the default name as defined by [`DEFAULT_ENVIRONMENT_NAME`].
93
+
94
+ Examples
95
+ --------
96
+ ```python
97
+ >>> lock_file = LockFile.from_path("./pixi.lock")
98
+ >>> lock_file.default_environment()
99
+ Environment()
100
+ >>>
101
+ ```
102
+ """
103
+ return Environment._from_py_environment(self._lock_file.default_environment())
104
+
105
+ @classmethod
106
+ def _from_py_lock_file(cls, py_lock_file: PyLockFile) -> LockFile:
107
+ """
108
+ Construct Rattler LockFile from FFI PyLockFile object.
109
+ """
110
+ lock_file = cls.__new__(cls)
111
+ lock_file._lock_file = py_lock_file
112
+ return lock_file
113
+
114
+ def __repr__(self) -> str:
115
+ """
116
+ Returns a representation of the LockFile.
117
+ """
118
+ return "LockFile()"
@@ -0,0 +1,302 @@
1
+ from __future__ import annotations
2
+ from abc import ABC
3
+ from typing import Optional, Set, List
4
+
5
+ from rattler import PackageRecord, Version, RepoDataRecord
6
+
7
+ from rattler.rattler import PyLockedPackage
8
+ from rattler.lock.hash import PackageHashes
9
+ from rattler.match_spec import MatchSpec
10
+
11
+
12
+ class LockedPackage(ABC):
13
+ """
14
+ Base class for any package in a lock file.
15
+ """
16
+
17
+ _package: PyLockedPackage
18
+
19
+ @property
20
+ def name(self) -> str:
21
+ """
22
+ Returns the name of the package as recorded in the lock-file.
23
+
24
+ Note that this might not perse be the normalized name according to the specific ecosystem for the package.
25
+
26
+ Examples
27
+ --------
28
+ ```python
29
+ >>> from rattler import Platform, LockFile
30
+ >>> lock_file = LockFile.from_path("../test-data/test.lock")
31
+ >>> env = lock_file.default_environment()
32
+ >>> lock_package = env.packages(Platform("osx-arm64"))[0]
33
+ >>> lock_package.name
34
+ 'tzdata'
35
+ >>>
36
+ ```
37
+ """
38
+ return self._package.name
39
+
40
+ @property
41
+ def location(self) -> str:
42
+ """
43
+ Returns the location of the package as recorded in the lock-file.
44
+
45
+ Examples
46
+ --------
47
+ ```python
48
+ >>> from rattler import Platform, LockFile
49
+ >>> lock_file = LockFile.from_path("../test-data/test.lock")
50
+ >>> env = lock_file.default_environment()
51
+ >>> lock_package = env.packages(Platform("osx-arm64"))[0]
52
+ >>> lock_package.location
53
+ 'https://conda.anaconda.org/...'
54
+ >>>
55
+ ```
56
+ """
57
+ return self._package.location
58
+
59
+ @property
60
+ def hashes(self) -> Optional[PackageHashes]:
61
+ """
62
+ Hashes of the file pointed to by `url`.
63
+
64
+ Examples
65
+ --------
66
+ ```python
67
+ >>> from rattler import LockFile, Platform
68
+ >>> lock_file = LockFile.from_path("../test-data/test.lock")
69
+ >>> env = lock_file.default_environment()
70
+ >>> pypi_packages = env.pypi_packages()
71
+ >>> data = pypi_packages[Platform("osx-arm64")][0]
72
+ >>> data.hashes
73
+ PackageHashes()
74
+ >>>
75
+ ```
76
+ """
77
+ return PackageHashes._from_py_package_hashes(self._package.hashes)
78
+
79
+ def __repr__(self) -> str:
80
+ """
81
+ Returns a representation of the LockedPackage.
82
+ """
83
+ return f"{type(self).__name__}(name={self.name!r},location={self.location!r})"
84
+
85
+ @classmethod
86
+ def _from_py_locked_package(cls, py_pkg: PyLockedPackage) -> LockedPackage:
87
+ """
88
+ Construct Rattler LockedPackage from FFI PyLockedPackage object.
89
+ """
90
+ pkg: LockedPackage
91
+ if py_pkg.is_conda_binary:
92
+ pkg = CondaLockedBinaryPackage.__new__(CondaLockedBinaryPackage)
93
+ elif py_pkg.is_conda_source:
94
+ pkg = CondaLockedSourcePackage.__new__(CondaLockedSourcePackage)
95
+ elif py_pkg.is_pypi:
96
+ pkg = PypiLockedPackage.__new__(PypiLockedPackage)
97
+ else:
98
+ raise TypeError(
99
+ "Cannot create LockedPackage from PyLockedPackage, the type of the package is not supported."
100
+ )
101
+
102
+ pkg._package = py_pkg
103
+ return pkg
104
+
105
+
106
+ class CondaLockedPackage(LockedPackage, ABC):
107
+ """
108
+ A locked conda package in a lock file.
109
+ """
110
+
111
+ @property
112
+ def package_record(self) -> PackageRecord:
113
+ """
114
+ Returns the metadata of the package as recorded in the lock-file.
115
+ """
116
+ return PackageRecord._from_py_record(self._package.package_record)
117
+
118
+ @property
119
+ def version(self) -> Version:
120
+ """
121
+ Returns the version of the package as recorded in the lock-file.
122
+
123
+ Examples
124
+ --------
125
+ ```python
126
+ >>> from rattler import Platform, LockFile
127
+ >>> lock_file = LockFile.from_path("../test-data/test.lock")
128
+ >>> env = lock_file.default_environment()
129
+ >>> lock_package = env.packages(Platform("osx-arm64"))[0]
130
+ >>> lock_package.version
131
+ Version("2024a")
132
+ >>>
133
+ ```
134
+ """
135
+ return Version._from_py_version(self._package.conda_version)
136
+
137
+ def satisfies(self, spec: MatchSpec | str) -> bool:
138
+ """
139
+ Returns true if this package satisfies the given `spec`.
140
+
141
+ Examples
142
+ --------
143
+ ```python
144
+ >>> from rattler import LockFile, Platform
145
+ >>> lock_file = LockFile.from_path("../test-data/test.lock")
146
+ >>> env = lock_file.default_environment()
147
+ >>> packages = env.packages(Platform("osx-arm64"))
148
+ >>> packages[0].satisfies("tzdata >=2024a")
149
+ True
150
+ >>>
151
+ ```
152
+ """
153
+ if isinstance(spec, str):
154
+ spec = MatchSpec(spec)
155
+
156
+ return self._package.conda_satisfies(spec._match_spec)
157
+
158
+
159
+ class PypiLockedPackage(LockedPackage):
160
+ """
161
+ A locked PyPI package in a lock file.
162
+ """
163
+
164
+ @property
165
+ def version(self) -> str:
166
+ """
167
+ Returns the version of the package as recorded in the lock-file.
168
+ """
169
+ return self._package.pypi_version
170
+
171
+ @property
172
+ def requires_dist(self) -> List[str]:
173
+ """
174
+ A list of dependencies on other packages.
175
+
176
+ Examples
177
+ --------
178
+ ```python
179
+ >>> from rattler import LockFile, Platform
180
+ >>> lock_file = LockFile.from_path("../test-data/test.lock")
181
+ >>> env = lock_file.default_environment()
182
+ >>> pypi_packages = env.pypi_packages()
183
+ >>> data = pypi_packages[Platform("osx-arm64")][0]
184
+ >>> data.requires_dist
185
+ []
186
+ >>>
187
+ ```
188
+ """
189
+ return self._package.pypi_requires_dist
190
+
191
+ @property
192
+ def requires_python(self) -> Optional[str]:
193
+ """
194
+ The python version that this package requires.
195
+
196
+ Examples
197
+ --------
198
+ ```python
199
+ >>> from rattler import LockFile, Platform
200
+ >>> lock_file = LockFile.from_path("../test-data/test.lock")
201
+ >>> env = lock_file.default_environment()
202
+ >>> pypi_packages = env.pypi_packages()
203
+ >>> data = pypi_packages[Platform("osx-arm64")][0]
204
+ >>> data.requires_python
205
+ '>=3.7.0'
206
+ >>>
207
+ ```
208
+ """
209
+ return self._package.pypi_requires_python
210
+
211
+ @property
212
+ def is_editable(self) -> bool:
213
+ """
214
+ Whether the package should be installed in editable mode or not.
215
+
216
+ Examples
217
+ --------
218
+ ```python
219
+ >>> from rattler import LockFile, Platform
220
+ >>> lock_file = LockFile.from_path("../test-data/test.lock")
221
+ >>> env = lock_file.default_environment()
222
+ >>> pypi_packages = env.pypi_packages()
223
+ >>> data = pypi_packages[Platform("osx-arm64")][0]
224
+ >>> data.is_editable
225
+ False
226
+ >>>
227
+ ```
228
+ """
229
+ return self._package.pypi_is_editable
230
+
231
+ @property
232
+ def extras(self) -> Set[str]:
233
+ """
234
+ The extras enabled for the package.
235
+ Note that the order doesn't matter.
236
+
237
+ Examples
238
+ --------
239
+ ```python
240
+ >>> from rattler import LockFile, Platform
241
+ >>> lock_file = LockFile.from_path("../test-data/test.lock")
242
+ >>> env = lock_file.default_environment()
243
+ >>> pypi_packages = env.pypi_packages()
244
+ >>> env_data = pypi_packages[Platform("osx-arm64")][0]
245
+ >>> env_data.extras
246
+ set()
247
+ >>>
248
+ ```
249
+ """
250
+ return self._package.pypi_extras
251
+
252
+ def satisfies(self, spec: str) -> bool:
253
+ """
254
+ Returns true if this package satisfies the given `spec`.
255
+
256
+ Examples
257
+ --------
258
+ ```python
259
+ >>> from rattler import LockFile, Platform
260
+ >>> lock_file = LockFile.from_path("../test-data/test.lock")
261
+ >>> env = lock_file.default_environment()
262
+ >>> pypi_packages = env.pypi_packages()
263
+ >>> data = pypi_packages[Platform("osx-arm64")][0]
264
+ >>> data.satisfies("charset-normalizer")
265
+ True
266
+ >>>
267
+ ```
268
+ """
269
+ return self._package.pypi_satisfies(spec)
270
+
271
+ @classmethod
272
+ def _from_py_locked_package(cls, py_pkg: PyLockedPackage) -> PypiLockedPackage:
273
+ """
274
+ Construct Rattler LockedPackage from FFI PyLockedPackage object.
275
+ """
276
+ if py_pkg.is_pypi:
277
+ pkg = PypiLockedPackage.__new__(PypiLockedPackage)
278
+ else:
279
+ raise TypeError(
280
+ "Cannot create PypiLockedPackage from PyLockedPackage, the type of the package is not supported."
281
+ )
282
+
283
+ pkg._package = py_pkg
284
+ return pkg
285
+
286
+
287
+ class CondaLockedSourcePackage(CondaLockedPackage):
288
+ """
289
+ A locked conda source package in a lock file.
290
+ """
291
+
292
+
293
+ class CondaLockedBinaryPackage(CondaLockedPackage):
294
+ """
295
+ A locked conda binary package in a lock file.
296
+ """
297
+
298
+ def repo_data_record(self) -> RepoDataRecord:
299
+ """
300
+ Returns the metadata of the package as recorded in the lock-file including location information.
301
+ """
302
+ return RepoDataRecord._from_py_record(self._package.repo_data_record)
@@ -0,0 +1,4 @@
1
+ from rattler.match_spec.match_spec import MatchSpec
2
+ from rattler.match_spec.nameless_match_spec import NamelessMatchSpec
3
+
4
+ __all__ = ["MatchSpec", "NamelessMatchSpec"]