The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(termux): keep durable runtime checks and verify the prebuilt TUI
ethernetfe40130d6298
diff --git a/.github/workflows/termux-verify.yml b/.github/workflows/termux-verify.ymlindex e8860b605f6..6830ba0bb82 100644--- a/.github/workflows/termux-verify.yml+++ b/.github/workflows/termux-verify.yml@@ -47,8 +47,27 @@ jobs:tests/pm/test_stage_only.py tests/pm/test_deb_safety.py tests/test_stage_apt_repo.py \tests/test_run_tests_shell.py- native-linkage:- name: Reproduce and verify bionic Python linkage+ tui:+ name: Prebuilt TUI checks+ runs-on: ubuntu-24.04+ timeout-minutes: 15+ steps:+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ persist-credentials: false+ - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0+ with:+ node-version: '22'+ - name: Install the locked JS workspace+ run: npm ci --workspace ui-tui --workspace tests-js --include-workspace-root --include=dev --no-fund --no-audit+ - name: Check and bundle the TUI+ run: |+ npm run check --workspace tests-js+ npm run check --workspace ui-tui+ npm run build --workspace ui-tui++ native-runtime:+ name: Verify bionic runtime toolsruns-on: ubuntu-24.04-armtimeout-minutes: 45steps:@@ -79,38 +98,3 @@ jobs:test -s "$PREFIX/tmp/ffmpeg-proof.wav"printf "FFMPEG_BARE_RUNTIME_OK\n"'- - name: Download the wheel from the confirmed failing build- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4- with:- github-token: ${{ github.token }}- run-id: 34044387547- name: termux-linkage-842e3b0eed0eafbfb3d7f219ea465bd92d055cc2- path: termux-build/baseline- - name: Run the native reproduction- run: |- image=ghcr.io/ethernet8023/hermes-termux-builder:c14ffb703abf- docker pull "$image"- image=$(docker image inspect --format '{{index .RepoDigests 0}}' "$image")- printf 'Builder image: %s\n' "$image"- mkdir -p termux-build/linkage- chmod 0777 termux-build/linkage- docker run --rm --platform linux/arm64 --user 1000:1000 \- -v "$PWD:/repo:ro" -v "$PWD/termux-build/payload:/payload:ro" \- -v "$PWD/termux-build/linkage:/evidence" \- "$image" bash -c '- set -euo pipefail- export PREFIX=/data/data/com.termux/files/usr- export LD_LIBRARY_PATH="/payload/python$PREFIX/lib:/payload/runtime-libs/lib:$PREFIX/lib"- exec "/payload/python$PREFIX/bin/python3.11" \- /repo/scripts/termux/probe_python_linkage.py \- --repo /repo --payload /payload --output /evidence \- --built-wheel /repo/termux-build/baseline/firecrawl_anydoc-0.2.4-cp310-abi3-android_24_arm64_v8a.whl- '- - name: Preserve the built wheel and linker evidence- if: always()- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7- with:- name: termux-linkage-${{ github.sha }}- path: termux-build/linkage/- if-no-files-found: warn- retention-days: 7diff --git a/scripts/termux/probe_python_linkage.py b/scripts/termux/probe_python_linkage.pydeleted file mode 100644index fa47b18e140..00000000000--- a/scripts/termux/probe_python_linkage.py+++ /dev/null@@ -1,133 +0,0 @@-#!/usr/bin/env python3-"""Diagnose the actual anydoc wheel against the pinned bionic interpreter.--This standalone CI diagnostic builds the locked sdist, inspects the ELF-linkage, and tests the same extension with an explicit libpython dependency.-It does not change any package source or publish release artifacts.-"""-from __future__ import annotations--import argparse-import json-import os-from pathlib import Path-import shutil-import subprocess-import sys-import sysconfig-import tempfile-import tomllib-import zipfile---def run(argv: list[str], *, env: dict[str, str] | None = None) -> subprocess.CompletedProcess:- print("+", " ".join(argv), flush=True)- return subprocess.run(argv, check=True, env=env)---def import_anydoc(python: Path, site: Path, env: dict[str, str]) -> subprocess.CompletedProcess:- return subprocess.run(- [str(python), "-c", "import anydoc; print('ANYDOC_IMPORT_OK', anydoc.__file__)"],- env={**env, "PYTHONPATH": str(site)},- capture_output=True,- text=True,- )---def main() -> int:- ap = argparse.ArgumentParser(description=__doc__)- ap.add_argument("--repo", type=Path, required=True)- ap.add_argument("--payload", type=Path, required=True)- ap.add_argument("--output", type=Path, required=True)- ap.add_argument("--built-wheel", type=Path)- args = ap.parse_args()- sys.path.insert(0, str(args.repo))- from pm.store import current_target-- target = current_target()- print("PAYLOAD_TARGET", target, "ANDROID_API_LEVEL", sysconfig.get_config_var("ANDROID_API_LEVEL"), flush=True)- if target != "linux-arm64-bionic":- raise RuntimeError(f"payload interpreter misclassified: {target}")- prefix = Path("/data/data/com.termux/files/usr")- python = args.payload / "python" / prefix.relative_to("/") / "bin/python3.11"- uv = args.payload / "uv" / prefix.relative_to("/") / "bin/uv"- pylib = python.parent.parent / "lib"- runtime_libs = args.payload / "runtime-libs/lib"- env = {**os.environ, "LD_LIBRARY_PATH": f"{pylib}:{runtime_libs}:{prefix}/lib"}- args.output.mkdir(parents=True, exist_ok=True)- lock = tomllib.loads((args.repo / "uv.lock").read_text(encoding="utf-8"))- package = next(p for p in lock["package"] if p["name"] == "firecrawl-anydoc")- requirement = f"firecrawl-anydoc=={package['version']}"- with tempfile.TemporaryDirectory(prefix="hermes-linkage-", dir=prefix / "tmp") as tmp:- venv = Path(tmp) / "venv"- run([str(uv), "venv", "--python", str(python), str(venv)], env=env)- vp = venv / "bin/python"- run([str(uv), "pip", "install", "--python", str(vp), "pip", "packaging"], env=env)- build_env = {- **env,- "CARGO_BUILD_JOBS": "1",- "MAKEFLAGS": "-j1",- "ANDROID_API_LEVEL": "24",- "RUSTFLAGS": f"-L{pylib}",- "LDFLAGS": f"-L{pylib}",- }- if args.built_wheel:- shutil.copy2(args.built_wheel, args.output / args.built_wheel.name)- else:- run([- str(vp), "-m", "pip", "wheel", "--no-deps", "--no-cache-dir",- "--no-binary", ":all:", "-w", str(args.output), requirement,- ], env=build_env)- wheels = sorted(args.output.glob("firecrawl_anydoc-*.whl"))- if len(wheels) != 1:- raise RuntimeError(f"expected one anydoc wheel, found {wheels}")- site = Path(tmp) / "site"- with zipfile.ZipFile(wheels[0]) as wheel:- wheel.extractall(site)- extension = next(site.glob("anydoc/_anydoc*.so"))- library = next(pylib.glob("libpython3.11.so.*"))- readelf = shutil.which("llvm-readelf") or shutil.which("readelf")- if not readelf:- raise RuntimeError("builder has no ELF inspection tool")- run([readelf, "-d", str(extension)])- symbols = subprocess.run([readelf, "--dyn-syms", "--wide", str(library)], check=True, capture_output=True, text=True)- print("libpython export:", *[line for line in symbols.stdout.splitlines() if "_Py_NoneStruct" in line], sep="\n")- baseline = import_anydoc(vp, site, env)- print("BASELINE_EXIT", baseline.returncode, flush=True)- print(baseline.stdout, baseline.stderr, flush=True)- soname = subprocess.run(["patchelf", "--print-soname", str(library)], check=True, capture_output=True, text=True).stdout.strip()- needed = subprocess.run(["patchelf", "--print-needed", str(extension)], check=True, capture_output=True, text=True).stdout.splitlines()- from python_linkage import repair_wheel-- repaired = repair_wheel(wheels[0], library)- if repaired == 0:- raise RuntimeError("production wheel repair did not change the failing extension")- shutil.rmtree(site)- with zipfile.ZipFile(wheels[0]) as wheel:- wheel.extractall(site)- explicit = import_anydoc(vp, site, env)- print("EXPLICIT_LINK_EXIT", explicit.returncode, flush=True)- print(explicit.stdout, explicit.stderr, flush=True)- evidence = {- "requirement": requirement,- "wheel": wheels[0].name,- "libpython_soname": soname,- "original_needed": needed,- "baseline_exit": baseline.returncode,- "baseline_error": baseline.stderr,- "explicit_link_exit": explicit.returncode,- "explicit_link_error": explicit.stderr,- }- (args.output / "linkage-evidence.json").write_text(json.dumps(evidence, indent=2), encoding="utf-8")- if baseline.returncode == 0:- raise RuntimeError("baseline did not reproduce the native import failure")- if "_Py_NoneStruct" not in baseline.stderr:- raise RuntimeError("baseline failed for a different reason")- if explicit.returncode:- raise RuntimeError("explicit libpython dependency did not fix the import")- print("LINKAGE_CAUSE_PROVEN", flush=True)- return 0---if __name__ == "__main__":- raise SystemExit(main())diff --git a/tests/pm/test_extras.py b/tests/pm/test_extras.pyindex d44e083aedf..1bd3a87a5c1 100644--- a/tests/pm/test_extras.py+++ b/tests/pm/test_extras.py@@ -135,9 +135,12 @@ def test_ensure_and_bind_false_on_import_failure(monkeypatch, synced):assert extras.ensure_and_bind("fal", importer, {}) is False-def test_package_reexports():- assert pm.available is extras.available- assert pm.ensure_import is extras.ensure_import+def test_package_exports_preserve_availability_and_noop_install(monkeypatch, synced):+ monkeypatch.setitem(sys.modules, "some_new_thing", SimpleNamespace())+ assert pm.available("some-new-thing") == extras.available("some-new-thing") is True+ assert pm.available("no-such-extra-anywhere") == extras.available("no-such-extra-anywhere") is False+ pm.ensure_import("some-new-thing")+ assert synced == []def test_every_anchor_extra_exists_in_pyproject():