-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathhatch_build.py
More file actions
27 lines (19 loc) · 1003 Bytes
/
hatch_build.py
File metadata and controls
27 lines (19 loc) · 1003 Bytes
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
"""Build ONNX preprocessors."""
import sys
from pathlib import Path
from typing import Any
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
class _BuildPreprocessorsHook(BuildHookInterface): # type: ignore[type-arg]
artifacts_path = Path("src/onnx_asr/preprocessors/data")
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
self.app.display_info(f"Build ONNX and NumPy preprocessors ({self.artifacts_path})")
sys.path.append(self.root)
from preprocessors.build import build # noqa: PLC0415
self.artifacts_path.mkdir(exist_ok=True)
build(self.artifacts_path, self.metadata.version)
build_data["artifacts"] = [
str(self.artifacts_path.joinpath("*.onnx").as_posix()),
str(self.artifacts_path.joinpath("*.npz").as_posix()),
]
def dependencies(self) -> list[str]:
return self.metadata.config["dependency-groups"]["build"] # type: ignore[no-any-return]