diff --git a/.secrets.baseline b/.secrets.baseline index 1d7b10a..ad923c2 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -137,7 +137,7 @@ "filename": "src/starbridge/hello/service.py", "hashed_secret": "b96ff7d04dbdf5211aa6bf8ac3a557f30dc7469b", "is_verified": false, - "line_number": 119, + "line_number": 113, "is_secret": false } ], @@ -152,5 +152,5 @@ } ] }, - "generated_at": "2024-12-28T14:44:42Z" + "generated_at": "2024-12-29T18:21:09Z" } diff --git a/src/starbridge/__init__.py b/src/starbridge/__init__.py index 46f08c0..f9ec62c 100644 --- a/src/starbridge/__init__.py +++ b/src/starbridge/__init__.py @@ -31,6 +31,7 @@ def _parse_env_args(): def _amend_library_path(): """Patch environment variables before any other imports""" + if "DYLD_FALLBACK_LIBRARY_PATH" not in os.environ: os.environ["DYLD_FALLBACK_LIBRARY_PATH"] = ( f"{os.getenv('HOMEBREW_PREFIX', '/opt/homebrew')}/lib/" diff --git a/src/starbridge/hello/service.py b/src/starbridge/hello/service.py index b4cae0e..96d78fa 100644 --- a/src/starbridge/hello/service.py +++ b/src/starbridge/hello/service.py @@ -1,18 +1,11 @@ """Handles Hello operations.""" import base64 +import imp import io import os from mcp.types import BlobResourceContents, EmbeddedResource - -try: - from PIL import Image - - _has_imaging = True -except ImportError: - _has_imaging = False - from pydantic import AnyUrl from starbridge.mcp import MCPBaseService, MCPContext, mcp_tool @@ -44,12 +37,13 @@ def hello(self, locale: str = "en_US", context: MCPContext | None = None): return "Hallo Welt!" return "Hello World!" - if _has_imaging: + if imp.find_module("cairosvg"): @mcp_tool() def bridge(self, context: MCPContext | None = None): """Show image of starbridge""" import cairosvg + from PIL import Image return Image.open( io.BytesIO(