Auto merge dev → main (#1225)
* fix BOT.data_parser import in render_recap.py render_recap.py runs as a subprocess (Path(__file__).parent.parent on sys.path) and used `from BOT.data_parser import ...`. After the SHARED move, data_parser is no longer in the BOT package. Add BOTS/SHARED to sys.path and switch to the absolute `from data_parser import ...`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * centralize SHARED sys.path bootstrap in BOT/__init__.py Drop per-file `sys.path.insert(SHARED)` bandaids from BOT/scoreboard.py, gob.py, utils.py, and game_api.py. The bootstrap now happens exactly once when the BOT package is imported (via BOT/__init__.py), which is implicit for any `from BOT.X import …` / `import BOT.X` and any `python -m BOT.x` invocation. `SHARED_DIR` is exposed as a public name on the BOT package; siblings import it via `from . import SHARED_DIR` for building asset paths (MAPS, ICONS, FONTS, vromfs) instead of recomputing the location. render_recap.py is the one subprocess entry point that runs as __main__, so it keeps a minimal bootstrap: add SREBOT to sys.path then `import BOT` to fire the package init once. Also move pyrightconfig.json to the BOTS monorepo root so pyright resolves data_parser and third-party imports regardless of which subproject the editor opens from. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+5
-9
@@ -14,7 +14,6 @@ import logging
|
||||
import os
|
||||
import pstats
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime, timezone
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
@@ -24,12 +23,9 @@ import numpy as np
|
||||
from PIL import Image, ImageDraw, ImageFilter, ImageFont
|
||||
from PIL.Image import Resampling
|
||||
|
||||
# Make SHARED (sibling of SREBOT under BOTS/) importable
|
||||
_SHARED_DIR = Path(__file__).resolve().parents[2] / "SHARED"
|
||||
if str(_SHARED_DIR) not in sys.path:
|
||||
sys.path.insert(0, str(_SHARED_DIR))
|
||||
|
||||
# Local Module Imports
|
||||
from . import SHARED_DIR
|
||||
|
||||
# Toggle for data_parser dependency
|
||||
# Set to False to avoid importing data_parser and show all vehicles as "?" in team composition
|
||||
USE_DATA_PARSER = True
|
||||
@@ -45,9 +41,9 @@ else:
|
||||
return name
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
MAPS_DIR = _SHARED_DIR / "MAPS"
|
||||
ICON_BASE_DIR = _SHARED_DIR / "ICONS"
|
||||
TEXT_FONT_PATH = _SHARED_DIR / "FONTS" / "arial_unicode_ms.otf"
|
||||
MAPS_DIR = SHARED_DIR / "MAPS"
|
||||
ICON_BASE_DIR = SHARED_DIR / "ICONS"
|
||||
TEXT_FONT_PATH = SHARED_DIR / "FONTS" / "arial_unicode_ms.otf"
|
||||
|
||||
|
||||
def _normalize_squad_key(value: str | None) -> str:
|
||||
|
||||
Reference in New Issue
Block a user