Spaces:
Running on Zero
Running on Zero
Buffy commited on
Commit ·
1df1e19
1
Parent(s): accae83
Recreate stale searxng venv when its python predates 3.11
Browse files- searx_runtime.py +7 -1
searx_runtime.py
CHANGED
|
@@ -62,7 +62,13 @@ def _venv_python() -> str | None:
|
|
| 62 |
"""Create the venv and install searxng + deps (idempotent)."""
|
| 63 |
py = os.path.join(VENV_DIR, "bin", "python")
|
| 64 |
if os.path.exists(py):
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
# Prefer the newest interpreter available (SearXNG master needs 3.11+;
|
| 67 |
# the container base image ships 3.10).
|
| 68 |
base = None
|
|
|
|
| 62 |
"""Create the venv and install searxng + deps (idempotent)."""
|
| 63 |
py = os.path.join(VENV_DIR, "bin", "python")
|
| 64 |
if os.path.exists(py):
|
| 65 |
+
# A stale venv from a different interpreter breaks imports; recreate.
|
| 66 |
+
r = subprocess.run([py, "-c", "import tomllib"], capture_output=True)
|
| 67 |
+
if r.returncode != 0:
|
| 68 |
+
_log("stale venv (python<3.11) — recreating")
|
| 69 |
+
shutil.rmtree(VENV_DIR, ignore_errors=True)
|
| 70 |
+
else:
|
| 71 |
+
return py
|
| 72 |
# Prefer the newest interpreter available (SearXNG master needs 3.11+;
|
| 73 |
# the container base image ships 3.10).
|
| 74 |
base = None
|