-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwasm_init.py
More file actions
149 lines (136 loc) · 3 KB
/
wasm_init.py
File metadata and controls
149 lines (136 loc) · 3 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 (WASM/Pyodide build)
"""
import sys
from rayforce.ffi import FFI
FFI.init_runtime()
version = "0.5.4"
# WASM/Pyodide: The shared library is loaded automatically by Pyodide
# when the wheel is installed, so we don't need ctypes.CDLL here
if sys.platform != "emscripten":
# For non-WASM platforms, use the standard loading mechanism
import ctypes
from pathlib import Path
if sys.platform == "linux":
lib_name = "_rayforce_c.so"
elif sys.platform == "darwin":
lib_name = "_rayforce_c.so"
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
if lib_path.exists():
try:
ctypes.CDLL(str(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,
)
# Network modules not available in WASM (no sockets)
# from .network import TCPClient, TCPServer
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",
"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",
]