mirror of
https://github.com/usestrix/strix.git
synced 2026-08-16 17:27:26 +02:00
feat(tui): replace Textual with a Go/Bubble Tea interface (#941)
This commit is contained in:
@@ -39,6 +39,12 @@ if ! command -v uv &> /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v go &> /dev/null; then
|
||||
echo -e "${RED}Error: Go is not installed${NC}"
|
||||
echo "Go 1.24 or newer is required to build the Bubble Tea TUI."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "\n${BLUE}Installing dependencies...${NC}"
|
||||
uv sync --frozen
|
||||
|
||||
@@ -48,6 +54,14 @@ echo -e "${YELLOW}Version:${NC} $VERSION"
|
||||
echo -e "\n${BLUE}Cleaning previous builds...${NC}"
|
||||
rm -rf build/ dist/
|
||||
|
||||
echo -e "\n${BLUE}Building Bubble Tea sidecar...${NC}"
|
||||
TUI_BINARY="build/sidecar/strix-tui"
|
||||
if [ "$OS_NAME" = "windows" ]; then
|
||||
TUI_BINARY="${TUI_BINARY}.exe"
|
||||
fi
|
||||
mkdir -p build/sidecar
|
||||
(cd strix/interface/tui && CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o "../../../$TUI_BINARY" ./cmd/strix-tui)
|
||||
|
||||
echo -e "\n${BLUE}Building binary with PyInstaller...${NC}"
|
||||
uv run pyinstaller strix.spec --noconfirm
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
"""Hatchling build hook that compiles and bundles the Go TUI sidecar."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sysconfig
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
||||
|
||||
|
||||
class CustomBuildHook(BuildHookInterface[Any]):
|
||||
"""Compile the Bubble Tea sidecar and ship it inside the wheel.
|
||||
|
||||
The sidecar is the only interactive interface, so every wheel is a
|
||||
platform wheel and a missing Go toolchain is a build failure.
|
||||
"""
|
||||
|
||||
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
|
||||
# Editable installs run from the checkout, where the TUI is started
|
||||
# with ``go run``; there is nothing to bundle.
|
||||
if version == "editable":
|
||||
return
|
||||
|
||||
root = Path(self.root)
|
||||
executable = "strix-tui.exe" if os.name == "nt" else "strix-tui"
|
||||
output = root / "build" / "sidecar" / executable
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
go = shutil.which("go")
|
||||
if go is None:
|
||||
raise RuntimeError("Go 1.24 or newer is required to build the Bubble Tea TUI")
|
||||
env = os.environ.copy()
|
||||
env["CGO_ENABLED"] = "0"
|
||||
subprocess.run( # noqa: S603 - fixed build command using the resolved Go binary
|
||||
[
|
||||
go,
|
||||
"build",
|
||||
"-trimpath",
|
||||
"-ldflags=-s -w",
|
||||
"-o",
|
||||
str(output),
|
||||
"./cmd/strix-tui",
|
||||
],
|
||||
cwd=root / "strix" / "interface" / "tui",
|
||||
env=env,
|
||||
check=True,
|
||||
)
|
||||
|
||||
build_data["force_include"][str(output)] = f"strix/bin/{executable}"
|
||||
build_data["pure_python"] = False
|
||||
platform_tag = os.environ.get("STRIX_WHEEL_PLATFORM_TAG")
|
||||
if not platform_tag:
|
||||
platform_tag = sysconfig.get_platform().replace("-", "_").replace(".", "_")
|
||||
build_data["tag"] = f"py3-none-{platform_tag}"
|
||||
Reference in New Issue
Block a user