from __future__ import annotations
import os
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
BIN_DIR = "finance_query/bin"
class CustomBuildHook(BuildHookInterface):
def initialize(self, version: str, build_data: dict) -> None:
binary = os.environ.get("SOOTHFAST_SERVER_BIN")
tag = os.environ.get("SOOTHFAST_WHEEL_TAG")
if not binary or not tag:
return
if not os.path.isfile(binary):
raise RuntimeError(f"SOOTHFAST_SERVER_BIN does not exist: {binary}")
build_data["pure_python"] = False
build_data["infer_tag"] = False
build_data["tag"] = tag
build_data["force_include"][binary] = f"{BIN_DIR}/{os.path.basename(binary)}"