fall back on stock json if orjson unavailable
This commit is contained in:
parent
cc44523449
commit
9dda5cf6ca
@ -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
|
||||
|
@ -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"',
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user