@@ -5,13 +5,40 @@ from __future__ import annotations
55import argparse
66import os
77import signal
8+ import shutil
89import subprocess
910import time
1011from pathlib import Path
1112
1213EXAMPLE_DIR = Path (__file__ ).resolve ().parents [1 ]
1314REPO_DIR = EXAMPLE_DIR .parent
14- PYTHON = REPO_DIR / ".venv" / "bin" / "python3.14"
15+
16+
17+ def resolve_python () -> str :
18+ candidates = (
19+ os .environ .get ("REACT_ON_DJANGO_EXAMPLE_PYTHON" ),
20+ str (REPO_DIR / ".venv" / "bin" / "python3.14" ),
21+ str (REPO_DIR / ".venv" / "bin" / "python" ),
22+ "python3" ,
23+ )
24+ for candidate in candidates :
25+ if not candidate :
26+ continue
27+ candidate_path = Path (candidate ).expanduser ()
28+ if candidate_path .is_absolute () or "/" in candidate :
29+ if candidate_path .exists ():
30+ return str (candidate_path )
31+ continue
32+ resolved = shutil .which (candidate )
33+ if resolved :
34+ return resolved
35+ raise SystemExit (
36+ "Could not find a Python interpreter. "
37+ "Set REACT_ON_DJANGO_EXAMPLE_PYTHON or create .venv/bin/python3.14." ,
38+ )
39+
40+
41+ PYTHON = resolve_python ()
1542RENDERER_PASSWORD = "react-on-django-example"
1643
1744
@@ -213,8 +240,6 @@ def process_specs(
213240
214241def run () -> int :
215242 args = parse_args ()
216- if not PYTHON .exists ():
217- raise SystemExit (f"Expected Python at { PYTHON } " )
218243
219244 defaults = {
220245 "dev" : (3000 , 3800 , 3035 ),
0 commit comments