Portability: Blender/ODA discovery via env > PATH > macOS default

The two hardcoded macOS paths in code become last-resort defaults:
- build_showcase_variants: env BLENDER > shutil.which("blender") > app bundle
- cad_dxf_report: env ODA_CONVERTER > shutil.which("ODAFileConverter") > app
  bundle (env override existed already; PATH lookup is new)
Docs annotate the macOS example paths with the discovery order.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-04 15:05:32 +08:00
parent 23cf3af678
commit b871a2f8bd
4 changed files with 20 additions and 4 deletions

View File

@@ -8,6 +8,8 @@ Blender to produce GLBs. Its manifest is consumed by write_web_showcase.py.
from __future__ import annotations
import argparse
import shutil
import os
import copy
import json
import subprocess
@@ -38,6 +40,13 @@ VARIANTS = [
def default_blender() -> str:
"""Blender executable: env BLENDER > PATH > macOS app-bundle default."""
override = os.environ.get("BLENDER")
if override:
return override
found = shutil.which("blender")
if found:
return found
return "/Applications/Blender.app/Contents/MacOS/Blender"

View File

@@ -86,10 +86,13 @@ def run_dwg2dxf(source: Path, dest: Path) -> dict:
def oda_converter() -> str | None:
"""ODA File Converter path (env ODA_CONVERTER overrides the macOS default)."""
"""ODA File Converter: env ODA_CONVERTER > PATH > macOS app-bundle default."""
override = os.environ.get("ODA_CONVERTER")
if override:
return override if Path(override).exists() else None
found = shutil.which("ODAFileConverter")
if found:
return found
default = Path("/Applications/ODAFileConverter.app/Contents/MacOS/ODAFileConverter")
return str(default) if default.exists() else None