finance-query 3.0.0

A Rust library for querying financial data
Documentation
# Code generated by `cargo soothfast sdk gen`. DO NOT EDIT.
"""Wheel build hook: bundles the server binary and tags the wheel.

``cargo soothfast sdk build`` sets ``SOOTHFAST_SERVER_BIN`` and
``SOOTHFAST_WHEEL_TAG`` once per target, producing one platform wheel per
target. Built without them — an sdist, or a plain ``uv build`` — this does
nothing and the result is a pure-Python wheel with no server in it, which
falls back to finding one on ``PATH``.
"""
from __future__ import annotations

import os

from hatchling.builders.hooks.plugin.interface import BuildHookInterface

#: Where the binary lands inside the wheel. Kept in step with
#: ``_server.bundled_binary``, which looks for it there.
BIN_DIR = "finance_query/bin"


class CustomBuildHook(BuildHookInterface):
    """Force-includes one prebuilt binary and stamps the platform tag."""

    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)}"