Files
strata/strata.py
T
Niko1221 66bc889072 terminal archive: bundled Python for Windows x64 and Linux x86_64, hash-locked wheels, launchers, smoke test
package_terminal.py builds the terminal archive for windows-x86_64 (.zip), linux-x86_64 and darwin-arm64 (.tar.gz)
from the pinned python-build-standalone CPython 3.12.15 (SHA-256 per target, from the release's SHA256SUMS) and a
per-target lock, packaging/locks/runtime-<target>-cp312.txt, installed with pip --require-hashes --no-deps
--only-binary=:all: at BUILD time only (pip is the interpreter's own, no upgrade; the result must equal the lock).
packaging/lock_wheels.py makes a lock. Console-script launchers that name the build path are removed; a VERSION
file and the read-only gguf_reader tool join the payload.

- bin/strata.cmd and bin/strata.ps1 (Windows), bin/strata (POSIX): the bundled runtime first, PYTHONNOUSERSITE=1,
  no PYTHONHOME/PYTHONPATH; a path with spaces works.
- START-HERE.bat, SETUP.bat, UPDATE.bat, setup.sh, update.sh use a python/ folder beside them when present (no
  Python lookup or install).
- strata --version (one line: version and interpreter), strata serve --engine mock, a typed exit-5 message when the
  server's packages are missing (strata.py preflight).
- packaging/smoke_terminal.py extracts an archive in a clean env (space in the path, PATH without Python, dead proxy)
  and runs --version, doctor, profile list, install, serve --engine mock (health, models, a chat answer).
- tests/terminal/test_packaging_pins.py: digests, lock shape and agreement with requirements.txt, launcher order.
2026-10-15 12:06:29 +02:00

36 lines
1.4 KiB
Python

"""Strata's small, dependency-free terminal entry point.
Run ``python strata.py --help`` from a source checkout. Optional terminal UI
dependencies are imported only by ``monitor``.
"""
import importlib.util
import sys
#: What the API server (serve, bench) imports. Everything else in the CLI is standard library.
SERVER_PACKAGES = ("jinja2", "yaml", "regex", "psutil", "requests", "numpy", "PIL")
def _preflight(argv):
"""A missing package is a typed, actionable error, never an install: starting does not run pip."""
command = next((a for a in argv if not a.startswith("-")), "")
if command not in ("serve", "bench"):
return 0
missing = [m for m in SERVER_PACKAGES if importlib.util.find_spec(m) is None]
if not missing:
return 0
sys.stderr.write(
"strata: the interpreter %s is missing packages the API server needs: %s.\n"
" Starting and serving never install anything. Use the Strata terminal archive (it carries them),\n"
" or install them yourself: python -m pip install -r requirements.txt\n"
" (status, monitor, timeskip and tune plan do not need them)\n" % (sys.executable, ", ".join(missing)))
return 5
if __name__ == "__main__":
code = _preflight(sys.argv[1:])
if code:
raise SystemExit(code)
from strata_cli.cli import main
raise SystemExit(main())