mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-23 05:31:23 +00:00
fix(update): use termux-all uv fallback path on Termux
This commit is contained in:
parent
3863d6d344
commit
6d5d467d39
3 changed files with 86 additions and 32 deletions
|
|
@ -6445,13 +6445,11 @@ def _invalidate_update_cache():
|
|||
pass
|
||||
|
||||
|
||||
def _load_installable_optional_extras() -> list[str]:
|
||||
"""Return the optional extras referenced by the ``all`` group.
|
||||
def _load_installable_optional_extras(group: str = "all") -> list[str]:
|
||||
"""Return optional extras referenced by a dependency group.
|
||||
|
||||
Only extras that ``[all]`` actually pulls in are retried individually.
|
||||
Extras outside ``[all]`` (e.g. ``rl``, ``yc-bench``) are intentionally
|
||||
excluded — they have heavy or platform-specific deps that most users
|
||||
never installed.
|
||||
``group`` is usually ``all`` (desktop/server broad install) or
|
||||
``termux-all`` (Termux-compatible broad install).
|
||||
"""
|
||||
try:
|
||||
import tomllib
|
||||
|
|
@ -6465,11 +6463,9 @@ def _load_installable_optional_extras() -> list[str]:
|
|||
if not isinstance(optional_deps, dict):
|
||||
return []
|
||||
|
||||
# Parse the [all] group to find which extras it references.
|
||||
# Entries look like "hermes-agent[matrix]" or "package-name[extra]".
|
||||
all_refs = optional_deps.get("all", [])
|
||||
refs = optional_deps.get(group, [])
|
||||
referenced: list[str] = []
|
||||
for ref in all_refs:
|
||||
for ref in refs:
|
||||
if "[" in ref and "]" in ref:
|
||||
name = ref.split("[", 1)[1].split("]", 1)[0]
|
||||
if name in optional_deps:
|
||||
|
|
@ -6521,25 +6517,16 @@ def _install_python_dependencies_with_optional_fallback(
|
|||
install_cmd_prefix: list[str],
|
||||
*,
|
||||
env: dict[str, str] | None = None,
|
||||
group: str = "all",
|
||||
) -> None:
|
||||
"""Install base deps plus as many optional extras as the environment supports.
|
||||
|
||||
We intentionally do NOT pass ``--quiet`` to pip. On platforms without
|
||||
prebuilt wheels for some extras (Termux/Android aarch64, older musl
|
||||
distros, fresh Raspberry Pi) pip has to compile C/Rust extensions from
|
||||
source, which can take several minutes with zero network activity.
|
||||
Without progress output the call looks like a hang and users Ctrl+C it.
|
||||
Pip's default output is proportional to actual work (one line per
|
||||
Collecting/Building/Installing step), so keeping it visible costs
|
||||
nothing on fast hardware and prevents the "hermes update hangs" reports
|
||||
on slow hardware.
|
||||
|
||||
We also add periodic heartbeat lines in case the resolver/build backend is
|
||||
itself silent for long stretches.
|
||||
By default this targets ``.[all]``; Termux callers can pass
|
||||
``group='termux-all'`` to use the curated Android-compatible profile.
|
||||
"""
|
||||
try:
|
||||
_run_install_with_heartbeat(
|
||||
install_cmd_prefix + ["install", "-e", ".[all]"],
|
||||
install_cmd_prefix + ["install", "-e", f".[{group}]"],
|
||||
env=env,
|
||||
)
|
||||
return
|
||||
|
|
@ -6555,7 +6542,7 @@ def _install_python_dependencies_with_optional_fallback(
|
|||
|
||||
failed_extras: list[str] = []
|
||||
installed_extras: list[str] = []
|
||||
for extra in _load_installable_optional_extras():
|
||||
for extra in _load_installable_optional_extras(group=group):
|
||||
try:
|
||||
_run_install_with_heartbeat(
|
||||
install_cmd_prefix + ["install", "-e", f".[{extra}]"],
|
||||
|
|
@ -7390,16 +7377,20 @@ def _cmd_update_impl(args, gateway_mode: bool):
|
|||
print("→ Updating Python dependencies...")
|
||||
pip_cmd = [sys.executable, "-m", "pip"]
|
||||
uv_bin = shutil.which("uv") or _ensure_uv_for_termux(pip_cmd)
|
||||
install_group = "all"
|
||||
|
||||
if uv_bin:
|
||||
uv_env = {**os.environ, "VIRTUAL_ENV": str(PROJECT_ROOT / "venv")}
|
||||
if _is_termux_env(uv_env):
|
||||
uv_env.pop("PYTHONPATH", None)
|
||||
uv_env.pop("PYTHONHOME", None)
|
||||
install_group = "termux-all"
|
||||
print(" → Termux detected: using uv + curated termux-all optional profile...")
|
||||
if _is_termux_env(uv_env) and _is_android_python():
|
||||
print(" → Termux/Android detected: prebuilding psutil with Linux source path compatibility...")
|
||||
_install_psutil_android_compat([uv_bin, "pip"], env=uv_env)
|
||||
_install_python_dependencies_with_optional_fallback(
|
||||
[uv_bin, "pip"], env=uv_env
|
||||
[uv_bin, "pip"], env=uv_env, group=install_group
|
||||
)
|
||||
else:
|
||||
# Use sys.executable to explicitly call the venv's pip module,
|
||||
|
|
@ -7420,10 +7411,13 @@ def _cmd_update_impl(args, gateway_mode: bool):
|
|||
cwd=PROJECT_ROOT,
|
||||
check=True,
|
||||
)
|
||||
if _is_termux_env():
|
||||
install_group = "termux-all"
|
||||
print(" → Termux detected: using curated termux-all optional profile...")
|
||||
if _is_termux_env() and _is_android_python():
|
||||
print(" → Termux/Android detected: prebuilding psutil with Linux source path compatibility...")
|
||||
_install_psutil_android_compat(pip_cmd)
|
||||
_install_python_dependencies_with_optional_fallback(pip_cmd)
|
||||
_install_python_dependencies_with_optional_fallback(pip_cmd, group=install_group)
|
||||
|
||||
_update_node_dependencies()
|
||||
_build_web_ui(PROJECT_ROOT / "web")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue