Skip to content

Commit c7679d6

Browse files
author
Neo
committed
fix: setup.py Python version check + add missing database.path to config
- setup.py now detects when global Python is too old and automatically restarts under .venv/bin/python3 if available, instead of exiting - Adds database.path to generated config so gateway validation passes - Adds database.path to openmatrix.config.json.example for users who skip the wizard and copy the example directly
1 parent 06f64d6 commit c7679d6

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

openmatrix.config.json.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"workspace": ".",
66
"timezone": "America/Los_Angeles",
77
"max_steps": 10,
8+
"database": {
9+
"path": "data/0pnmatrx.db"
10+
},
811
"model": {
912
"provider": "ollama",
1013
"primary": "llama3.1",

setup.py

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,31 @@ def spinner(text, duration=1.0):
111111
# ─── Setup Steps ─────────────────────────────────────────────────────────────
112112

113113
def check_python():
114-
"""Verify Python version."""
114+
"""Verify Python version.
115+
116+
If the running interpreter is too old but a suitable venv exists in
117+
the project directory, restart under that venv automatically so
118+
users who cloned the repo on a system with an older global Python
119+
aren't blocked.
120+
"""
115121
v = sys.version_info
116-
if v.major < 3 or (v.major == 3 and v.minor < 10):
117-
fail(f"Python 3.10+ required. You have {v.major}.{v.minor}.{v.micro}")
118-
sys.exit(1)
119-
success(f"Python {v.major}.{v.minor}.{v.micro}")
122+
if v.major >= 3 and v.minor >= 10:
123+
success(f"Python {v.major}.{v.minor}.{v.micro}")
124+
return
125+
126+
# The running Python is too old — check for a usable venv before
127+
# giving up.
128+
venv_python = Path(__file__).parent / ".venv" / "bin" / "python3"
129+
if venv_python.exists():
130+
warn(f"System Python is {v.major}.{v.minor}.{v.micro}, but .venv has a newer version.")
131+
info("Restarting setup under .venv/bin/python3 …")
132+
os.execv(str(venv_python), [str(venv_python)] + sys.argv)
133+
# execv replaces the process; this line is never reached.
134+
135+
fail(f"Python 3.10+ required. You have {v.major}.{v.minor}.{v.micro}")
136+
info("Create a venv with a newer Python, or install Python 3.10+:")
137+
info(" python3.12 -m venv .venv && source .venv/bin/activate && python setup.py")
138+
sys.exit(1)
120139

121140

122141
def install_dependencies():
@@ -402,7 +421,10 @@ def main():
402421
print(f" {DIM}You can re-run this anytime to change settings.{RESET}")
403422

404423
total = 8
405-
config = {}
424+
config = {
425+
"platform": "0pnMatrx",
426+
"database": {"path": "data/0pnmatrx.db"},
427+
}
406428

407429
# Step 1: Python check
408430
step(1, total, "Checking environment")

0 commit comments

Comments
 (0)