-
Notifications
You must be signed in to change notification settings - Fork 4
/
jsonpath_build.py
60 lines (45 loc) · 1.51 KB
/
jsonpath_build.py
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
# Standard Library
from typing import Any, Mapping, Optional
def build_lark_parser(pybin_path=None) -> None:
# Standard Library
import subprocess
import sys
output = subprocess.check_output(
args=[
pybin_path or sys.executable,
"-m",
"lark.tools.standalone",
"--maybe_placeholders",
"jsonpath/grammar.lark",
]
)
with open("jsonpath/lark_parser.py", "wb") as f:
f.write(output)
def __getattr__(name: str) -> Any:
if name == "build_lark_parser":
return build_lark_parser
try:
# Third Party Library
import pdm.pep517.api
func = getattr(pdm.pep517.api, name)
if name == "build_wheel":
def build_wheel(
wheel_directory: str,
config_settings: Optional[Mapping[str, Any]] = None,
metadata_directory: Optional[str] = None,
) -> str:
build_lark_parser()
return func(wheel_directory, config_settings, metadata_directory)
return build_wheel
elif name == "build_sdist":
def build_sdist(
sdist_directory: str,
config_settings: Optional[Mapping[str, Any]] = None,
) -> str:
build_lark_parser()
return func(sdist_directory, config_settings)
return build_sdist
else:
return func
except ImportError:
return getattr(globals(), name)