Files
NexusOS/scripts/install-termux.sh
Athena KaminskyandClaude Opus 5 9104c724c4 feat(packaging): move the CLI into nexusos_cli and make the wheel self-sufficient
The CLI shipped from `management/`, which also holds desktop-only pieces (the
Tk control panel, the XFCE panel wiring, the shell wrappers). Packaging that
directory meant the wheel either dragged in tkinter or shipped a broken import.
Split it: `nexusos_cli/` is what the wheel ships and what `nexus`/`ncp`/
`nexusos` dispatch to, `management/` keeps the desktop half.

Alongside the move:

* hatch_build.py decides the interface/web/dist include at build time. dist/
  is gitignored, so a static force-include aborts `pip install -e .` on a
  fresh clone - before the reader reaches the `npm run build` step. Editable
  installs now skip a missing dist; wheels and sdists hard-error naming the
  command to run.
* synapse/proc_util.py gives frontend_manager and ncp process inspection and
  termination without psutil, which became an optional extra when the wheel
  landed. It routes around Windows having no signals, where os.kill(pid, 15)
  is an unblockable TerminateProcess rather than a polite request.
* nexusos_cli/monitor.py adds `ncp monitor`, an ASCII dashboard with no curses
  or rich dependency so it works in Termux, plain SSH and Windows Terminal.
  Collector and renderer are separate so tests feed fixtures, no stack needed.
* tests/test_packaging_deps.py fails the gate when synapse or nexusos_cli
  import a distribution pyproject does not declare, and when an optional
  dependency is imported at module scope instead of lazily.
* bin/check.sh now builds the wheel, twine-checks it, and asserts the compiled
  UI and seed playbooks are actually inside it. A wheel that builds but ships
  no dist/ serves a blank page, which only shows up after release.

tests/test_nexus_api.py moves to tests/ with the module it covers.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-26 08:11:39 -05:00

76 lines
2.6 KiB
Bash

#!/usr/bin/env bash
# Install the portable NexusOS wheel in Termux.
#
# NEXUS_PACKAGE may be a PyPI requirement, wheel URL, or local wheel path.
# NEXUS_ANDROID_WHEEL_INDEX may point at a trusted PEP 503 index containing
# Android pydantic-core wheels for the device's Python/CPU combination.
set -euo pipefail
if [[ "${PREFIX:-}" != *com.termux* ]]; then
echo "This installer must be run inside Termux." >&2
exit 2
fi
PACKAGE_SPEC="${1:-${NEXUS_PACKAGE:-nexusos-ai}}"
echo "==> Installing Termux prerequisites"
pkg update -y
pkg install -y python python-pip curl clang make
PYTHON_TAG="$(python -c 'import sys; print(f"cp{sys.version_info.major}{sys.version_info.minor}")')"
ARCH="$(uname -m)"
echo "==> Python ${PYTHON_TAG}; architecture ${ARCH}"
PIP_INDEX_ARGS=()
if [[ -n "${NEXUS_ANDROID_WHEEL_INDEX:-}" ]]; then
PIP_INDEX_ARGS+=(--extra-index-url "${NEXUS_ANDROID_WHEEL_INDEX}")
fi
# Pydantic 2 is required on Python 3.14+, and its Rust extension is not built
# reliably on-device. Require a binary before asking pip to resolve NexusOS so
# failures are immediate and actionable. Older Termux environments also benefit
# from using a wheel instead of compiling the extension on a phone.
echo "==> Checking for an Android pydantic-core wheel"
if ! python -m pip install \
--only-binary=pydantic-core \
"${PIP_INDEX_ARGS[@]}" \
"pydantic>=2.7,<3"; then
cat >&2 <<EOF
No compatible pydantic-core wheel was found for ${PYTHON_TAG}/${ARCH}.
PyPI does not currently publish Android wheels for this native dependency.
Set NEXUS_ANDROID_WHEEL_INDEX to a trusted NexusOS Android wheel index and
run this installer again. Do not force a source build on a memory-limited phone.
EOF
exit 1
fi
echo "==> Installing ${PACKAGE_SPEC}"
# Same extra index as the pydantic-core probe: a NexusOS wheel hosted there
# would otherwise be invisible to the resolver.
python -m pip install "${PIP_INDEX_ARGS[@]}" "${PACKAGE_SPEC}"
echo "==> Initializing NexusOS"
nexus init
if [[ -n "${NEXUS_PROVIDER_URL:-}" ]]; then
nexus provider use remote --url "${NEXUS_PROVIDER_URL}"
fi
# Report health without aborting: `set -e` would otherwise skip the guidance
# below whenever doctor finds a failing required check - exactly when the
# reader most needs to see what to do next. The status is re-raised at exit.
DOCTOR_STATUS=0
nexus doctor || DOCTOR_STATUS=$?
cat <<'EOF'
NexusOS is installed. Configure an Ollama-compatible provider, then run:
nexus provider use remote --url http://YOUR-OLLAMA-HOST:11434
nexus serve
Open http://127.0.0.1:8000 in the Android browser.
EOF
exit "${DOCTOR_STATUS}"