Skip to content

Commit d5b5ad8

Browse files
committed
Use available Python for example CI
1 parent c11ca80 commit d5b5ad8

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

example/bin/dev

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,40 @@ from __future__ import annotations
55
import argparse
66
import os
77
import signal
8+
import shutil
89
import subprocess
910
import time
1011
from pathlib import Path
1112

1213
EXAMPLE_DIR = Path(__file__).resolve().parents[1]
1314
REPO_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()
1542
RENDERER_PASSWORD = "react-on-django-example"
1643

1744

@@ -213,8 +240,6 @@ def process_specs(
213240

214241
def 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

Comments
 (0)