Merge remote-tracking branch 'refs/remotes/azuze/main'

This commit is contained in:
2026-05-04 09:50:25 +02:00
5 changed files with 118 additions and 0 deletions
+39
View File
@@ -11,7 +11,10 @@ uv install strategy (in order):
"""
from __future__ import annotations
<<<<<<< HEAD
import argparse
=======
>>>>>>> refs/remotes/azuze/main
import io
import json
import os
@@ -207,6 +210,7 @@ def _uv_pip(uv: list[str], args: list[str]) -> None:
subprocess.check_call(cmd)
<<<<<<< HEAD
def detect_and_install(
uv: list[str],
force_backend: str | None = None,
@@ -221,6 +225,14 @@ def detect_and_install(
f"[kawai] Backend: {info.backend}{forced_note} | "
f"{info.vendor} / {info.device_name} / {info.vram_gb:.1f} GB / tier={info.tier}"
)
=======
def detect_and_install(uv: list[str]) -> dict:
sys.path.insert(0, str(ROOT))
from backends import hardware
info = hardware.detect()
print(f"[kawai] Detected: {info.vendor} / {info.device_name} / {info.vram_gb:.1f} GB / tier={info.tier}")
>>>>>>> refs/remotes/azuze/main
_uv_pip(uv, hardware.torch_install_args(info))
_uv_pip(uv, ["-r", str(ROOT / "requirements.txt")])
@@ -231,7 +243,10 @@ def detect_and_install(
"device_name": info.device_name,
"vram_gb": info.vram_gb,
"tier": info.tier,
<<<<<<< HEAD
"forced": bool(force_backend and force_backend != "auto"),
=======
>>>>>>> refs/remotes/azuze/main
}
HARDWARE_CACHE.write_text(json.dumps(payload, indent=2))
MARKER.write_text("ok")
@@ -245,12 +260,17 @@ def already_in_venv() -> bool:
return False
<<<<<<< HEAD
def relaunch_in_venv(forwarded_args: list[str]) -> None:
=======
def relaunch_in_venv() -> None:
>>>>>>> refs/remotes/azuze/main
"""Re-exec the launcher inside the venv. Use subprocess on Windows because
os.execv mangles argv with spaces in paths."""
print("[kawai] Relaunching inside venv...")
py = str(venv_python())
script = str(ROOT / "launcher.py")
<<<<<<< HEAD
argv = [py, script, *forwarded_args]
if os.name == "nt":
result = subprocess.run(argv)
@@ -299,6 +319,20 @@ def main() -> None:
if not MARKER.exists():
uv = _ensure_uv()
detect_and_install(uv, force_backend=forced, force_vendor=args.vendor)
=======
if os.name == "nt":
result = subprocess.run([py, script])
sys.exit(result.returncode)
else:
os.execv(py, [py, script])
def main() -> None:
if already_in_venv():
if not MARKER.exists():
uv = _ensure_uv()
detect_and_install(uv)
>>>>>>> refs/remotes/azuze/main
from app import run
run()
return
@@ -306,8 +340,13 @@ def main() -> None:
uv = _ensure_uv()
_create_venv(uv)
if not MARKER.exists():
<<<<<<< HEAD
detect_and_install(uv, force_backend=forced, force_vendor=args.vendor)
relaunch_in_venv(sys.argv[1:])
=======
detect_and_install(uv)
relaunch_in_venv()
>>>>>>> refs/remotes/azuze/main
if __name__ == "__main__":