Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree (570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base = the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main). Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details, conflict table and left-out files are in docs/upstream.md. Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61), docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out. scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run"). Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR macros on. No GPU run, no quality gate. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
134 lines
5.6 KiB
Bash
Executable File
134 lines
5.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# Strata Terminal launcher.
|
|
#
|
|
# An end user must not need a development checkout, a global interpreter, pip or a compiler. This
|
|
# script finds a usable Python in a fixed order and hands over to the CLI; it installs nothing and
|
|
# downloads nothing.
|
|
#
|
|
# Search order:
|
|
# 1. $STRATA_PYTHON — an explicit override, always wins
|
|
# 2. <this dir>/python/bin/python3 — the private runtime shipped with the distribution
|
|
# 3. A Python 3.10+ found on PATH — a developer convenience, never a requirement
|
|
#
|
|
# The private runtime is a *relocatable* CPython plus this distribution's dependencies, staged into
|
|
# `python/` beside this script. `docs/work/QUALIFICATION-KIT.md` gives the staging command. When it
|
|
# is absent the launcher still works anywhere a 3.10+ interpreter exists, and says so clearly rather
|
|
# than failing obscurely.
|
|
set -eu
|
|
|
|
# Resolve this script's real directory, following symlinks, so `strata` can live on PATH.
|
|
self=$0
|
|
while [ -L "$self" ]; do
|
|
dir=$(CDPATH= cd -- "$(dirname -- "$self")" && pwd -P)
|
|
target=$(readlink "$self")
|
|
case $target in
|
|
/*) self=$target ;;
|
|
*) self=$dir/$target ;;
|
|
esac
|
|
done
|
|
HERE=$(CDPATH= cd -- "$(dirname -- "$self")" && pwd -P)
|
|
|
|
pick_python() {
|
|
if [ -n "${STRATA_PYTHON:-}" ]; then
|
|
if [ -x "$STRATA_PYTHON" ]; then printf '%s\n' "$STRATA_PYTHON"; return 0; fi
|
|
echo "strata: STRATA_PYTHON=$STRATA_PYTHON is not executable" >&2
|
|
return 1
|
|
fi
|
|
|
|
# The private runtime shipped with the distribution.
|
|
#
|
|
# Two layouts are supported, and the relative depth differs between them:
|
|
# * an installed distribution: <root>/bin/strata with the runtime at <root>/python/
|
|
# * a source checkout: <root>/bin/strata with no bundled runtime at all
|
|
# So the parent directory is checked as well as this one. Getting this wrong is silent: the
|
|
# launcher falls through to whatever Python is on PATH and the bundle stops being self-contained.
|
|
for candidate in \
|
|
"$HERE/../python/bin/python3" "$HERE/python/bin/python3" \
|
|
"$HERE/../python/bin/python" "$HERE/python/bin/python"; do
|
|
if [ -x "$candidate" ]; then printf '%s\n' "$candidate"; return 0; fi
|
|
done
|
|
|
|
# Anything on PATH that is new enough, then the usual places an interpreter lives on macOS
|
|
# without being on a non-interactive PATH (Homebrew, python.org, and the interpreter a DeepSeek
|
|
# Harness installation already ships, which is a legitimate Python 3.12 to reuse rather than
|
|
# download a second copy of). Strata needs 3.10 or newer; macOS's own /usr/bin/python3 is 3.9 and
|
|
# is correctly rejected below.
|
|
for candidate in \
|
|
"$(command -v python3 2>/dev/null || true)" \
|
|
"$(command -v python 2>/dev/null || true)" \
|
|
/opt/homebrew/bin/python3 /usr/local/bin/python3 \
|
|
/Library/Frameworks/Python.framework/Versions/3.13/bin/python3 \
|
|
/Library/Frameworks/Python.framework/Versions/3.12/bin/python3 \
|
|
/Library/Frameworks/Python.framework/Versions/3.11/bin/python3 \
|
|
"/Applications/DeepSeek Harness.app/Contents/Resources/runtime/primary-runtime/dependencies/python/bin/python3" \
|
|
/usr/bin/python3
|
|
do
|
|
[ -n "$candidate" ] || continue
|
|
[ -x "$candidate" ] || continue
|
|
if "$candidate" -c 'import sys; raise SystemExit(0 if sys.version_info[:2] >= (3, 10) else 1)' 2>/dev/null; then
|
|
printf '%s\n' "$candidate"; return 0
|
|
fi
|
|
done
|
|
|
|
return 1
|
|
}
|
|
|
|
if ! PY=$(pick_python); then
|
|
cat >&2 <<'MSG'
|
|
strata: no usable Python found.
|
|
|
|
This distribution is meant to run on its own. If you are seeing this, the private runtime is
|
|
missing from the install and no Python 3.10+ is on your PATH.
|
|
|
|
* Reinstall the distribution, which restores the bundled runtime, or
|
|
* set STRATA_PYTHON=/path/to/python3 (3.10 or newer), or
|
|
* install Python 3.10+ and run this launcher again.
|
|
MSG
|
|
exit 5
|
|
fi
|
|
|
|
# Find the application root. Two layouts are supported so the same launcher works from a checkout
|
|
# (`bin/strata` beside `strata.py`) and from an installed distribution (`<root>/bin/strata` with the
|
|
# code under `<root>/`).
|
|
if [ -f "$HERE/strata.py" ]; then
|
|
APP=$HERE
|
|
elif [ -f "$HERE/../strata.py" ]; then
|
|
APP=$(CDPATH= cd -- "$HERE/.." && pwd -P)
|
|
else
|
|
echo "strata: cannot find strata.py next to $HERE or its parent; the installation looks incomplete" >&2
|
|
exit 5
|
|
fi
|
|
|
|
# Only the API server needs third-party packages. `--help`, `status`, `monitor`, `timeskip` and
|
|
# `tune plan` are deliberately stdlib-only — the CLI imports `serve.*` lazily inside the functions
|
|
# that need it — so they must keep working on a bare interpreter. Checking them here anyway was a
|
|
# real defect: it made `strata --help` refuse to run on an interpreter that could have answered it.
|
|
#
|
|
# A missing dependency is reported as a typed, actionable failure rather than a traceback, and
|
|
# nothing is ever installed here.
|
|
case "${1:-}" in
|
|
serve|bench)
|
|
if ! "$PY" - <<'PROBE' 2>/dev/null
|
|
import importlib.util, sys
|
|
need = ("jinja2", "yaml", "regex", "psutil", "requests", "numpy", "PIL")
|
|
missing = [m for m in need if importlib.util.find_spec(m) is None]
|
|
if missing:
|
|
sys.stderr.write("missing: " + ", ".join(missing) + "\n")
|
|
raise SystemExit(1)
|
|
PROBE
|
|
then
|
|
echo "strata: the interpreter $PY is missing packages the API server needs." >&2
|
|
echo " Run: $PY -m pip install -r \"$APP/requirements.txt\"" >&2
|
|
echo " (strata status, monitor, timeskip and tune plan do not need them)" >&2
|
|
exit 5
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
# The private runtime must not see the user's site-packages, PYTHONHOME or PYTHONPATH.
|
|
case $PY in
|
|
"$HERE"/../python/*|"$HERE"/python/*) PYTHONNOUSERSITE=1; export PYTHONNOUSERSITE; unset PYTHONHOME PYTHONPATH ;;
|
|
esac
|
|
|
|
exec "$PY" "$APP/strata.py" "$@"
|