mirror of
https://github.com/usestrix/strix.git
synced 2026-11-17 09:32:20 +00:00
fix(build): bundle google-auth so Vertex AI works in release binaries
strix.spec excluded google.auth and google.oauth2 from the PyInstaller bundle, and the release build ran a plain `uv sync --frozen`, so google-auth was never installed there either. litellm's vertex_ai Gemini path authenticates through google.auth and google.oauth2 on every call, so every Vertex model failed on the standalone binary with "No module named 'google'" even though `pip install strix-agent[vertex]` worked. Stop excluding those two modules and install the `vertex` extra in the release build. The remaining google.* and grpc excludes stay: litellm only reaches them for legacy PaLM and Model Garden models, which need google-cloud-aiplatform, and none of those packages are in the lockfile. Fixes the Vertex half of #1256. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
84f4108195
commit
8f898e6cea
3 changed files with 58 additions and 5 deletions
2
.github/workflows/build-release.yml
vendored
2
.github/workflows/build-release.yml
vendored
|
|
@ -55,7 +55,7 @@ jobs:
|
|||
env:
|
||||
STRIX_WHEEL_PLATFORM_TAG: ${{ matrix.wheel-platform }}
|
||||
run: |
|
||||
uv sync --frozen
|
||||
uv sync --frozen --extra vertex
|
||||
uv build --wheel
|
||||
uv run python -c 'import glob, os, sys, zipfile; wheels = glob.glob("dist/*.whl"); assert len(wheels) == 1, wheels; archive = zipfile.ZipFile(wheels[0]); tui = "strix/bin/strix-tui.exe" if sys.platform == "win32" else "strix/bin/strix-tui"; assert tui in archive.namelist(); metadata = archive.read(next(name for name in archive.namelist() if name.endswith(".dist-info/WHEEL"))).decode(); assert "Root-Is-Purelib: false" in metadata; assert "Tag: py3-none-" + os.environ["STRIX_WHEEL_PLATFORM_TAG"] in metadata'
|
||||
|
||||
|
|
|
|||
|
|
@ -207,12 +207,14 @@ excludes = [
|
|||
'openhands-aci',
|
||||
'numpydoc',
|
||||
|
||||
# Google Cloud / Vertex AI
|
||||
# Google Cloud SDKs. litellm only reaches these for legacy PaLM and Model
|
||||
# Garden models, which need google-cloud-aiplatform and are not bundled.
|
||||
# google.auth and google.oauth2 are deliberately NOT excluded: every
|
||||
# vertex_ai/gemini-* call authenticates through them, and the `vertex`
|
||||
# extra installs google-auth for exactly that (#1256).
|
||||
'google.cloud',
|
||||
'google.cloud.aiplatform',
|
||||
'google.api_core',
|
||||
'google.auth',
|
||||
'google.oauth2',
|
||||
'google.protobuf',
|
||||
'grpc',
|
||||
'grpcio',
|
||||
|
|
|
|||
|
|
@ -2,11 +2,15 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
PYPROJECT = Path(__file__).resolve().parent.parent / "pyproject.toml"
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
PYPROJECT = REPO_ROOT / "pyproject.toml"
|
||||
PYINSTALLER_SPEC = REPO_ROOT / "strix.spec"
|
||||
BUILD_RELEASE_WORKFLOW = REPO_ROOT / ".github" / "workflows" / "build-release.yml"
|
||||
|
||||
|
||||
def _optional_dependencies() -> dict[str, list[str]]:
|
||||
|
|
@ -25,3 +29,50 @@ def test_bedrock_extra_pins_boto3() -> None:
|
|||
extras = _optional_dependencies()
|
||||
assert "bedrock" in extras
|
||||
assert any(req.startswith("boto3") for req in extras["bedrock"])
|
||||
|
||||
|
||||
def _pyinstaller_excludes() -> list[str]:
|
||||
"""Read the ``excludes`` list from strix.spec without executing it.
|
||||
|
||||
Executing the spec imports PyInstaller, so parse it and take the literal.
|
||||
"""
|
||||
tree = ast.parse(PYINSTALLER_SPEC.read_text(encoding="utf-8"))
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.Assign) and any(
|
||||
isinstance(t, ast.Name) and t.id == "excludes" for t in node.targets
|
||||
):
|
||||
excludes: list[str] = ast.literal_eval(node.value)
|
||||
return excludes
|
||||
raise AssertionError("strix.spec defines no `excludes` list")
|
||||
|
||||
|
||||
def _is_excluded(module: str, excludes: list[str]) -> bool:
|
||||
# PyInstaller drops a module when it or any parent package is excluded.
|
||||
parts = module.split(".")
|
||||
return any(".".join(parts[:i]) in excludes for i in range(1, len(parts) + 1))
|
||||
|
||||
|
||||
def test_binary_keeps_the_google_auth_modules_vertex_needs() -> None:
|
||||
"""The standalone binary must be able to authenticate to Vertex AI.
|
||||
|
||||
litellm's vertex_ai Gemini path imports google.auth and google.oauth2 for
|
||||
every call. Excluding them from the PyInstaller bundle made every Vertex
|
||||
model fail with ``No module named 'google'`` on the binary install.
|
||||
"""
|
||||
excludes = _pyinstaller_excludes()
|
||||
for module in (
|
||||
"google.auth",
|
||||
"google.auth.credentials",
|
||||
"google.auth.transport.requests",
|
||||
"google.oauth2",
|
||||
"google.oauth2.service_account",
|
||||
):
|
||||
assert not _is_excluded(module, excludes), f"{module} is excluded from the binary"
|
||||
|
||||
|
||||
def test_release_build_installs_the_vertex_extra() -> None:
|
||||
"""Keeping google.auth in the bundle only helps if the build installs it."""
|
||||
workflow = BUILD_RELEASE_WORKFLOW.read_text(encoding="utf-8")
|
||||
sync_lines = [line.strip() for line in workflow.splitlines() if "uv sync" in line]
|
||||
assert sync_lines, "the release workflow no longer runs uv sync"
|
||||
assert all("--extra vertex" in line for line in sync_lines), sync_lines
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue