The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(install): reuse an installed supported Python instead of downloading 3.11
teknium15bdb4742b016
diff --git a/scripts/install.sh b/scripts/install.shindex 0b189f7fa2f..be4f977e336 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -57,6 +57,7 @@ elseINSTALL_DIR_EXPLICIT=falsefiPYTHON_VERSION="3.11"+PYTHON_SUPPORTED_RANGE=">=3.11,<3.14" # pyproject requires-python; keep in syncNODE_VERSION="26"# FHS-style root install layout (set by resolve_install_layout when applicable):@@ -688,6 +689,16 @@ check_python() {return 0fi+ # No 3.11, but any interpreter inside requires-python (>=3.11,<3.14) works: reuse it rather+ # than downloading 3.11 — the download is a hard failure on hosts that cannot reach GitHub+ # releases, and the user already has a supported Python (#10778).+ if PYTHON_PATH="$("$UV_CMD" python find "$PYTHON_SUPPORTED_RANGE" 2>/dev/null)"; then+ PYTHON_FOUND_VERSION="$("$PYTHON_PATH" --version 2>/dev/null)"+ PYTHON_VERSION="$PYTHON_PATH" # uv venv --python / UV_PYTHON pin onto this interpreter+ log_success "Python found: $PYTHON_FOUND_VERSION (supported; reusing instead of downloading 3.11)"+ return 0+ fi+# Python not found — use uv to install it (no sudo needed!)log_info "Python $PYTHON_VERSION not found, installing via uv..."if "$UV_CMD" python install "$PYTHON_VERSION"; then@@ -1755,7 +1766,7 @@ setup_venv() {export UV_PYTHON="$INSTALL_DIR/venv/bin/python"fi- log_success "Virtual environment ready (Python $PYTHON_VERSION)"+ log_success "Virtual environment ready ($(./venv/bin/python --version 2>/dev/null || echo "Python $PYTHON_VERSION"))"}run_locked_uv_sync() {diff --git a/tests/test_install_sh_reuse_supported_python.py b/tests/test_install_sh_reuse_supported_python.pynew file mode 100644index 00000000000..269fb0bf802--- /dev/null+++ b/tests/test_install_sh_reuse_supported_python.py@@ -0,0 +1,50 @@+"""install.sh reuses an already-installed supported Python instead of downloading 3.11 (#10778)."""++from __future__ import annotations++import os+import shutil+import stat+import subprocess+from pathlib import Path++import pytest++REPO_ROOT = Path(__file__).resolve().parent.parent+INSTALL_SH = REPO_ROOT / "scripts" / "install.sh"+++def _exe(path: Path, content: str) -> Path:+ path.write_text(content, encoding="utf-8")+ path.chmod(path.stat().st_mode | stat.S_IXUSR)+ return path+++def _run_prerequisites(tmp_path: Path, *, uv_find_script: str) -> subprocess.CompletedProcess[str]:+ """Run the real ``--stage prerequisites`` with a stub managed uv whose ``python find`` we script."""+ home = tmp_path / "home"+ hermes_home = home / ".hermes"+ (hermes_home / "bin").mkdir(parents=True)+ bin_dir = tmp_path / "bin"+ bin_dir.mkdir()+ _exe(bin_dir / "python3.13", "#!/bin/sh\n[ \"$1\" = --version ] && echo 'Python 3.13.12'\nexit 0\n")+ _exe(hermes_home / "bin" / "uv", "#!/bin/sh\n[ \"$1\" = --version ] && { echo 'uv 0.9.0'; exit 0; }\n"+ "if [ \"$1\" = python ] && [ \"$2\" = find ]; then\n" + uv_find_script + "fi\n"+ "if [ \"$1\" = python ] && [ \"$2\" = install ]; then echo 'DOWNLOAD ATTEMPTED' >&2; exit 1; fi\nexit 0\n")+ for tool in ("git", "node", "npm", "curl", "rg", "g++", "c++"):+ _exe(bin_dir / tool, "#!/bin/sh\ncase \"$1\" in --version|-v) echo 'v22.12.0 2.50.0';; esac\nexit 0\n")+ env = os.environ.copy()+ env.update({"HOME": str(home), "HERMES_HOME": str(hermes_home),+ "PATH": f"{bin_dir}{os.pathsep}{env.get('PATH', os.defpath)}"})+ bash = shutil.which("bash") or "/bin/bash"+ return subprocess.run([bash, str(INSTALL_SH), "--stage", "prerequisites", "--non-interactive"],+ env=env, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)++[email protected]_only+def test_supported_newer_python_is_reused_instead_of_downloading_311(tmp_path: Path) -> None:+ """3.11 absent, 3.13 present: the installer must take 3.13 and never call ``uv python install``."""+ result = _run_prerequisites(tmp_path, uv_find_script=(+ f" [ \"$3\" = 3.11 ] && exit 2\n [ \"$3\" = '>=3.11,<3.14' ] && {{ echo {tmp_path}/bin/python3.13; exit 0; }}\n exit 2\n"))+ assert "DOWNLOAD ATTEMPTED" not in result.stdout, result.stdout+ assert "Python found: Python 3.13.12" in result.stdout, result.stdout