The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(install): provision supported Python from TUR on Termux and update docs
Teknium95d42656021a
diff --git a/contributors/emails/[email protected] b/contributors/emails/[email protected]new file mode 100644index 00000000000..50d9be338ce--- /dev/null+++ b/contributors/emails/[email protected]@@ -0,0 +1 @@+gustbrdiff --git a/scripts/install.sh b/scripts/install.shindex 3d5a7d71fd0..eec308a5de7 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -639,15 +639,43 @@ check_python() {log_info "Installing Python via pkg..."pkg install -y python >/dev/nullPYTHON_PATH="$(command -v python)"- if ! "$PYTHON_PATH" -c 'import sys; raise SystemExit(0 if (3, 11) <= sys.version_info[:2] < (3, 14) else 1)' 2>/dev/null; then- PYTHON_FOUND_VERSION="$("$PYTHON_PATH" --version 2>/dev/null || true)"- log_error "Termux Python $PYTHON_FOUND_VERSION is not supported; Hermes requires Python >=3.11,<3.14"- log_info "Install a compatible Termux Python (for example python3.11) and re-run this script"- exit 1+ if "$PYTHON_PATH" -c 'import sys; raise SystemExit(0 if (3, 11) <= sys.version_info[:2] < (3, 14) else 1)' 2>/dev/null; then+ PYTHON_FOUND_VERSION="$("$PYTHON_PATH" --version 2>/dev/null)"+ log_success "Python installed: $PYTHON_FOUND_VERSION"+ return 0fi- PYTHON_FOUND_VERSION="$("$PYTHON_PATH" --version 2>/dev/null)"- log_success "Python installed: $PYTHON_FOUND_VERSION"- return 0++ # Termux's default `python` package is outside the supported range+ # (e.g. 3.14.x before Rust transitives ship cp314 wheels). The Termux+ # User Repository (TUR) publishes versioned CPython packages+ # (python3.13, python3.11), so try to provision a supported+ # interpreter from there before giving up.+ PYTHON_FOUND_VERSION="$("$PYTHON_PATH" --version 2>/dev/null || true)"+ log_warn "Termux Python $PYTHON_FOUND_VERSION is outside the supported range (>=3.11,<3.14)"+ log_info "Trying the Termux User Repository (TUR) for a supported Python..."+ pkg install -y tur-repo >/dev/null 2>&1 || true+ local tur_pkg+ for tur_pkg in python3.13 python3.12 python3.11; do+ if ! pkg install -y "$tur_pkg" >/dev/null 2>&1; then+ continue+ fi+ if ! command -v "$tur_pkg" >/dev/null 2>&1; then+ continue+ fi+ local tur_path+ tur_path="$(command -v "$tur_pkg")"+ if "$tur_path" -c 'import sys; raise SystemExit(0 if (3, 11) <= sys.version_info[:2] < (3, 14) else 1)' 2>/dev/null; then+ PYTHON_PATH="$tur_path"+ PYTHON_FOUND_VERSION="$("$PYTHON_PATH" --version 2>/dev/null)"+ log_success "Python installed from TUR: $PYTHON_FOUND_VERSION"+ return 0+ fi+ done++ log_error "Termux Python $PYTHON_FOUND_VERSION is not supported; Hermes requires Python >=3.11,<3.14"+ log_info "Install a supported interpreter and re-run this script:"+ log_info " pkg install tur-repo && pkg install python3.13"+ exit 1filog_info "Checking Python $PYTHON_VERSION..."diff --git a/setup-hermes.sh b/setup-hermes.shindex 6ce7cc430bb..4f71fade62e 100755--- a/setup-hermes.sh+++ b/setup-hermes.sh@@ -153,7 +153,8 @@ if is_termux; thenif command -v python >/dev/null 2>&1; thenPYTHON_FOUND_VERSION="$(python --version 2>/dev/null || true)"echo -e "${RED}✗${NC} Termux Python $PYTHON_FOUND_VERSION is not supported; Hermes requires Python >=3.11,<3.14"- echo " Install a compatible Termux Python (for example python3.11) and re-run this script"+ echo " Install a supported interpreter and re-run this script:"+ echo " pkg install tur-repo && pkg install python3.13"elseecho -e "${RED}✗${NC} Python not found in Termux"echo " Run: pkg install python"diff --git a/tests/test_install_sh_termux_python_bounds.py b/tests/test_install_sh_termux_python_bounds.pyindex 745a6a302d6..443873bf641 100644--- a/tests/test_install_sh_termux_python_bounds.py+++ b/tests/test_install_sh_termux_python_bounds.py@@ -67,7 +67,8 @@ def _write_termux_command_stubs(bin_dir: Path) -> None:bin_dir / "uname","#!/bin/sh\n[ \"${1:-}\" = '-s' ] && echo Linux || echo Linux\n",)- _write_executable(bin_dir / "pkg", "#!/bin/sh\nexit 0\n")+ if not (bin_dir / "pkg").exists():+ _write_executable(bin_dir / "pkg", "#!/bin/sh\nexit 0\n")_write_executable(bin_dir / "git", "#!/bin/sh\necho 'git version 2.50.0'\n")_write_executable(bin_dir / "node", "#!/bin/sh\necho 'v22.12.0'\n")_write_executable(bin_dir / "npm", "#!/bin/sh\nexit 0\n")@@ -156,10 +157,39 @@ def test_install_stage_rejects_post_install_unsupported_default(tmp_path: Path)assert result.returncode == 1assert "Termux Python Python 3.14.6 is not supported" in result.stdoutassert "Hermes requires Python >=3.11,<3.14" in result.stdout- assert (- "Install a compatible Termux Python (for example python3.11)" in result.stdout+ assert "pkg install tur-repo && pkg install python3.13" in result.stdout+++def test_install_stage_provisions_supported_python_from_tur(tmp_path: Path) -> None:+ """When the default Termux python is too new, the installer falls back to+ the Termux User Repository (TUR) and picks up a supported interpreter that+ `pkg install python3.13` provides."""+ bin_dir = tmp_path / "bin"+ bin_dir.mkdir()+ _write_fake_python(bin_dir, "python", "3.14.6")+ # Shadow any host python3.11/3.12/3.13 so the candidate scan can't find a+ # supported interpreter before the TUR fallback runs.+ _write_unsupported_explicit_pythons(bin_dir)++ # Stateful pkg stub: `pkg install -y python3.13` drops a supported fake+ # interpreter into PATH, mimicking a successful TUR package install.+ staged = tmp_path / "staged"+ staged.mkdir()+ _write_fake_python(staged, "python3.13", "3.13.7")+ _write_executable(+ bin_dir / "pkg",+ "#!/bin/sh\n"+ "for arg in \"$@\"; do\n"+ f" if [ \"$arg\" = 'python3.13' ]; then cp {staged}/python3.13 {bin_dir}/python3.13; fi\n"+ "done\n"+ "exit 0\n",)+ result = _run_install_prerequisites(tmp_path)++ assert result.returncode == 0, result.stdout+ assert "Python installed from TUR: Python 3.13.7" in result.stdout+def test_setup_script_prefers_compatible_minor_over_unsupported_default(tmp_path: Path,diff --git a/website/docs/getting-started/termux.md b/website/docs/getting-started/termux.mdindex 6b31efb30c4..df94ba95708 100644--- a/website/docs/getting-started/termux.md+++ b/website/docs/getting-started/termux.md@@ -110,6 +110,22 @@ pkg install -y git python clang rust make pkg-config libffi openssl nodejs ripgrWhy these packages?- `python` — runtime + venv support++:::warning Supported Python range+Hermes requires **Python >=3.11,<3.14**. Current Termux ships `python`+3.14.x, which is outside that range — the installer detects this, and will+automatically try the [Termux User Repository (TUR)](https://github.com/termux-user-repository/tur)+for a supported interpreter. For a manual install, get one yourself:++```bash+pkg install tur-repo+pkg install python3.13+```++Then use `python3.13` in place of `python` in the commands below+(e.g. `python3.13 -m venv venv`).+:::+- `git` — clone/update the repo- `clang`, `rust`, `make`, `pkg-config`, `libffi`, `openssl` — needed to build a few Python dependencies on Android- `nodejs` — optional Node runtime for experiments beyond the tested core path