diff --git a/app.py b/app.py index 3c12509..523f712 100644 --- a/app.py +++ b/app.py @@ -21,6 +21,7 @@ JOBS_DIR.mkdir(exist_ok=True) # In Docker: /usr/bin/freecadcmd, lokal (mac): via env setzen, wenn du willst FREECAD_TIMEOUT_SEC = int(os.environ.get("FREECAD_TIMEOUT_SEC", "1200")) FREECADCMD = (os.environ.get("FREECADCMD") or "").strip() or "/opt/conda/envs/fc/bin/freecadcmd" +FREECADCMD = "/usr/bin/freecadcmd" ALLOWED_MATERIALS = [ ("stainless", "Edelstahl"), @@ -97,7 +98,8 @@ try: mod_dir = os.path.expanduser("~/.local/share/FreeCAD/Mod") if os.path.isdir(mod_dir) and mod_dir not in sys.path: sys.path.append(mod_dir) - sm_dir = os.path.join(mod_dir, \"SheetMetal\") +# sm_dir = os.path.join(mod_dir, \"SheetMetal\") + sm_dir = os.path.join(mod_dir, \"sheetmetal\") if os.path.isdir(sm_dir) and sm_dir not in sys.path: sys.path.append(sm_dir) @@ -125,13 +127,29 @@ finally: cmd = [FREECADCMD, "run_stepanalyser.py"] env = os.environ.copy() - # In linuxserver containers the writable, persistent home is /config + + # Remove anything that can make embedded Python pick up the venv / wrong stdlib + for k in list(env.keys()): + if k.startswith("PYTHON"): + env.pop(k, None) + + # Also de-venv-ify PATH if you want to be extra safe + # (optional, but helpful if the venv puts shims first) + # env["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + + # Make locale sane (Py_EncodeLocale happens very early) + env.setdefault("LANG", "C.UTF-8") + env.setdefault("LC_ALL", "C.UTF-8") + env.setdefault("LC_CTYPE", "C.UTF-8") + + # Your existing settings env["HOME"] = env.get("HOME") or "/config" - env["HOME"] = "/config" # enforce for consistent expanduser() + Mod discovery - - # Headless Qt hints (works on Debian-based hosts too) env.setdefault("QT_QPA_PLATFORM", "offscreen") - + env["LANG"] = "C" + env["LC_ALL"] = "C" + env["LC_CTYPE"] = "C" + env["PYTHONUTF8"] = "1" + env["PYTHONCOERCECLOCALE"] = "1" timeout = FREECAD_TIMEOUT_SEC log_path = job_dir / "run.log" @@ -143,7 +161,8 @@ finally: log_fp.write("=== STEPANALYSER START ===\n") log_fp.write(f"Command: {cmd}\n") log_fp.flush() - + log_fp.write(f"Sanitized env: PYTHONHOME={env.get('PYTHONHOME')} PYTHONPATH={env.get('PYTHONPATH')}\n") + log_fp.write(f"Locale: LANG={env.get('LANG')} LC_ALL={env.get('LC_ALL')} LC_CTYPE={env.get('LC_CTYPE')}\n") proc = subprocess.Popen( cmd, cwd=str(job_dir),