aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/worldgen_path.py
diff options
context:
space:
mode:
authorgodosa <godosa@godosa.eu>2026-10-07 00:14:38 +0200
committergodosa <godosa@godosa.eu>2026-10-07 00:14:38 +0200
commit3443c1c65e9f1753e1e656b35d08416c1fa298f2 (patch)
tree4e43236f460145a4d75d1b4616dcb7aa6ef08f51 /worldgen_path.py
downloadworldmap-viewer-3443c1c65e9f1753e1e656b35d08416c1fa298f2.tar.gz
worldmap-viewer-3443c1c65e9f1753e1e656b35d08416c1fa298f2.zip
worldmap-viewer: initial public history
Diffstat (limited to 'worldgen_path.py')
-rw-r--r--worldgen_path.py18
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))