"""Runtime hook: add bundled pip packages to sys.path in frozen mode."""
import sys
from pathlib import Path

if getattr(sys, "frozen", False):
    _meipass = Path(sys._MEIPASS)
    _bundled = _meipass / "bundled_packages"
    if _bundled.is_dir():
        bundled_path = str(_bundled)
        if bundled_path not in sys.path:
            sys.path.insert(1, bundled_path)
        print(f"[rthook] Added bundled packages root {_bundled}")
