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,204 @@
1
+ from __future__ import annotations
2
+
3
+ from rattler.rattler import PyPackageName
4
+
5
+
6
+ class PackageName:
7
+ def __init__(self, source: str) -> None:
8
+ if not isinstance(source, str):
9
+ raise TypeError(
10
+ "PackageName constructor received unsupported type "
11
+ f" {type(source).__name__!r} for the `source` parameter"
12
+ )
13
+ self._name = PyPackageName(source)
14
+
15
+ @staticmethod
16
+ def unchecked(normalized: str) -> PackageName:
17
+ """
18
+ Constructs a new `PackageName` from a string without checking if the string is actually a
19
+ valid or normalized conda package name. This should only be used if you are sure that the
20
+ input string is valid.
21
+
22
+ Examples
23
+ --------
24
+ ```python
25
+ >>> p = PackageName.unchecked("test_xyz")
26
+ >>>
27
+ ```
28
+ """
29
+ return PackageName._from_py_package_name(PyPackageName.new_unchecked(normalized))
30
+
31
+ @staticmethod
32
+ def from_matchspec_str(spec: str) -> PackageName:
33
+ """
34
+ Parses the package name part from a matchspec string without parsing the entire matchspec.
35
+
36
+ This extracts the package name by splitting on whitespace or version constraint characters
37
+ (`>`, `<`, `=`, `!`, `~`, `;`).
38
+
39
+ Examples
40
+ --------
41
+ ```python
42
+ >>> p = PackageName.from_matchspec_str("numpy>=1.0,<2.0")
43
+ >>> p.source
44
+ 'numpy'
45
+ >>> p = PackageName.from_matchspec_str("pillow >=10")
46
+ >>> p.source
47
+ 'pillow'
48
+ >>>
49
+ ```
50
+ """
51
+ return PackageName._from_py_package_name(PyPackageName.from_matchspec_str(spec))
52
+
53
+ @staticmethod
54
+ def from_matchspec_str_unchecked(spec: str) -> PackageName:
55
+ """
56
+ Parses the package name part from a matchspec string without parsing the entire matchspec.
57
+ This function assumes the matchspec string is a valid matchspec.
58
+
59
+ This extracts the package name by splitting on whitespace or version constraint characters
60
+ (`>`, `<`, `=`, `!`, `~`, `;`). The original capitalization is preserved in the source,
61
+ while the normalized version is lowercase.
62
+
63
+ Examples
64
+ --------
65
+ ```python
66
+ >>> p = PackageName.from_matchspec_str_unchecked("Pillow >=10")
67
+ >>> p.source
68
+ 'Pillow'
69
+ >>> p.normalized
70
+ 'pillow'
71
+ >>>
72
+ ```
73
+ """
74
+ return PackageName._from_py_package_name(PyPackageName.from_matchspec_str_unchecked(spec))
75
+
76
+ @classmethod
77
+ def _from_py_package_name(cls, py_package_name: PyPackageName) -> PackageName:
78
+ """Construct Rattler PackageName from FFI PyPackageName object."""
79
+ package_name = cls.__new__(cls)
80
+ package_name._name = py_package_name
81
+ return package_name
82
+
83
+ @property
84
+ def source(self) -> str:
85
+ """
86
+ Returns the source representation of the package name.
87
+ This is the string from which this instance was created.
88
+
89
+ Examples
90
+ --------
91
+ ```python
92
+ >>> p = PackageName("test-xyz")
93
+ >>> p.source
94
+ 'test-xyz'
95
+ >>>
96
+ ```
97
+ """
98
+ return self._name.source
99
+
100
+ @property
101
+ def normalized(self) -> str:
102
+ """
103
+ Returns the normalized version of the package name.
104
+ The normalized string is guaranteed to be a valid conda package name.
105
+
106
+ Examples
107
+ --------
108
+ ```python
109
+ >>> p = PackageName("test-xyz")
110
+ >>> p.normalized
111
+ 'test-xyz'
112
+ >>>
113
+ ```
114
+ """
115
+ return self._name.normalized
116
+
117
+ def __hash__(self) -> int:
118
+ """
119
+ Computes the hash of this instance.
120
+
121
+ Examples
122
+ --------
123
+ ```python
124
+ >>> hash(PackageName("test-abc")) == hash(PackageName("test-abc"))
125
+ True
126
+ >>> hash(PackageName("test-abc")) == hash(PackageName("test-ABC"))
127
+ True
128
+ >>> hash(PackageName("test-abc")) == hash(PackageName("abc-test"))
129
+ False
130
+ >>>
131
+ ```
132
+ """
133
+ return self._name.__hash__()
134
+
135
+ def __eq__(self, other: object) -> bool:
136
+ """
137
+ Returns True if this instance represents the same PackageName as `other`.
138
+
139
+ Examples
140
+ --------
141
+ ```python
142
+ >>> PackageName("test-abc") == PackageName("abc-test")
143
+ False
144
+ >>> PackageName("test-abc") == PackageName("test-abc")
145
+ True
146
+ >>> PackageName("test-abc") == PackageName("test-ABC")
147
+ True
148
+ >>> PackageName("test-abc") == "test-abc"
149
+ True
150
+ >>> PackageName("test-abc") == "not-test-abc"
151
+ False
152
+ >>>
153
+ ```
154
+ """
155
+ if isinstance(other, str):
156
+ return self._name == PyPackageName(other)
157
+
158
+ if not isinstance(other, PackageName):
159
+ return False
160
+
161
+ return self._name == other._name
162
+
163
+ def __ne__(self, other: object) -> bool:
164
+ """
165
+ Returns True if this instance does not represents the same PackageName as `other`.
166
+
167
+ Examples
168
+ --------
169
+ ```python
170
+ >>> PackageName("test-abc") != PackageName("test-abc")
171
+ False
172
+ >>> PackageName("test-abc") != PackageName("test-ABC")
173
+ False
174
+ >>> PackageName("test-abc") != PackageName("abc-test")
175
+ True
176
+ >>> PackageName("test-abc") != "test-abc"
177
+ False
178
+ >>> PackageName("test-abc") != "not-test-abc"
179
+ True
180
+ >>>
181
+ ```
182
+ """
183
+ if isinstance(other, str):
184
+ return self._name != PyPackageName(other)
185
+
186
+ if not isinstance(other, PackageName):
187
+ return True
188
+
189
+ return self._name != other._name
190
+
191
+ def __repr__(self) -> str:
192
+ """
193
+ Returns a representation of the PackageName.
194
+
195
+ Examples
196
+ --------
197
+ ```python
198
+ >>> p = PackageName("test-xyz")
199
+ >>> p
200
+ PackageName("test-xyz")
201
+ >>>
202
+ ```
203
+ """
204
+ return f'PackageName("{self.source}")'
@@ -0,0 +1,81 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Union
4
+
5
+ from rattler.package.package_name import PackageName
6
+ from rattler.rattler import PyPackageNameMatcher
7
+
8
+
9
+ class PackageNameMatcher:
10
+ """
11
+ A class representing a package name matcher.
12
+
13
+ Examples
14
+ --------
15
+ ```python
16
+ >>> PackageNameMatcher("rattler")
17
+ PackageNameMatcher("rattler", exact)
18
+ >>> PackageNameMatcher("jupyter-*")
19
+ PackageNameMatcher("jupyter-*", glob)
20
+ >>> PackageNameMatcher("^jupyter-.*$")
21
+ PackageNameMatcher("^jupyter-.*$", regex)
22
+ >>>
23
+ ```
24
+ """
25
+
26
+ _package_name_matcher: PyPackageNameMatcher
27
+
28
+ def __init__(self, package_name_matcher: str):
29
+ self._package_name_matcher = PyPackageNameMatcher(package_name_matcher)
30
+
31
+ def __repr__(self) -> str:
32
+ inner = self._package_name_matcher.display_inner()
33
+ return f"{type(self).__name__}({inner})"
34
+
35
+ @classmethod
36
+ def _from_py_package_name_matcher(cls, py_package_name_matcher: PyPackageNameMatcher) -> PackageNameMatcher:
37
+ """Construct Rattler PackageNameMatcher from FFI PyPackageName object."""
38
+ package_name_matcher = cls.__new__(cls)
39
+ package_name_matcher._package_name_matcher = py_package_name_matcher
40
+ return package_name_matcher
41
+
42
+ @property
43
+ def normalized(self) -> str:
44
+ """
45
+ Returns the normalized string representation of the matcher.
46
+
47
+ For exact matches, returns the normalized package name.
48
+ For glob and regex patterns, returns the pattern string.
49
+
50
+ Examples
51
+ --------
52
+ ```python
53
+ >>> PackageNameMatcher("rattler").normalized
54
+ 'rattler'
55
+ >>> PackageNameMatcher("jupyter-*").normalized
56
+ 'jupyter-*'
57
+ >>> PackageNameMatcher("^jupyter-.*$").normalized
58
+ '^jupyter-.*$'
59
+ >>>
60
+ ```
61
+ """
62
+ return self._package_name_matcher.normalized
63
+
64
+ def as_package_name(self) -> Union[PackageName, None]:
65
+ """
66
+ Converts a PackageNameMatcher to a PackageName if it is an exact matcher.
67
+
68
+ Examples
69
+ --------
70
+ ```python
71
+ >>> PackageNameMatcher("rattler").as_package_name()
72
+ PackageName("rattler")
73
+ >>> PackageNameMatcher("jupyter-*").as_package_name()
74
+ >>> PackageNameMatcher("^jupyter-.*$").as_package_name()
75
+ >>>
76
+ ```
77
+ """
78
+ py_package_name = self._package_name_matcher.as_package_name()
79
+ if py_package_name is None:
80
+ return None
81
+ return PackageName._from_py_package_name(py_package_name)