diff --git a/src/lib/python/pyodide.ts b/src/lib/python/pyodide.ts index 76a9a9e..afd10ae 100644 --- a/src/lib/python/pyodide.ts +++ b/src/lib/python/pyodide.ts @@ -44,13 +44,17 @@ export async function asyncRunScenario( export async function runScenario(scenario: string) { const pythonProgram = ` import pyodide_http + import pyodide_js + import os pyodide_http.patch_all() print(globals()) from js import scenario_json - import demoland_engine import json import time + os.environ["DEMOLAND"] = pyodide_js.globals.get("DEMOLAND") + import demoland_engine + start = time.time() scenario = json.loads(scenario_json) diff --git a/src/lib/python/pyodide_worker.ts b/src/lib/python/pyodide_worker.ts index bae328f..c364960 100644 --- a/src/lib/python/pyodide_worker.ts +++ b/src/lib/python/pyodide_worker.ts @@ -42,7 +42,8 @@ self.onmessage = async (event) => { // package itself. We need to set this as a global variable here, which lets // us do `import pyodide_js; pyodide_js.globals.get("BASE_URL")` (in the // `cache.py` file). - // self.pyodide.globals.set("BASE_URL", BASE_URL); + let secondLastPart = window.location.pathname.split("/").slice(-2, -1)[0]; + self.pyodide.globals.set("DEMOLAND", secondLastPart); try { await self.pyodide.loadPackagesFromImports(python);