"""Puts the world generator (the `mapgen` package) on sys.path: $WORLDGEN, else a `worldgen` folder next to this one."""
import os
import sys
from pathlib import Path
def find() -> Path:
env = os.environ.get("WORLDGEN")
here = Path(__file__).resolve().parent
for c in ([Path(env)] if env else []) + [here.parent / "worldgen", here / "worldgen"]:
if (c / "mapgen" / "__init__.py").exists():
return c.resolve()
raise SystemExit("worldgen not found: set WORLDGEN=/path/to/worldgen or clone it next to this folder")
GEN = find()
if str(GEN) not in sys.path:
sys.path.insert(0, str(GEN))