Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: run the Windows sandbox (MXC) on ARM64 PCs with Microsoft's ARM64 build (#14176)

Daniel Hane4ff174894e4
diff --git a/studio/backend/core/inference/mxc_runtime.py b/studio/backend/core/inference/mxc_runtime.py
index fd44ae9f84e..9424e59328f 100644
--- a/studio/backend/core/inference/mxc_runtime.py
+++ b/studio/backend/core/inference/mxc_runtime.py
@@ -10,7 +10,6 @@ import json
import logging
import os
from pathlib import Path
-import platform
import re
import subprocess
import sys
@@ -35,6 +34,14 @@ WXC_EXEC_SHA256 = "6049c64723af1173c3739dc6cd6b2f33f6c021bb2832c4216233cba7f71ae
RELEASE_HOST_PREP_MEMBER = "package/bin/x64/wxc-host-prep.exe"
WXC_HOST_PREP_SIZE = 913_728
WXC_HOST_PREP_SHA256 = "a9b8b14a11a1c5888641297c26abca547c2afa4435085c03ccfebd1deface310"
+# The same package's ARM64 build: ARM64 PCs need it (the x64 one fails its live check under emulation).
+ARM64_RELEASE_MEMBER = "package/bin/arm64/wxc-exec.exe"
+ARM64_WXC_EXEC_SIZE = 4_836_152
+ARM64_WXC_EXEC_SHA256 = "dde1c592270e9a659b01dccad70362da7b99fec114885fa4d625507aa775a503"
+ARM64_RELEASE_HOST_PREP_MEMBER = "package/bin/arm64/wxc-host-prep.exe"
+ARM64_WXC_HOST_PREP_SIZE = 804_664
+ARM64_WXC_HOST_PREP_SHA256 = "c8ddcf0461ae3d7ddff4656abb87b51236146742bb711a2e03fdc23cb8a966b0"
+_ARCHITECTURES = ("x86_64", "arm64")
HOST_PREP_STEPS = ("prepare-system-drive", "prepare-null-device")
HOST_PREP_PROBE_SECONDS = 10.0
DACL_RECOVERY_SECONDS = 60.0
@@ -53,15 +60,16 @@ class MxcRuntimeUnavailable(RuntimeError):
class RuntimeInfo:
path: Path
sha256: str
+ architecture: str = "x86_64"
@property
def identity(self) -> str:
material = {
- "architecture": "x86_64",
+ "architecture": self.architecture,
"mxcRevision": MXC_REVISION,
"releaseTag": RELEASE_TAG,
"sha256": self.sha256,
- "size": WXC_EXEC_SIZE,
+ "size": _artifact(self.architecture, "exec")[1],
}
encoded = json.dumps(material, sort_keys = True, separators = (",", ":")).encode()
return hashlib.sha256(encoded).hexdigest()
@@ -97,7 +105,11 @@ def _studio_root() -> Path:
def _installed_package_root() -> Path:
- return _studio_root() / "mxc-runtime" / "windows-x86_64"
+ try:
+ architecture = _expected_architecture()
+ except MxcRuntimeUnavailable:
+ architecture = "x86_64"
+ return _studio_root() / "mxc-runtime" / f"windows-{architecture}"
def dacl_state_path() -> Path:
@@ -136,15 +148,35 @@ def _require_plain_directory(path: Path) -> Path:
def _expected_architecture() -> str:
- machine = platform.machine().casefold()
- if machine not in {"amd64", "x86_64"}:
+ """The OS architecture, not the interpreter's: an x64 Python on an ARM64 PC still needs the ARM64 build."""
+ from .wsl_host import native_machine
+
+ machine = native_machine()
+ if machine not in _ARCHITECTURES:
raise MxcRuntimeUnavailable(
- f"Microsoft MXC v0.8.0 is supported only on Windows x86-64, not {machine or 'unknown'}",
+ f"Microsoft MXC v0.8.0 is supported only on Windows x64 and ARM64, not {machine or 'unknown'}",
)
- return "x86_64"
+ return machine
+
+
+def _artifact(architecture: str, kind: str) -> tuple[str, int, str]:
+ if architecture == "arm64":
+ if kind == "exec":
+ return ARM64_RELEASE_MEMBER, ARM64_WXC_EXEC_SIZE, ARM64_WXC_EXEC_SHA256
+ return ARM64_RELEASE_HOST_PREP_MEMBER, ARM64_WXC_HOST_PREP_SIZE, ARM64_WXC_HOST_PREP_SHA256
+ if kind == "exec":
+ return RELEASE_MEMBER, WXC_EXEC_SIZE, WXC_EXEC_SHA256
+ return RELEASE_HOST_PREP_MEMBER, WXC_HOST_PREP_SIZE, WXC_HOST_PREP_SHA256
-def _validate_artifact(package_root: Path, name: str, size: int, sha256: str) -> RuntimeInfo:
+def artifact(kind: str) -> tuple[str, int, str]:
+ """(package member, size, sha256) of ``exec`` or ``prep`` for this PC's architecture."""
+ return _artifact(_expected_architecture(), kind)
+
+
+def _validate_artifact(package_root: Path, name: str, kind: str) -> RuntimeInfo:
+ architecture = _expected_architecture()
+ _member, size, sha256 = _artifact(architecture, kind)
root = _require_plain_directory(package_root)
executable = root / name
if not executable.is_file() or executable.is_symlink():
@@ -162,17 +194,15 @@ def _validate_artifact(package_root: Path, name: str, size: int, sha256: str) ->
digest = _sha256_file(executable)
if digest != sha256:
raise MxcRuntimeUnavailable(f"the managed {name} digest is not approved")
- return RuntimeInfo(path = executable.resolve(), sha256 = digest)
+ return RuntimeInfo(path = executable.resolve(), sha256 = digest, architecture = architecture)
def _validate_runtime(package_root: Path) -> RuntimeInfo:
- return _validate_artifact(package_root, _WXC_EXEC_NAME, WXC_EXEC_SIZE, WXC_EXEC_SHA256)
+ return _validate_artifact(package_root, _WXC_EXEC_NAME, "exec")
def _validate_host_prep(package_root: Path) -> RuntimeInfo:
- return _validate_artifact(
- package_root, _WXC_HOST_PREP_NAME, WXC_HOST_PREP_SIZE, WXC_HOST_PREP_SHA256
- )
+ return _validate_artifact(package_root, _WXC_HOST_PREP_NAME, "prep")
def selected_runtime(*, package_root: Path | None = None) -> RuntimeInfo:
diff --git a/studio/backend/core/inference/sandbox_setup_plan.py b/studio/backend/core/inference/sandbox_setup_plan.py
index c1f3f22a616..938b5986b19 100644
--- a/studio/backend/core/inference/sandbox_setup_plan.py
+++ b/studio/backend/core/inference/sandbox_setup_plan.py
@@ -341,10 +341,10 @@ MXC_MIN_WINDOWS_BUILD = 26100
def windows_runtime_unsupported() -> str | None:
- """None when this Windows can run MXC; else "arch" (not x64) or "build" (older than 26100)."""
- import platform
+ """None when this Windows can run MXC; else "arch" (not x64 or ARM64) or "build" (older than 26100)."""
+ from .wsl_host import native_machine
- if platform.machine().lower() not in ("amd64", "x86_64"):
+ if native_machine() not in ("x86_64", "arm64"):
return "arch"
try:
build = sys.getwindowsversion().build
@@ -384,12 +384,12 @@ def windows_builtin_container_update() -> tuple[str, str] | None:
def windows_runtime_supported() -> bool:
- """The MXC runtime Unsloth installs is built for x64 Windows 11 build 26100 or newer."""
+ """The MXC runtime Unsloth installs is built for x64 and ARM64 Windows 11 build 26100 or newer."""
return windows_runtime_unsupported() is None
_UNSUPPORTED_NOTES = {
- "arch": "The MXC runtime is built for x64 Windows, and this PC is not x64.",
+ "arch": "The MXC runtime is built for x64 and ARM64 Windows, and this PC is neither.",
"build": (
f"The MXC sandbox needs Windows 11 build {MXC_MIN_WINDOWS_BUILD} (24H2) or newer, "
"and this PC runs an older build."
diff --git a/studio/backend/core/inference/sandbox_windows_mxc.py b/studio/backend/core/inference/sandbox_windows_mxc.py
index f7bf4644bfa..cabf523069d 100644
--- a/studio/backend/core/inference/sandbox_windows_mxc.py
+++ b/studio/backend/core/inference/sandbox_windows_mxc.py
@@ -181,7 +181,7 @@ def prepare(plan, capability):
network_policy = "mxc_compatibility_requested_unverified",
backend_tier = "unknown",
runtime_revision = mxc_runtime.MXC_REVISION,
- runtime_artifact_digest = f"sha256:{mxc_runtime.WXC_EXEC_SHA256}",
+ runtime_artifact_digest = f"sha256:{mxc_runtime.artifact('exec')[2]}",
schema_version = mxc_runtime.MXC_SCHEMA_VERSION,
policy_hash = request["policyHash"],
execution_status = "planned",
diff --git a/studio/backend/core/inference/wsl_host.py b/studio/backend/core/inference/wsl_host.py
index 9f1cadc5c81..4ef9e88fe98 100644
--- a/studio/backend/core/inference/wsl_host.py
+++ b/studio/backend/core/inference/wsl_host.py
@@ -182,9 +182,18 @@ def native_machine() -> str:
"""The OS architecture, not the interpreter's: an x64 Python under ARM64 emulation reports AMD64."""
try:
import ctypes
-
- process, native = ctypes.c_ushort(), ctypes.c_ushort()
- kernel32 = ctypes.windll.kernel32
+ from ctypes import wintypes
+
+ # Typed, or the pseudo-handle arrives truncated under x64-on-ARM64 emulation and AMD64 is reported.
+ kernel32 = ctypes.WinDLL("kernel32")
+ kernel32.GetCurrentProcess.restype = wintypes.HANDLE
+ kernel32.IsWow64Process2.argtypes = [
+ wintypes.HANDLE,
+ ctypes.POINTER(wintypes.USHORT),
+ ctypes.POINTER(wintypes.USHORT),
+ ]
+ kernel32.IsWow64Process2.restype = wintypes.BOOL
+ process, native = wintypes.USHORT(), wintypes.USHORT()
if kernel32.IsWow64Process2(
kernel32.GetCurrentProcess(), ctypes.byref(process), ctypes.byref(native)
):
@@ -192,7 +201,12 @@ def native_machine() -> str:
except (AttributeError, OSError):
pass
arch = os.environ.get("PROCESSOR_ARCHITEW6432") or os.environ.get("PROCESSOR_ARCHITECTURE", "")
- return {"AMD64": "x86_64", "ARM64": "arm64"}.get(arch.upper(), arch.lower())
+ if not arch:
+ import platform
+ arch = platform.machine()
+ return {"AMD64": "x86_64", "X86_64": "x86_64", "ARM64": "arm64", "AARCH64": "arm64"}.get(
+ arch.upper(), arch.lower()
+ )
def windows_build() -> int:
diff --git a/studio/backend/routes/settings.py b/studio/backend/routes/settings.py
index e2e296fc839..788df69c1ce 100644
--- a/studio/backend/routes/settings.py
+++ b/studio/backend/routes/settings.py
@@ -5083,7 +5083,7 @@ class SandboxToolStatus(BaseModel):
class SandboxWindowsStatus(BaseModel):
runtime_installed: bool
- # None: this Windows can run MXC; "arch" (not x64) or "build" (older than 26100) otherwise.
+ # None: this Windows can run MXC; "arch" (not x64 or ARM64) or "build" (older than 26100) otherwise.
runtime_unsupported: Optional[Literal["arch", "build"]] = None
allow_dacl_fallback: bool
allow_dacl_fallback_saved: bool
diff --git a/studio/backend/tests/test_install_mxc_prebuilt.py b/studio/backend/tests/test_install_mxc_prebuilt.py
index 1bb1c82847e..653bc97d1f1 100644
--- a/studio/backend/tests/test_install_mxc_prebuilt.py
+++ b/studio/backend/tests/test_install_mxc_prebuilt.py
@@ -113,6 +113,37 @@ def test_installs_only_the_official_wxc_member(tmp_path, official_release):
)
+def test_arm64_pc_installs_the_arm64_members(tmp_path, monkeypatch):
+ x64, arm64, arm64_prep = b"official-wxc", b"official-wxc-arm64", b"official-host-prep-arm64"
+ archive = _archive(
+ [
+ (installer.mxc_runtime.RELEASE_MEMBER, x64, stat.S_IFREG | 0o644),
+ (installer.mxc_runtime.RELEASE_HOST_PREP_MEMBER, _HOST_PREP, stat.S_IFREG | 0o644),
+ (installer.mxc_runtime.ARM64_RELEASE_MEMBER, arm64, stat.S_IFREG | 0o644),
+ (
+ installer.mxc_runtime.ARM64_RELEASE_HOST_PREP_MEMBER,
+ arm64_prep,
+ stat.S_IFREG | 0o644,
+ ),
+ ]
+ )
+ monkeypatch.setattr(installer.sys, "platform", "win32")
+ monkeypatch.setattr(installer.mxc_runtime.sys, "platform", "win32")
+ monkeypatch.setattr(installer.mxc_runtime, "_expected_architecture", lambda: "arm64")
+ for name, payload in (("WXC_EXEC", arm64), ("WXC_HOST_PREP", arm64_prep)):
+ monkeypatch.setattr(installer.mxc_runtime, f"ARM64_{name}_SIZE", len(payload))
+ monkeypatch.setattr(
+ installer.mxc_runtime, f"ARM64_{name}_SHA256", hashlib.sha256(payload).hexdigest()
+ )
+ _serve(monkeypatch, archive)
+ install_dir = tmp_path / "installed" / "windows-arm64"
+ assert installer.install_mxc_release(install_dir) is True
+ assert (install_dir / "wxc-exec.exe").read_bytes() == arm64
+ assert (install_dir / "wxc-host-prep.exe").read_bytes() == arm64_prep
+ assert installer.mxc_runtime.selected_runtime(package_root = install_dir).architecture == "arm64"
+ assert installer.install_mxc_release(install_dir) is False
+
+
def test_matching_install_is_reused_without_download(tmp_path, monkeypatch, official_release):
install_dir = tmp_path / "installed" / "windows-x86_64"
assert installer.install_mxc_release(install_dir) is True
@@ -390,7 +421,7 @@ def test_host_prep_runs_elevated_only_from_an_admin_only_copy(tmp_path):
script.index("icacls.exe"),
script.index("GetFileSystemEntries"),
script.index("[IO.File]::Copy"),
- script.index(installer.mxc_runtime.WXC_HOST_PREP_SHA256.upper()),
+ script.index(installer.mxc_runtime.artifact("prep")[2].upper()),
script.index("& $exe"),
)
assert lock < empty < copy < hashed < run
diff --git a/studio/backend/tests/test_mxc_native_windows.py b/studio/backend/tests/test_mxc_native_windows.py
index 144f079992a..4752211cebd 100644
--- a/studio/backend/tests/test_mxc_native_windows.py
+++ b/studio/backend/tests/test_mxc_native_windows.py
@@ -98,7 +98,7 @@ def test_native_mxc_python_output_cannot_forge_execution_records():
assert record.completion_status == "finished"
assert record.cleanup_status == "complete"
assert record.runtime_revision == mxc_runtime.MXC_REVISION
- assert record.runtime_artifact_digest == f"sha256:{mxc_runtime.WXC_EXEC_SHA256}"
+ assert record.runtime_artifact_digest == f"sha256:{mxc_runtime.artifact('exec')[2]}"
assert record.schema_version == mxc_runtime.MXC_SCHEMA_VERSION
assert record.policy_hash.startswith("sha256:")
diff --git a/studio/backend/tests/test_mxc_runtime_integrity.py b/studio/backend/tests/test_mxc_runtime_integrity.py
index 8dc7831dbd4..4e7998f1fcb 100644
--- a/studio/backend/tests/test_mxc_runtime_integrity.py
+++ b/studio/backend/tests/test_mxc_runtime_integrity.py
@@ -19,7 +19,7 @@ _REAL_ARCHITECTURE = mxc_runtime._expected_architecture
@pytest.fixture
def runtime(tmp_path, monkeypatch):
- # The runtime is x86-64 only; an arm64 test host (Apple Silicon CI) is not the host under test.
+ # Pinned to x64 so an arm64 test host (Apple Silicon CI) checks the same pins.
monkeypatch.setattr(mxc_runtime, "_expected_architecture", lambda: "x86_64")
root = tmp_path / "managed" / "windows-x86_64"
root.mkdir(parents = True)
@@ -64,11 +64,47 @@ def test_missing_wxc_is_rejected(runtime):
mxc_runtime.selected_runtime(package_root = runtime)
-def test_wrong_architecture_is_rejected(runtime, monkeypatch):
+def test_unsupported_architecture_is_rejected(runtime, monkeypatch):
+ from core.inference import wsl_host
+
+ monkeypatch.setattr(mxc_runtime, "_expected_architecture", _REAL_ARCHITECTURE)
+ monkeypatch.setattr(wsl_host, "native_machine", lambda: "x86")
+ with pytest.raises(mxc_runtime.MxcRuntimeUnavailable, match = "x64 and ARM64"):
+ mxc_runtime.selected_runtime(package_root = runtime)
+
+
+def test_arm64_pc_selects_only_the_arm64_build(runtime, monkeypatch, tmp_path):
+ from core.inference import wsl_host
+
+ arm64 = b"official-wxc-arm64-payload"
monkeypatch.setattr(mxc_runtime, "_expected_architecture", _REAL_ARCHITECTURE)
- monkeypatch.setattr(mxc_runtime.platform, "machine", lambda: "ARM64")
- with pytest.raises(mxc_runtime.MxcRuntimeUnavailable, match = "x86-64"):
+ monkeypatch.setattr(wsl_host, "native_machine", lambda: "arm64")
+ monkeypatch.setattr(mxc_runtime, "ARM64_WXC_EXEC_SIZE", len(arm64))
+ monkeypatch.setattr(mxc_runtime, "ARM64_WXC_EXEC_SHA256", hashlib.sha256(arm64).hexdigest())
+ monkeypatch.setenv("UNSLOTH_STUDIO_HOME", str(tmp_path / "home"))
+ assert mxc_runtime._installed_package_root().name == "windows-arm64"
+ with pytest.raises(mxc_runtime.MxcRuntimeUnavailable, match = "size|digest"):
mxc_runtime.selected_runtime(package_root = runtime)
+ (runtime / "wxc-exec.exe").write_bytes(arm64)
+ info = mxc_runtime.selected_runtime(package_root = runtime)
+ assert info.architecture == "arm64"
+ assert mxc_runtime.artifact("exec")[0] == "package/bin/arm64/wxc-exec.exe"
+
+
+def test_x64_identity_and_folder_are_unchanged(runtime, monkeypatch, tmp_path):
+ # Existing installs and probe caches key on these; an x64 PC must see no difference.
+ monkeypatch.setenv("UNSLOTH_STUDIO_HOME", str(tmp_path / "home"))
+ assert mxc_runtime._installed_package_root().name == "windows-x86_64"
+ info = mxc_runtime.selected_runtime(package_root = runtime)
+ material = {
+ "architecture": "x86_64",
+ "mxcRevision": mxc_runtime.MXC_REVISION,
+ "releaseTag": mxc_runtime.RELEASE_TAG,
+ "sha256": hashlib.sha256(_WXC).hexdigest(),
+ "size": len(_WXC),
+ }
+ encoded = json.dumps(material, sort_keys = True, separators = (",", ":")).encode()
+ assert info.identity == hashlib.sha256(encoded).hexdigest()
def test_runtime_lease_holds_and_revalidates_the_wxc_file(runtime, monkeypatch):
diff --git a/studio/backend/tests/test_sandbox_runtime_install.py b/studio/backend/tests/test_sandbox_runtime_install.py
index 4b2a140bb84..3e064cf7496 100644
--- a/studio/backend/tests/test_sandbox_runtime_install.py
+++ b/studio/backend/tests/test_sandbox_runtime_install.py
@@ -49,8 +49,11 @@ class _Proc:
@pytest.fixture
def x64_windows(monkeypatch):
+ from core.inference import wsl_host
+
monkeypatch.setattr(sys, "platform", "win32")
monkeypatch.setattr(platform, "machine", lambda: "AMD64")
+ monkeypatch.setattr(wsl_host, "native_machine", lambda: "x86_64")
monkeypatch.setattr(
sys, "getwindowsversion", lambda: _types.SimpleNamespace(build = 26100), raising = False
)
@@ -78,14 +81,19 @@ def _wait(job, limit = 5.0):
@pytest.mark.parametrize(
"machine, build, expected",
[
- ("AMD64", 26100, None),
+ ("x86_64", 26100, None),
("x86_64", 26200, None),
- ("ARM64", 26100, "arch"),
- ("AMD64", 22631, "build"),
+ ("arm64", 26100, None),
+ ("x86", 26100, "arch"),
+ ("x86_64", 22631, "build"),
],
)
-def test_only_x64_windows_11_24h2_or_newer_can_run_mxc(monkeypatch, machine, build, expected):
- monkeypatch.setattr(platform, "machine", lambda: machine)
+def test_only_x64_or_arm64_windows_11_24h2_or_newer_can_run_mxc(
+ monkeypatch, machine, build, expected
+):
+ from core.inference import wsl_host
+
+ monkeypatch.setattr(wsl_host, "native_machine", lambda: machine)
monkeypatch.setattr(
sys, "getwindowsversion", lambda: _types.SimpleNamespace(build = build), raising = False
)
@@ -113,7 +121,9 @@ def test_no_plan_when_installed_or_unsupported(x64_windows, monkeypatch):
monkeypatch.setattr(plan_mod, "windows_runtime_installed", lambda: True)
assert plan_mod.windows_runtime_plan().action is None
monkeypatch.setattr(plan_mod, "windows_runtime_installed", lambda: False)
- monkeypatch.setattr(platform, "machine", lambda: "ARM64")
+ from core.inference import wsl_host
+
+ monkeypatch.setattr(wsl_host, "native_machine", lambda: "x86")
plan = plan_mod.windows_runtime_plan()
assert plan.action is None and "x64" in plan.reason
@@ -245,7 +255,9 @@ def test_not_on_other_platforms(route, monkeypatch):
def test_an_unavailable_install_is_a_conflict(x64_windows, monkeypatch):
- monkeypatch.setattr(platform, "machine", lambda: "ARM64")
+ from core.inference import wsl_host
+
+ monkeypatch.setattr(wsl_host, "native_machine", lambda: "x86")
with _client(OWNER) as client:
response = client.post("/sandbox/setup", json = {"operation": "windows-runtime"})
assert response.status_code == 409 and "x64" in response.json()["detail"]
diff --git a/studio/backend/tests/test_sandbox_setup_plan.py b/studio/backend/tests/test_sandbox_setup_plan.py
index c29618e7906..c2c53583e80 100644
--- a/studio/backend/tests/test_sandbox_setup_plan.py
+++ b/studio/backend/tests/test_sandbox_setup_plan.py
@@ -370,8 +370,11 @@ def windows(monkeypatch):
from core.inference import mxc_policy, mxc_probe, mxc_runtime
from utils import mxc_isolation_settings
+ from core.inference import wsl_host
+
monkeypatch.setattr(sys, "platform", "win32")
monkeypatch.setattr(platform, "machine", lambda: "AMD64")
+ monkeypatch.setattr(wsl_host, "native_machine", lambda: "x86_64")
state = {
"installed": True,
"missing": ("prepare-null-device",),
@@ -441,11 +444,22 @@ def test_windows_opt_in_locked_off_by_the_environment_is_not_offered(windows):
assert "--prepare-host" in plan.manual_command
-def test_windows_arm64_is_not_offered_a_runtime_it_cannot_run(windows, monkeypatch):
+def test_windows_arm64_is_offered_its_runtime(windows, monkeypatch):
+ from core.inference import wsl_host
+
+ windows["installed"] = False
+ monkeypatch.setattr(wsl_host, "native_machine", lambda: "arm64")
+ assert plan_mod.windows_runtime_unsupported() is None
+ assert plan_mod.windows_runtime_plan().action == plan_mod.WINDOWS_RUNTIME
+
+
+def test_windows_x86_is_not_offered_a_runtime_it_cannot_run(windows, monkeypatch):
+ from core.inference import wsl_host
+
windows["installed"] = False
- monkeypatch.setattr(platform, "machine", lambda: "ARM64")
+ monkeypatch.setattr(wsl_host, "native_machine", lambda: "x86")
plan = plan_mod.detect(False)
- assert plan.action is None and "x64" in plan.reason
+ assert plan.action is None and "ARM64" in plan.reason
assert plan_mod.windows_runtime_plan().action is None
diff --git a/studio/backend/tests/test_wsl_host.py b/studio/backend/tests/test_wsl_host.py
index b3e1ab1283e..ce17cd1d8f4 100644
--- a/studio/backend/tests/test_wsl_host.py
+++ b/studio/backend/tests/test_wsl_host.py
@@ -1059,3 +1059,24 @@ def test_amd_wsl_capacity_follows_the_windows_adapter(monkeypatch):
# No registry record that names this GPU: Windows cannot say.
monkeypatch.setattr(hardware, "_windows_amd_adapter_records_or_none", lambda: None)
assert managed_engine._wsl_amd_usable_mib([0]) is None
+
+
[email protected](sys.platform == "win32", reason = "Windows answers from IsWow64Process2")
+ "environment, machine, expected",
+ [
+ ({"PROCESSOR_ARCHITECTURE": "ARM64"}, "", "arm64"),
+ ({"PROCESSOR_ARCHITEW6432": "AMD64", "PROCESSOR_ARCHITECTURE": "x86"}, "", "x86_64"),
+ ({}, "aarch64", "arm64"),
+ ({}, "x86_64", "x86_64"),
+ ],
+)
+def test_native_machine_fallbacks(monkeypatch, environment, machine, expected):
+ import platform
+
+ for name in ("PROCESSOR_ARCHITEW6432", "PROCESSOR_ARCHITECTURE"):
+ monkeypatch.delenv(name, raising = False)
+ for name, value in environment.items():
+ monkeypatch.setenv(name, value)
+ monkeypatch.setattr(platform, "machine", lambda: machine)
+ assert wsl_host.native_machine() == expected
diff --git a/studio/install_mxc_prebuilt.py b/studio/install_mxc_prebuilt.py
index d0f74c266ba..7dc2607c328 100644
--- a/studio/install_mxc_prebuilt.py
+++ b/studio/install_mxc_prebuilt.py
@@ -46,12 +46,11 @@ def _download(destination: Path) -> None:
def _approved_members() -> dict[str, tuple[str, int]]:
+ exec_member, exec_size, _ = mxc_runtime.artifact("exec")
+ prep_member, prep_size, _ = mxc_runtime.artifact("prep")
return {
- mxc_runtime.RELEASE_MEMBER: ("wxc-exec.exe", mxc_runtime.WXC_EXEC_SIZE),
- mxc_runtime.RELEASE_HOST_PREP_MEMBER: (
- "wxc-host-prep.exe",
- mxc_runtime.WXC_HOST_PREP_SIZE,
- ),
+ exec_member: ("wxc-exec.exe", exec_size),
+ prep_member: ("wxc-host-prep.exe", prep_size),
}
@@ -105,8 +104,7 @@ def install_mxc_release(install_dir: Path) -> bool:
"""Install the approved WXC binary; return ``True`` only when files changed."""
if sys.platform != "win32":
raise MxcInstallError("the MXC runtime installer is Windows-only")
- if mxc_runtime._expected_architecture() != "x86_64":
- raise MxcInstallError("the Microsoft MXC release supports Windows x86-64 only")
+ mxc_runtime._expected_architecture()
install_dir = install_dir.expanduser().resolve()
install_dir.parent.mkdir(parents = True, exist_ok = True)
@@ -265,7 +263,7 @@ def _host_prep_script(executable: Path, arguments: list[str]) -> str:
" try { $digest = [Security.Cryptography.SHA256]::Create().ComputeHash($stream) } "
"finally { $stream.Dispose() }",
" $hash = [BitConverter]::ToString($digest).Replace('-', '')",
- f" if ($hash -ne '{mxc_runtime.WXC_HOST_PREP_SHA256.upper()}') {{ exit 91 }}",
+ f" if ($hash -ne '{mxc_runtime.artifact('prep')[2].upper()}') {{ exit 91 }}",
f" & $exe {' '.join(quote(value) for value in arguments)}",
" exit $LASTEXITCODE",
"} finally {",
diff --git a/studio/setup.ps1 b/studio/setup.ps1
index b19f840efea..e53b5bf3d64 100644
--- a/studio/setup.ps1
+++ b/studio/setup.ps1
@@ -9622,7 +9622,9 @@ Complete-FrontendBuildBackground -IfDone
# corrupt runtime must be installed or repaired even when the venv is current.
if ([System.Environment]::OSVersion.Platform -eq [System.PlatformID]::Win32NT) {
$_mxcInstaller = Join-Path $PSScriptRoot "install_mxc_prebuilt.py"
- $_mxcInstallDir = Join-Path $StudioHome "mxc-runtime\windows-x86_64"
+ # Must match mxc_runtime._installed_package_root(): ARM64 PCs get Microsoft's ARM64 build.
+ $_mxcArchDir = if ((Get-UvHostArch) -eq "arm64") { "windows-arm64" } else { "windows-x86_64" }
+ $_mxcInstallDir = Join-Path $StudioHome "mxc-runtime\$_mxcArchDir"
if (Test-Path -LiteralPath $_mxcInstaller -PathType Leaf) {
substep "installing Windows MXC Preview runtime..."
# Optional, so a nonzero exit or stderr line must reach the fallback below, not stop setup.