diff options
Diffstat (limited to 'worldgen_path.py')
| -rw-r--r-- | worldgen_path.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/worldgen_path.py b/worldgen_path.py new file mode 100644 index 0000000..e061ea2 --- /dev/null +++ b/worldgen_path.py @@ -0,0 +1,18 @@ +"""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)) |
