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,184 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from rattler.rattler import PyVersionSpec
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from rattler.version.version import Version
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class VersionSpec:
|
|
12
|
+
"""
|
|
13
|
+
A version specification represents a constraint on a version.
|
|
14
|
+
|
|
15
|
+
Version specifications can be simple like ">=1.2.3" or complex
|
|
16
|
+
with multiple constraints like ">=1.2.3,<2.0.0" or ">=1.2.3|<1.0.0".
|
|
17
|
+
|
|
18
|
+
Examples
|
|
19
|
+
--------
|
|
20
|
+
```python
|
|
21
|
+
>>> from rattler import VersionSpec, Version
|
|
22
|
+
>>> spec = VersionSpec(">=1.2.3,<2.0.0")
|
|
23
|
+
>>> version = Version("1.5.0")
|
|
24
|
+
>>> spec.matches(version)
|
|
25
|
+
True
|
|
26
|
+
>>> version2 = Version("2.1.0")
|
|
27
|
+
>>> spec.matches(version2)
|
|
28
|
+
False
|
|
29
|
+
>>>
|
|
30
|
+
```
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
_spec: PyVersionSpec
|
|
34
|
+
|
|
35
|
+
def __init__(self, spec: str, strict: bool = False) -> None:
|
|
36
|
+
"""
|
|
37
|
+
Construct a new VersionSpec from a string.
|
|
38
|
+
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
spec : str
|
|
42
|
+
The version specification string (e.g., ">=1.2.3,<2.0.0")
|
|
43
|
+
strict : bool, optional
|
|
44
|
+
If True, use strict parsing mode (default: False)
|
|
45
|
+
|
|
46
|
+
Raises
|
|
47
|
+
------
|
|
48
|
+
InvalidVersionSpecError
|
|
49
|
+
If the version specification string is invalid
|
|
50
|
+
|
|
51
|
+
Examples
|
|
52
|
+
--------
|
|
53
|
+
```python
|
|
54
|
+
>>> spec = VersionSpec(">=1.2.3,<2.0.0")
|
|
55
|
+
>>> spec_strict = VersionSpec(">=1.2.3", strict=True)
|
|
56
|
+
>>> spec_any = VersionSpec("*")
|
|
57
|
+
>>>
|
|
58
|
+
```
|
|
59
|
+
"""
|
|
60
|
+
if isinstance(spec, str):
|
|
61
|
+
self._spec = PyVersionSpec(spec, strict)
|
|
62
|
+
else:
|
|
63
|
+
raise TypeError(
|
|
64
|
+
f"VersionSpec constructor received unsupported type {type(spec).__name__!r} for the `spec` parameter"
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def _from_py_version_spec(cls, py_spec: PyVersionSpec) -> VersionSpec:
|
|
69
|
+
"""Construct Rattler VersionSpec from FFI PyVersionSpec object."""
|
|
70
|
+
spec = cls.__new__(cls)
|
|
71
|
+
spec._spec = py_spec
|
|
72
|
+
return spec
|
|
73
|
+
|
|
74
|
+
def matches(self, version: Version) -> bool:
|
|
75
|
+
"""
|
|
76
|
+
Check if a version matches this version specification.
|
|
77
|
+
|
|
78
|
+
Parameters
|
|
79
|
+
----------
|
|
80
|
+
version : Version
|
|
81
|
+
The version to check
|
|
82
|
+
|
|
83
|
+
Returns
|
|
84
|
+
-------
|
|
85
|
+
bool
|
|
86
|
+
True if the version matches the specification, False otherwise
|
|
87
|
+
|
|
88
|
+
Examples
|
|
89
|
+
--------
|
|
90
|
+
```python
|
|
91
|
+
>>> from rattler import VersionSpec, Version
|
|
92
|
+
>>> spec = VersionSpec(">=1.2.3,<2.0.0")
|
|
93
|
+
>>> spec.matches(Version("1.5.0"))
|
|
94
|
+
True
|
|
95
|
+
>>> spec.matches(Version("2.1.0"))
|
|
96
|
+
False
|
|
97
|
+
>>> spec.matches(Version("1.2.3"))
|
|
98
|
+
True
|
|
99
|
+
>>> spec.matches(Version("2.0.0"))
|
|
100
|
+
False
|
|
101
|
+
>>>
|
|
102
|
+
```
|
|
103
|
+
"""
|
|
104
|
+
return self._spec.matches(version._version)
|
|
105
|
+
|
|
106
|
+
def __str__(self) -> str:
|
|
107
|
+
"""
|
|
108
|
+
Returns the string representation of the version specification.
|
|
109
|
+
|
|
110
|
+
Examples
|
|
111
|
+
--------
|
|
112
|
+
```python
|
|
113
|
+
>>> str(VersionSpec(">=1.2.3,<2.0.0"))
|
|
114
|
+
'>=1.2.3,<2.0.0'
|
|
115
|
+
>>>
|
|
116
|
+
```
|
|
117
|
+
"""
|
|
118
|
+
return self._spec.as_str()
|
|
119
|
+
|
|
120
|
+
def __repr__(self) -> str:
|
|
121
|
+
"""
|
|
122
|
+
Returns a representation of the version specification.
|
|
123
|
+
|
|
124
|
+
Examples
|
|
125
|
+
--------
|
|
126
|
+
```python
|
|
127
|
+
>>> VersionSpec(">=1.2.3,<2.0.0")
|
|
128
|
+
VersionSpec(">=1.2.3,<2.0.0")
|
|
129
|
+
>>>
|
|
130
|
+
```
|
|
131
|
+
"""
|
|
132
|
+
return f'VersionSpec("{self._spec.as_str()}")'
|
|
133
|
+
|
|
134
|
+
def __hash__(self) -> int:
|
|
135
|
+
"""
|
|
136
|
+
Computes the hash of this instance.
|
|
137
|
+
|
|
138
|
+
Examples
|
|
139
|
+
--------
|
|
140
|
+
```python
|
|
141
|
+
>>> hash(VersionSpec(">=1.2.3")) == hash(VersionSpec(">=1.2.3"))
|
|
142
|
+
True
|
|
143
|
+
>>> hash(VersionSpec(">=1.2.3")) == hash(VersionSpec(">=2.0.0"))
|
|
144
|
+
False
|
|
145
|
+
>>>
|
|
146
|
+
```
|
|
147
|
+
"""
|
|
148
|
+
return self._spec.__hash__()
|
|
149
|
+
|
|
150
|
+
def __eq__(self, other: object) -> bool:
|
|
151
|
+
"""
|
|
152
|
+
Returns True if this instance represents the same version spec as `other`.
|
|
153
|
+
|
|
154
|
+
Examples
|
|
155
|
+
--------
|
|
156
|
+
```python
|
|
157
|
+
>>> VersionSpec(">=1.2.3") == VersionSpec(">=1.2.3")
|
|
158
|
+
True
|
|
159
|
+
>>> VersionSpec(">=1.2.3") == VersionSpec(">=2.0.0")
|
|
160
|
+
False
|
|
161
|
+
>>>
|
|
162
|
+
```
|
|
163
|
+
"""
|
|
164
|
+
if not isinstance(other, VersionSpec):
|
|
165
|
+
return NotImplemented
|
|
166
|
+
return self._spec == other._spec
|
|
167
|
+
|
|
168
|
+
def __ne__(self, other: object) -> bool:
|
|
169
|
+
"""
|
|
170
|
+
Returns False if this instance represents the same version spec as `other`.
|
|
171
|
+
|
|
172
|
+
Examples
|
|
173
|
+
--------
|
|
174
|
+
```python
|
|
175
|
+
>>> VersionSpec(">=1.2.3") != VersionSpec(">=1.2.3")
|
|
176
|
+
False
|
|
177
|
+
>>> VersionSpec(">=1.2.3") != VersionSpec(">=2.0.0")
|
|
178
|
+
True
|
|
179
|
+
>>>
|
|
180
|
+
```
|
|
181
|
+
"""
|
|
182
|
+
if not isinstance(other, VersionSpec):
|
|
183
|
+
return NotImplemented
|
|
184
|
+
return self._spec != other._spec
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Union, Optional
|
|
4
|
+
|
|
5
|
+
from rattler.rattler import PyVersion
|
|
6
|
+
|
|
7
|
+
from rattler.version import Version
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class VersionWithSource(Version):
|
|
11
|
+
"""
|
|
12
|
+
Holds a version and the string it was created from. This is useful if
|
|
13
|
+
you want to retain the original string the version was created from.
|
|
14
|
+
This might be useful in cases where you have multiple strings that
|
|
15
|
+
are represented by the same [`Version`] but you still want to be able to
|
|
16
|
+
distinguish them.
|
|
17
|
+
|
|
18
|
+
The string `1.1` and `1.01` represent the same version. When you print
|
|
19
|
+
the parsed version though it will come out as `1.1`. You loose the
|
|
20
|
+
original representation. This class stores the original source string,
|
|
21
|
+
which can be accessed by `source` property.
|
|
22
|
+
|
|
23
|
+
This class derives from `Version` which allows you to compare it with
|
|
24
|
+
other `Version` objects.
|
|
25
|
+
|
|
26
|
+
Comparison will be done based on the parsed version, not the source string.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
_source: str
|
|
30
|
+
|
|
31
|
+
def __init__(self, version: Union[str, Version]):
|
|
32
|
+
if not isinstance(version, (str, Version)):
|
|
33
|
+
raise TypeError(
|
|
34
|
+
"VersionWithSource constructor received unsupported type "
|
|
35
|
+
f" {type(version).__name__!r} for the `version` parameter"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
if isinstance(version, str):
|
|
39
|
+
self._source = version
|
|
40
|
+
self._version = PyVersion(version)
|
|
41
|
+
|
|
42
|
+
if isinstance(version, Version):
|
|
43
|
+
self._source = str(version)
|
|
44
|
+
self._version = version._version
|
|
45
|
+
|
|
46
|
+
@classmethod
|
|
47
|
+
def _from_py_version(cls, py_version: PyVersion, source: Optional[str] = None) -> VersionWithSource:
|
|
48
|
+
"""Construct Rattler version from FFI PyVersion object."""
|
|
49
|
+
version = cls.__new__(cls)
|
|
50
|
+
version._version = py_version
|
|
51
|
+
version._source = source or py_version.as_str()
|
|
52
|
+
return version
|
|
53
|
+
|
|
54
|
+
def __str__(self) -> str:
|
|
55
|
+
"""
|
|
56
|
+
Returns the string representation of the version
|
|
57
|
+
|
|
58
|
+
Examples
|
|
59
|
+
--------
|
|
60
|
+
```python
|
|
61
|
+
>>> str(VersionWithSource("1.02.3"))
|
|
62
|
+
'1.02.3'
|
|
63
|
+
>>>
|
|
64
|
+
```
|
|
65
|
+
"""
|
|
66
|
+
return self._source
|
|
67
|
+
|
|
68
|
+
def __repr__(self) -> str:
|
|
69
|
+
"""
|
|
70
|
+
Returns a representation of the version
|
|
71
|
+
|
|
72
|
+
Examples
|
|
73
|
+
--------
|
|
74
|
+
```python
|
|
75
|
+
>>> VersionWithSource("1.02.3")
|
|
76
|
+
VersionWithSource(version="1.2.3", source="1.02.3")
|
|
77
|
+
>>>
|
|
78
|
+
```
|
|
79
|
+
"""
|
|
80
|
+
return f'{type(self).__name__}(version="{self._version.as_str()}", source="{self._source}")'
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from rattler.version import Version
|
|
4
|
+
from rattler.package import PackageName
|
|
5
|
+
|
|
6
|
+
from rattler.rattler import PyGenericVirtualPackage
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class GenericVirtualPackage:
|
|
10
|
+
_generic_virtual_package: PyGenericVirtualPackage
|
|
11
|
+
|
|
12
|
+
def __init__(self, name: PackageName, version: Version, build_string: str) -> None:
|
|
13
|
+
if not isinstance(name, PackageName):
|
|
14
|
+
raise TypeError(
|
|
15
|
+
"GenericVirtualPackage constructor received unsupported type "
|
|
16
|
+
f" {type(name).__name__!r} for the `name` parameter"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
if not isinstance(version, Version):
|
|
20
|
+
raise TypeError(
|
|
21
|
+
"GenericVirtualPackage constructor received unsupported type "
|
|
22
|
+
f" {type(version).__name__!r} for the `version` parameter"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
if not isinstance(build_string, str):
|
|
26
|
+
raise TypeError(
|
|
27
|
+
"GenericVirtualPackage constructor received unsupported type "
|
|
28
|
+
f" {type(build_string).__name__!r} for the `build_string` parameter"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
self._generic_virtual_package = PyGenericVirtualPackage(name._name, version._version, build_string)
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def name(self) -> PackageName:
|
|
35
|
+
"""
|
|
36
|
+
Returns the name of the package
|
|
37
|
+
|
|
38
|
+
Examples
|
|
39
|
+
--------
|
|
40
|
+
```python
|
|
41
|
+
>>> from rattler.package.package_name import PackageName
|
|
42
|
+
>>> from rattler.version.version import Version
|
|
43
|
+
>>> gvp = GenericVirtualPackage(PackageName("__archspec"), Version("1"), "x86_64")
|
|
44
|
+
>>> gvp.name
|
|
45
|
+
PackageName("__archspec")
|
|
46
|
+
>>> gvp.name.source
|
|
47
|
+
'__archspec'
|
|
48
|
+
>>> gvp.name.normalized
|
|
49
|
+
'__archspec'
|
|
50
|
+
>>>
|
|
51
|
+
```
|
|
52
|
+
"""
|
|
53
|
+
return PackageName._from_py_package_name(self._generic_virtual_package.name)
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def version(self) -> Version:
|
|
57
|
+
"""
|
|
58
|
+
Returns the version of the package
|
|
59
|
+
|
|
60
|
+
Examples
|
|
61
|
+
--------
|
|
62
|
+
```python
|
|
63
|
+
>>> from rattler.package.package_name import PackageName
|
|
64
|
+
>>> from rattler.version.version import Version
|
|
65
|
+
>>> gvp = GenericVirtualPackage(PackageName("__archspec"), Version("1"), "x86_64")
|
|
66
|
+
>>> gvp.version
|
|
67
|
+
Version("1")
|
|
68
|
+
>>>
|
|
69
|
+
```
|
|
70
|
+
"""
|
|
71
|
+
return Version._from_py_version(self._generic_virtual_package.version)
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def build_string(self) -> str:
|
|
75
|
+
"""
|
|
76
|
+
Returns the build identifier of the package.
|
|
77
|
+
|
|
78
|
+
Examples
|
|
79
|
+
--------
|
|
80
|
+
```python
|
|
81
|
+
>>> from rattler.package.package_name import PackageName
|
|
82
|
+
>>> from rattler.version.version import Version
|
|
83
|
+
>>> gvp = GenericVirtualPackage(PackageName("__archspec"), Version("1"), "x86_64")
|
|
84
|
+
>>> gvp.build_string
|
|
85
|
+
'x86_64'
|
|
86
|
+
>>>
|
|
87
|
+
```
|
|
88
|
+
"""
|
|
89
|
+
return self._generic_virtual_package.build_string
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def _from_py_generic_virtual_package(
|
|
93
|
+
cls, py_generic_virtual_package: PyGenericVirtualPackage
|
|
94
|
+
) -> GenericVirtualPackage:
|
|
95
|
+
"""
|
|
96
|
+
Construct Rattler GenericVirtualPackage from FFI
|
|
97
|
+
PyGenericVirtualPackage object.
|
|
98
|
+
"""
|
|
99
|
+
generic_virtual_package = cls.__new__(cls)
|
|
100
|
+
generic_virtual_package._generic_virtual_package = py_generic_virtual_package
|
|
101
|
+
return generic_virtual_package
|
|
102
|
+
|
|
103
|
+
def __str__(self) -> str:
|
|
104
|
+
"""
|
|
105
|
+
Returns the string representation of the GenericVirtualPackage
|
|
106
|
+
|
|
107
|
+
Examples
|
|
108
|
+
--------
|
|
109
|
+
```python
|
|
110
|
+
>>> from rattler.package.package_name import PackageName
|
|
111
|
+
>>> from rattler.version.version import Version
|
|
112
|
+
>>> gvp = GenericVirtualPackage(PackageName("__archspec"), Version("1"), "x86_64")
|
|
113
|
+
>>> str(gvp)
|
|
114
|
+
'__archspec=1=x86_64'
|
|
115
|
+
>>>
|
|
116
|
+
```
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
return self._generic_virtual_package.as_str()
|
|
120
|
+
|
|
121
|
+
def __repr__(self) -> str:
|
|
122
|
+
"""
|
|
123
|
+
Returns a representation of the GenericVirtualPackage
|
|
124
|
+
|
|
125
|
+
Examples
|
|
126
|
+
--------
|
|
127
|
+
```python
|
|
128
|
+
>>> from rattler.package.package_name import PackageName
|
|
129
|
+
>>> from rattler.version.version import Version
|
|
130
|
+
>>> gvp = GenericVirtualPackage(PackageName("__archspec"), Version("1"), "x86_64")
|
|
131
|
+
>>> gvp
|
|
132
|
+
GenericVirtualPackage("__archspec=1=x86_64")
|
|
133
|
+
>>>
|
|
134
|
+
```
|
|
135
|
+
"""
|
|
136
|
+
return f'GenericVirtualPackage("{self._generic_virtual_package.as_str()}")'
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import List
|
|
3
|
+
import warnings
|
|
4
|
+
|
|
5
|
+
from rattler.rattler import PyVirtualPackage, PyOverride, PyVirtualPackageOverrides
|
|
6
|
+
|
|
7
|
+
from rattler.virtual_package.generic import GenericVirtualPackage
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Override:
|
|
11
|
+
"""
|
|
12
|
+
Represents an override for a virtual package.
|
|
13
|
+
An override can be build using
|
|
14
|
+
- `Override.default_env_var()` for overriding the detection with the default environment variable,
|
|
15
|
+
- `Override.env_var(str)` for overriding the detection with a custom environment variable,
|
|
16
|
+
- `Override.string(str)` for passing the version directly, or
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
_override: PyOverride
|
|
20
|
+
|
|
21
|
+
@classmethod
|
|
22
|
+
def _from_py_override(cls, py_override: PyOverride) -> Override:
|
|
23
|
+
"""Construct Rattler Override from FFI PyOverride object."""
|
|
24
|
+
override = cls.__new__(cls)
|
|
25
|
+
override._override = py_override
|
|
26
|
+
return override
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def default_env_var(cls) -> Override:
|
|
30
|
+
"""
|
|
31
|
+
Returns a new instance to indicate that the default environment variable should overwrite the detected information from the host if specified.
|
|
32
|
+
"""
|
|
33
|
+
return cls._from_py_override(PyOverride.default_env_var())
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def env_var(cls, env_var: str) -> Override:
|
|
37
|
+
"""
|
|
38
|
+
Returns the environment variable override for the given environment variable.
|
|
39
|
+
"""
|
|
40
|
+
return cls._from_py_override(PyOverride.env_var(env_var))
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def string(cls, override: str) -> Override:
|
|
44
|
+
"""
|
|
45
|
+
Returns the override for the given string.
|
|
46
|
+
"""
|
|
47
|
+
return cls._from_py_override(PyOverride.string(override))
|
|
48
|
+
|
|
49
|
+
def __str__(self) -> str:
|
|
50
|
+
"""
|
|
51
|
+
Returns string representation of the Override.
|
|
52
|
+
"""
|
|
53
|
+
return self._override.as_str()
|
|
54
|
+
|
|
55
|
+
def __repr__(self) -> str:
|
|
56
|
+
"""
|
|
57
|
+
Returns a representation of the Override.
|
|
58
|
+
"""
|
|
59
|
+
return f"Override({self._override.as_str()})"
|
|
60
|
+
|
|
61
|
+
def __eq__(self, other: object) -> bool:
|
|
62
|
+
"""
|
|
63
|
+
Returns True if the Overrides are equal, False otherwise.
|
|
64
|
+
"""
|
|
65
|
+
if not isinstance(other, Override):
|
|
66
|
+
return NotImplemented
|
|
67
|
+
return self._override == other._override
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class VirtualPackageOverrides:
|
|
71
|
+
_overrides: PyVirtualPackageOverrides
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def _from_py_virtual_package_overrides(
|
|
75
|
+
cls, py_virtual_package_overrides: PyVirtualPackageOverrides
|
|
76
|
+
) -> VirtualPackageOverrides:
|
|
77
|
+
"""Construct Rattler VirtualPackageOverrides from FFI PyVirtualPackageOverrides object."""
|
|
78
|
+
virtual_package_overrides = cls.__new__(cls)
|
|
79
|
+
virtual_package_overrides._overrides = py_virtual_package_overrides
|
|
80
|
+
return virtual_package_overrides
|
|
81
|
+
|
|
82
|
+
def __init__(self, osx: Override | None = None, libc: Override | None = None, cuda: Override | None = None) -> None:
|
|
83
|
+
"""
|
|
84
|
+
Returns the default virtual package overrides. By default, none of the overrides are set.
|
|
85
|
+
"""
|
|
86
|
+
self._overrides = PyVirtualPackageOverrides.none()
|
|
87
|
+
self.osx = osx
|
|
88
|
+
self.libc = libc
|
|
89
|
+
self.cuda = cuda
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def from_env(cls) -> VirtualPackageOverrides:
|
|
93
|
+
"""
|
|
94
|
+
Returns the virtual package overrides for None.
|
|
95
|
+
"""
|
|
96
|
+
return cls._from_py_virtual_package_overrides(PyVirtualPackageOverrides.from_env())
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def osx(self) -> Override | None:
|
|
100
|
+
"""
|
|
101
|
+
Returns the OSX override.
|
|
102
|
+
"""
|
|
103
|
+
override = self._overrides.osx
|
|
104
|
+
return Override._from_py_override(override) if override else None
|
|
105
|
+
|
|
106
|
+
@osx.setter
|
|
107
|
+
def osx(self, override: Override | None) -> None:
|
|
108
|
+
"""
|
|
109
|
+
Sets the OSX override.
|
|
110
|
+
"""
|
|
111
|
+
self._overrides.osx = override._override if override else None
|
|
112
|
+
|
|
113
|
+
@property
|
|
114
|
+
def libc(self) -> Override | None:
|
|
115
|
+
"""
|
|
116
|
+
Returns the libc override.
|
|
117
|
+
"""
|
|
118
|
+
override = self._overrides.libc
|
|
119
|
+
return Override._from_py_override(override) if override else None
|
|
120
|
+
|
|
121
|
+
@libc.setter
|
|
122
|
+
def libc(self, override: Override | None) -> None:
|
|
123
|
+
"""
|
|
124
|
+
Sets the libc override.
|
|
125
|
+
"""
|
|
126
|
+
self._overrides.libc = override._override if override else None
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def cuda(self) -> Override | None:
|
|
130
|
+
"""
|
|
131
|
+
Returns the CUDA override.
|
|
132
|
+
"""
|
|
133
|
+
override = self._overrides.cuda
|
|
134
|
+
return Override._from_py_override(override) if override else None
|
|
135
|
+
|
|
136
|
+
@cuda.setter
|
|
137
|
+
def cuda(self, override: Override | None) -> None:
|
|
138
|
+
"""
|
|
139
|
+
Sets the CUDA override.
|
|
140
|
+
"""
|
|
141
|
+
self._overrides.cuda = override._override if override else None
|
|
142
|
+
|
|
143
|
+
def __str__(self) -> str:
|
|
144
|
+
"""
|
|
145
|
+
Returns string representation of the VirtualPackageOverrides.
|
|
146
|
+
"""
|
|
147
|
+
return self._overrides.as_str()
|
|
148
|
+
|
|
149
|
+
def __repr__(self) -> str:
|
|
150
|
+
"""
|
|
151
|
+
Returns a representation of the VirtualPackageOverrides.
|
|
152
|
+
"""
|
|
153
|
+
return f"VirtualPackageOverrides({self._overrides.as_str()})"
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class VirtualPackage:
|
|
157
|
+
_virtual_package: PyVirtualPackage
|
|
158
|
+
|
|
159
|
+
@classmethod
|
|
160
|
+
def _from_py_virtual_package(cls, py_virtual_package: PyVirtualPackage) -> VirtualPackage:
|
|
161
|
+
"""Construct Rattler VirtualPackage from FFI PyVirtualPackage object."""
|
|
162
|
+
virtual_package = cls.__new__(cls)
|
|
163
|
+
virtual_package._virtual_package = py_virtual_package
|
|
164
|
+
return virtual_package
|
|
165
|
+
|
|
166
|
+
@staticmethod
|
|
167
|
+
def current() -> List[VirtualPackage]:
|
|
168
|
+
"""
|
|
169
|
+
Returns virtual packages detected for the current system or an error
|
|
170
|
+
if the versions could not be properly detected.
|
|
171
|
+
|
|
172
|
+
.. deprecated:: 0.7.0 Use `detect` instead.
|
|
173
|
+
"""
|
|
174
|
+
warnings.warn("Use `detect` instead")
|
|
175
|
+
return VirtualPackage.detect()
|
|
176
|
+
|
|
177
|
+
@staticmethod
|
|
178
|
+
def detect(overrides: VirtualPackageOverrides = VirtualPackageOverrides()) -> List[VirtualPackage]:
|
|
179
|
+
"""
|
|
180
|
+
Returns virtual packages detected for the current system with the given overrides.
|
|
181
|
+
"""
|
|
182
|
+
return [VirtualPackage._from_py_virtual_package(vp) for vp in PyVirtualPackage.detect(overrides._overrides)]
|
|
183
|
+
|
|
184
|
+
def into_generic(self) -> GenericVirtualPackage:
|
|
185
|
+
"""
|
|
186
|
+
Returns a GenericVirtualPackage from VirtualPackage.
|
|
187
|
+
"""
|
|
188
|
+
# subclass from Generic instead.
|
|
189
|
+
return GenericVirtualPackage._from_py_generic_virtual_package(self._virtual_package.as_generic())
|
|
190
|
+
|
|
191
|
+
def __str__(self) -> str:
|
|
192
|
+
"""
|
|
193
|
+
Returns string representation of the VirtualPackage.
|
|
194
|
+
"""
|
|
195
|
+
return self._virtual_package.as_str()
|
|
196
|
+
|
|
197
|
+
def __repr__(self) -> str:
|
|
198
|
+
"""
|
|
199
|
+
Returns a representation of the VirtualPackage.
|
|
200
|
+
"""
|
|
201
|
+
return f"VirtualPackage({self._virtual_package.as_str()})"
|