-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrayforce_init_pyodide.py
More file actions
149 lines (138 loc) · 3.15 KB
/
rayforce_init_pyodide.py
File metadata and controls
149 lines (138 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
"""
Python bindings for RayforceDB (Pyodide/WASM version)
"""
import sys
from rayforce.ffi import FFI
FFI.init_runtime()
version = "0.5.4"
# On emscripten (Pyodide), the C extension is already loaded by the Python runtime
# No need to use ctypes.CDLL - the _rayforce_c module is imported directly
if sys.platform != "emscripten":
import ctypes
from pathlib import Path
if sys.platform == "linux":
lib_name = "_rayforce_c.so"
raykx_lib_name = "libraykx.so"
elif sys.platform == "darwin":
lib_name = "_rayforce_c.so"
raykx_lib_name = "libraykx.dylib"
elif sys.platform == "win32":
lib_name = "rayforce.dll"
else:
raise ImportError(f"Platform not supported: {sys.platform}")
lib_path = Path(__file__).resolve().parent / lib_name
raykx_lib_path = Path(__file__).resolve().parent / "plugins" / raykx_lib_name
if lib_path.exists() and raykx_lib_path.exists():
try:
ctypes.CDLL(str(lib_path), mode=ctypes.RTLD_GLOBAL)
ctypes.CDLL(str(raykx_lib_path), mode=ctypes.RTLD_GLOBAL)
except Exception as e:
raise ImportError(f"Error loading CDLL: {e}") from e
from .errors import ( # noqa: E402
RayforceArityError,
RayforceConversionError,
RayforceDomainError,
RayforceError,
RayforceEvaluationError,
RayforceIndexError,
RayforceInitError,
RayforceLengthError,
RayforceNYIError,
RayforceOkError,
RayforceOSError,
RayforceParseError,
RayforcePartedTableError,
RayforceQueryCompilationError,
RayforceTCPError,
RayforceThreadError,
RayforceTypeError,
RayforceTypeRegistryError,
RayforceUserError,
RayforceValueError,
)
from .types import ( # noqa: E402
B8,
C8,
F64,
GUID,
I16,
I32,
I64,
U8,
Column,
Date,
Dict,
Expression,
Fn,
List,
Null,
Operation,
QuotedSymbol,
String,
Symbol,
Table,
TableColumnInterval,
Time,
Timestamp,
Vector,
)
from .utils import ( # noqa: E402
eval_obj,
eval_str,
python_to_ray,
ray_to_python,
)
core_version = String(eval_str("(sysinfo)")["hash"]).to_python()
__all__ = [
"B8",
"C8",
"F64",
"GUID",
"I16",
"I32",
"I64",
"U8",
"Column",
"Date",
"Dict",
"Expression",
"Fn",
"List",
"Null",
"Operation",
"QuotedSymbol",
"RayforceArityError",
"RayforceConversionError",
"RayforceDomainError",
"RayforceError",
"RayforceEvaluationError",
"RayforceIndexError",
"RayforceInitError",
"RayforceInitError",
"RayforceLengthError",
"RayforceNYIError",
"RayforceOSError",
"RayforceOkError",
"RayforceParseError",
"RayforcePartedTableError",
"RayforceQueryCompilationError",
"RayforceTCPError",
"RayforceThreadError",
"RayforceTypeError",
"RayforceTypeRegistryError",
"RayforceUserError",
"RayforceValueError",
"String",
"Symbol",
"Table",
"TableColumnInterval",
"Time",
"Timestamp",
"Vector",
"core_version",
"eval_obj",
"eval_str",
"python_to_ray",
"ray_to_python",
"version",
]