Fix web GUI by setting PYTHONPATH in spawned command
textual-serve spawns the app as a subprocess which doesn't inherit PYTHONPATH. Bake the project root into the command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from tui.app import GnizaApp
|
from tui.app import GnizaApp
|
||||||
|
|
||||||
|
# Resolve project root (parent of tui/)
|
||||||
|
_PROJECT_ROOT = str(Path(__file__).resolve().parent.parent)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if "--web" in sys.argv:
|
if "--web" in sys.argv:
|
||||||
@@ -10,7 +15,9 @@ def main():
|
|||||||
for i, arg in enumerate(sys.argv):
|
for i, arg in enumerate(sys.argv):
|
||||||
if arg == "--port" and i + 1 < len(sys.argv):
|
if arg == "--port" and i + 1 < len(sys.argv):
|
||||||
port = int(sys.argv[i + 1])
|
port = int(sys.argv[i + 1])
|
||||||
server = Server("python3 -m tui", host="0.0.0.0", port=port)
|
env_path = f"{_PROJECT_ROOT}:{os.environ.get('PYTHONPATH', '')}"
|
||||||
|
cmd = f"PYTHONPATH={env_path} GNIZA_DIR={_PROJECT_ROOT} python3 -m tui"
|
||||||
|
server = Server(cmd, host="0.0.0.0", port=port)
|
||||||
server.serve()
|
server.serve()
|
||||||
else:
|
else:
|
||||||
app = GnizaApp()
|
app = GnizaApp()
|
||||||
|
|||||||
Reference in New Issue
Block a user