This commit is contained in:
Devraj Pal 2026-09-24 12:36:15 -04:00 • committed by GitHub
commit 4269b9c11f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 82 additions and 5 deletions

View file

@ -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'

View file

@ -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',

View file

@ -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,74 @@ 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")
# A commented-out command must not satisfy the check: a build that stopped
# installing the extra would otherwise still pass on the comment's text.
sync_lines = [
line.strip()
for line in workflow.splitlines()
if "uv sync" in line and not line.lstrip().startswith("#")
]
assert sync_lines, "the release workflow no longer runs uv sync"
assert all("--extra vertex" in line for line in sync_lines), sync_lines
def test_workflow_check_ignores_commented_out_sync_commands(tmp_path: Path) -> None:
"""The workflow check must read commands, not comments that mention them."""
workflow = tmp_path / "build-release.yml"
workflow.write_text(
" run: |\n # uv sync --frozen --extra vertex\n uv sync --frozen\n",
encoding="utf-8",
)
sync_lines = [
line.strip()
for line in workflow.read_text(encoding="utf-8").splitlines()
if "uv sync" in line and not line.lstrip().startswith("#")
]
assert sync_lines == ["uv sync --frozen"]
assert not all("--extra vertex" in line for line in sync_lines)