mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
fall back on stock json if orjson unavailable
This commit is contained in:
parent
cc44523449
commit
9dda5cf6ca
2 changed files with 14 additions and 2 deletions
|
@ -20,7 +20,6 @@ from typing import (
|
||||||
)
|
)
|
||||||
|
|
||||||
import ankirspy # pytype: disable=import-error
|
import ankirspy # pytype: disable=import-error
|
||||||
import orjson
|
|
||||||
|
|
||||||
import anki.backend_pb2 as pb
|
import anki.backend_pb2 as pb
|
||||||
import anki.buildinfo
|
import anki.buildinfo
|
||||||
|
@ -36,6 +35,19 @@ assert ankirspy.buildhash() == anki.buildinfo.buildhash
|
||||||
|
|
||||||
SchedTimingToday = pb.SchedTimingTodayOut
|
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):
|
class Interrupted(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -21,7 +21,7 @@ setuptools.setup(
|
||||||
"requests",
|
"requests",
|
||||||
"decorator",
|
"decorator",
|
||||||
"protobuf",
|
"protobuf",
|
||||||
"orjson",
|
'orjson; platform_machine == "x86_64"',
|
||||||
'psutil; sys_platform == "win32"',
|
'psutil; sys_platform == "win32"',
|
||||||
'distro; sys_platform != "darwin" and sys_platform != "win32"',
|
'distro; sys_platform != "darwin" and sys_platform != "win32"',
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue