fall back on stock json if orjson unavailable

This commit is contained in:
Damien Elmes 2020-03-21 21:24:21 +10:00
parent cc44523449
commit 9dda5cf6ca
2 changed files with 14 additions and 2 deletions

View File

@ -20,7 +20,6 @@ from typing import (
)
import ankirspy # pytype: disable=import-error
import orjson
import anki.backend_pb2 as pb
import anki.buildinfo
@ -36,6 +35,19 @@ assert ankirspy.buildhash() == anki.buildinfo.buildhash
SchedTimingToday = pb.SchedTimingTodayOut
try:
import orjson
except:
# add compat layer for 32 bit builds that can't use orjson
print("reverting to stock json")
import json
class orjson: # type: ignore
def dumps(obj: Any) -> bytes:
return json.dumps(obj).encode("utf8")
loads = json.loads
class Interrupted(Exception):
pass

View File

@ -21,7 +21,7 @@ setuptools.setup(
"requests",
"decorator",
"protobuf",
"orjson",
'orjson; platform_machine == "x86_64"',
'psutil; sys_platform == "win32"',
'distro; sys_platform != "darwin" and sys_platform != "win32"',
],