Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
Packaged Terminal: setup.py without CMakeLists.txt, and strata install hands its options to setup (#4188)
Niko1221012bea51f86f
diff --git a/setup.py b/setup.pyindex bf5cd2e69..2fdd01e0e 100644--- a/setup.py+++ b/setup.py@@ -5160,7 +5160,10 @@ def prebuilt_bases(url_base) -> list[str]:base = url_base if url_base.endswith(("/", "\\")) else url_base + "/"if base != PREBUILT_URL:return [base]- return [PREBUILT_TAG_URL.format(version=source_version()), base]+ version = source_version()+ if version == "0": # no source tree to name a release by (the packaged Terminal): the latest release+ return [base]+ return [PREBUILT_TAG_URL.format(version=version), base]PREVIOUS_ENGINE = ".previous"@@ -6677,8 +6680,13 @@ def installed_configs():def source_version() -> str:- """The engine version the source tree builds (CMakeLists.txt's project version)."""- m = re.search(r"project\(strata VERSION ([\d.]+)", (ROOT / "CMakeLists.txt").read_text(encoding="utf-8"))+ """The engine version the source tree builds (CMakeLists.txt's project version). "0" when there is none to read: the packaged+ Terminal carries no CMakeLists.txt (it ships VERSION and BUNDLE.json), and a missing file was a FileNotFoundError out of+ prebuilt_bases() that ended the whole setup (#4188)."""+ try:+ m = re.search(r"project\(strata VERSION ([\d.]+)", (ROOT / "CMakeLists.txt").read_text(encoding="utf-8"))+ except (OSError, UnicodeDecodeError):+ return "0"return m.group(1) if m else "0"@@ -6696,8 +6704,8 @@ def stale_binary(exe) -> bool:"""#2054: the engine binary is of another version than this source tree builds. A BUILD.json that carries thesource's hash and version cannot be trusted alone: a build that stopped (a host compiler the toolkit rejects) canleave the old binary beside a stamp of the new source, and nothing would ever compile it again."""- v = binary_engine_version(exe)- return v is not None and v != source_version()+ v, source = binary_engine_version(exe), source_version()+ return v is not None and source != "0" and v != source # "0": no source tree to compare with (the packaged Terminal)def engine_version(exe: Path) -> tuple:diff --git a/strata_cli/cli.py b/strata_cli/cli.pyindex c267c5d55..0cad0dc7a 100644--- a/strata_cli/cli.py+++ b/strata_cli/cli.py@@ -2214,6 +2214,21 @@ class _QuietCapture:return self.text+def _install_argv(argv: list[str]) -> list[str]:+ """`strata install` hands everything after it to setup.py (`strata install --family qwen --model IQ3_XXS --yes`). argparse cannot do that+ by itself: an option it does not know ahead of the first plain word (--source, --family) was refused as "unrecognized arguments", or+ split from its value (#4188). So the options of setup.py go behind a `--`, and only `--update` and --help stay strata's own."""+ if not argv or argv[0] != "install":+ return argv+ rest = list(argv[1:])+ if rest and rest[0] in ("-h", "--help"):+ return argv+ update = "--update" in rest+ if update:+ rest.remove("--update")+ return ["install", *(["--update"] if update else []), "--", *rest]++def main(argv: list[str] | None = None) -> int:try:from strata_control import private_files@@ -2221,8 +2236,9 @@ def main(argv: list[str] | None = None) -> int:except ImportError: # a thin bundle ships without strata_controlpassap = parser()- a, extras = ap.parse_known_args(argv)- a.raw_argv = list(sys.argv[1:] if argv is None else argv)+ raw = list(sys.argv[1:] if argv is None else argv)+ a, extras = ap.parse_known_args(_install_argv(raw))+ a.raw_argv = rawif extras:if getattr(a, "command", None) in ("launch", "connect"):from strata_cli.launch import cmd as launch_cmddiff --git a/tests/terminal/test_packaged_setup_028.py b/tests/terminal/test_packaged_setup_028.pynew file mode 100644index 000000000..cc684c39b--- /dev/null+++ b/tests/terminal/test_packaged_setup_028.py@@ -0,0 +1,78 @@+"""The packaged Terminal (#4188 parts 2 and 3): setup.py without a CMakeLists.txt, and `strata install` handing setup its options.+Nothing here starts an engine, downloads anything or reads the real profile."""+from __future__ import annotations++import os+import subprocess+import tempfile+import unittest+from pathlib import Path+from unittest import mock++import setup as S+from strata_cli import cli+++class PackagedSetupWithoutCMake(unittest.TestCase):+ """#4188: the packaged Terminal ships VERSION and BUNDLE.json but no CMakeLists.txt."""++ def test_source_version_is_zero_without_a_source_tree(self):+ with tempfile.TemporaryDirectory() as tmp, mock.patch.object(S, "ROOT", Path(tmp)):+ self.assertEqual(S.source_version(), "0")+ (Path(tmp) / "CMakeLists.txt").write_text("project(strata VERSION 0.1.52 LANGUAGES C)\n", encoding="utf-8")+ self.assertEqual(S.source_version(), "0.1.52")+ (Path(tmp) / "CMakeLists.txt").write_bytes(b"\xff\xfe\x00 not text")+ self.assertEqual(S.source_version(), "0")++ def test_prebuilt_bases_names_the_latest_release_when_there_is_no_source_tree(self):+ with tempfile.TemporaryDirectory() as tmp, mock.patch.object(S, "ROOT", Path(tmp)):+ self.assertEqual(S.prebuilt_bases(S.PREBUILT_URL), [S.PREBUILT_URL])+ (Path(tmp) / "CMakeLists.txt").write_text("project(strata VERSION 0.1.52)\n", encoding="utf-8")+ bases = S.prebuilt_bases(S.PREBUILT_URL)+ self.assertEqual(len(bases), 2)+ self.assertIn("v0.1.52", bases[0])+ self.assertEqual(S.prebuilt_bases("https://example.org/engine"), ["https://example.org/engine/"])++ def test_an_installed_engine_is_not_called_stale_just_because_there_is_no_source_to_compare(self):+ with tempfile.TemporaryDirectory() as tmp, mock.patch.object(S, "ROOT", Path(tmp)), \+ mock.patch.object(S, "binary_engine_version", return_value="0.1.50"):+ self.assertFalse(S.stale_binary("x"))+ (Path(tmp) / "CMakeLists.txt").write_text("project(strata VERSION 0.1.52)\n", encoding="utf-8")+ self.assertTrue(S.stale_binary("x"))+++class InstallForwardsSetupOptions(unittest.TestCase):+ """#4188: `strata install --source modelscope --family qwen ...` was refused by strata's own parser."""++ def test_the_options_of_setup_go_behind_a_double_dash_and_update_stays_strata_s(self):+ self.assertEqual(cli._install_argv(["install", "--source", "modelscope", "--yes"]), ["install", "--", "--source", "modelscope", "--yes"])+ self.assertEqual(cli._install_argv(["install", "--family", "qwen", "--update"]), ["install", "--update", "--", "--family", "qwen"])+ self.assertEqual(cli._install_argv(["install"]), ["install", "--"])+ self.assertEqual(cli._install_argv(["install", "-h"]), ["install", "-h"])+ self.assertEqual(cli._install_argv(["status", "--source", "x"]), ["status", "--source", "x"])+ self.assertEqual(cli._install_argv([]), [])++ def test_the_parser_hands_all_of_it_to_setup_in_order(self):+ ap = cli.parser()+ for argv in (["install", "--source", "modelscope", "--family", "qwen", "--model", "IQ3_XXS", "--context", "32k", "--yes"],+ ["install", "--family", "qwen", "--yes"], ["install", "--yes"]):+ a, extras = ap.parse_known_args(cli._install_argv(argv))+ self.assertEqual(extras, [], argv)+ self.assertEqual([x for x in a.setup_args if x != "--"], argv[1:], argv)++ def test_main_runs_setup_with_every_option_and_in_order(self):+ with tempfile.TemporaryDirectory() as tmp:+ (Path(tmp) / "setup.py").write_text("# stand-in\n", encoding="utf-8")+ calls = []+ with mock.patch.dict(os.environ, {"STRATA_INSTALL_DIR": tmp}), \+ mock.patch.object(subprocess, "call", side_effect=lambda argv, **kw: calls.append(argv) or 0):+ code = cli.main(["install", "--source", "modelscope", "--family", "qwen", "--model", "IQ3_XXS", "--context", "32k", "--yes"])+ self.assertEqual(code, 0)+ code = cli.main(["install", "--update", "--yes"])+ self.assertEqual(code, 0)+ self.assertEqual(calls[0][2:], ["--setup", "--source", "modelscope", "--family", "qwen", "--model", "IQ3_XXS", "--context", "32k", "--yes"])+ self.assertEqual(calls[1][2:], ["--update", "--yes"])+++if __name__ == "__main__":+ unittest.main()