setup.py run(): the app's installer also runs the bundled Mac preparation tools in metal/tools (metal_repack.py, stream_experts.py); a fresh Mac Terminal or app install of UD-Q4_K_XL or UD-IQ4_XS-v31 stopped with "only runs its bundled preparation tools" since af1ffd913. Test: they run, and -m, another interpreter and other folders are still refused

This commit is contained in:
Niko1221 committed 2026-11-07 01:29:36 +01:00
1 parent 9780a8c27d
commit 146df3c468
2 files changed
+22 -1

No files matched your search

+1 -1
View File
@@ -1130,7 +1130,7 @@ def run(cmd, cwd=None, env=None, check=True, quiet=False):
if CONTROL: # the app: only this Python running a bundled tool
argv = [str(c) for c in cmd]
if len(argv) < 2 or os.path.normcase(argv[0]) != os.path.normcase(sys.executable) or argv[1] == "-m" or \
Path(argv[1]).resolve().parent not in ((ROOT / "tools").resolve(), (ROOT / "tools" / "dsv41").resolve()):
Path(argv[1]).resolve().parent not in ((ROOT / "tools").resolve(), (ROOT / "tools" / "dsv41").resolve(), (ROOT / "metal" / "tools").resolve()):
raise acquisition.AcquisitionRefused("the desktop app's installer only runs its bundled preparation tools; "
+ " ".join(argv[:2]))
gguf_py = (env or {}).get("STRATA_GGUF_PY")
+21
View File
@@ -73,6 +73,27 @@ class ControlModeTests(unittest.TestCase):
S.run([sys.executable, str(tool), "--help"], check=False)
runner.assert_called_once()
def test_the_mac_preparation_tools_in_metal_tools_may_run_and_nothing_else_beside_them(self):
# mac_repack() and mac_stream run metal/tools/metal_repack.py and stream_experts.py (mac_tools_dir() = ROOT/metal/tools): the bundled Mac tools, like tools/*.py
S = self.S
done = subprocess.CompletedProcess([], 0)
for tool in ("metal_repack.py", "stream_experts.py"):
with self.subTest(allowed=tool), mock.patch.object(S.subprocess, "run", return_value=done) as runner:
S.run([sys.executable, str(ROOT / "metal" / "tools" / tool), "--help"], check=False)
runner.assert_called_once()
for refused in (
[sys.executable, "-m", "metal.tools.metal_repack"], # -m is never allowed
["python3", str(ROOT / "metal" / "tools" / "metal_repack.py")], # another interpreter
[sys.executable, str(ROOT / "metal" / "kernels" / "evil.py")], # another folder of the bundle
[sys.executable, str(ROOT / "metal" / "evil.py")], # metal/ itself
[sys.executable, str(self.home / "metal" / "tools" / "metal_repack.py")], # a copy in the install folder
[sys.executable, str(ROOT / "metal" / "tools" / ".." / ".." / "setup.py")],
[sys.executable],
):
with self.subTest(refused=refused), mock.patch.object(S.subprocess, "run", side_effect=AssertionError("ran")):
with self.assertRaises(S.acquisition.AcquisitionRefused):
S.run(refused)
def test_no_package_is_installed(self):
S = self.S
with mock.patch.object(S, "run", side_effect=AssertionError("pip")), \