Skip to content

Commit 07f0b2a

Browse files
committed
move install condition to a constant
1 parent 68490dc commit 07f0b2a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

airbyte_cdk/models/airbyte_protocol_serializers.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
import sys
33
from typing import Any, Dict
44

5-
if sys.platform == 'emscripten':
6-
from serpyco import CustomType, Serializer
7-
else:
8-
from serpyco_rs import CustomType, Serializer
9-
105
from .airbyte_protocol import ( # type: ignore[attr-defined] # all classes are imported to airbyte_protocol via *
116
AirbyteCatalog,
127
AirbyteMessage,
@@ -19,6 +14,14 @@
1914
ConnectorSpecification,
2015
)
2116

17+
USE_RUST_BACKEND = sys.platform != "emscripten"
18+
"""When run in WASM, use the pure Python backend for serpyco."""
19+
20+
if USE_RUST_BACKEND:
21+
from serpyco_rs import CustomType, Serializer
22+
else:
23+
from serpyco import CustomType, Serializer
24+
2225

2326
class AirbyteStateBlobType(CustomType[AirbyteStateBlob, Dict[str, Any]]):
2427
def serialize(self, value: AirbyteStateBlob) -> Dict[str, Any]:

0 commit comments

Comments
 (0)