cleanup(build): drop helper architecture parsing

This commit is contained in:
Tianyi Cui
2026-07-30 01:07:47 +08:00
parent 758dc73ed9
commit 0e53b7a8aa
10 changed files with 12 additions and 130 deletions
+2 -49
View File
@@ -16,14 +16,6 @@ SCRIPT = ROOT / "scripts" / "build-python-release.py"
build_python_release = SimpleNamespace(**runpy.run_path(str(SCRIPT)))
def helper_header(target: str) -> bytes:
header = bytearray(8)
header[:4] = b"\xcf\xfa\xed\xfe"
cpu_type = 0x01000007 if target == "macos-x64" else 0x0100000C
header[4:8] = cpu_type.to_bytes(4, "little")
return bytes(header)
def test_repository_version_matches_root_package_json() -> None:
expected = json.loads((ROOT / "package.json").read_text())["version"]
@@ -53,7 +45,7 @@ def test_stage_runtime_copies_executable_and_spawn_helper(tmp_path: Path) -> Non
executable.write_bytes(b"runtime")
executable.chmod(0o755)
spawn_helper = Path(f"{executable}-spawn-helper")
spawn_helper.write_bytes(helper_header("macos-arm64"))
spawn_helper.write_bytes(b"helper")
spawn_helper.chmod(0o751)
destination = tmp_path / "staging"
@@ -67,7 +59,7 @@ def test_stage_runtime_copies_executable_and_spawn_helper(tmp_path: Path) -> Non
runtime_dir = destination / "src" / "deepseek_harness_runtime" / "runtime"
assert (runtime_dir / executable.name).read_bytes() == b"runtime"
copied_helper = runtime_dir / spawn_helper.name
assert copied_helper.read_bytes() == helper_header("macos-arm64")
assert copied_helper.read_bytes() == b"helper"
assert copied_helper.stat().st_mode & stat.S_IXUSR
@@ -120,42 +112,3 @@ def test_stage_runtime_copies_linux_executable_without_spawn_helper(
runtime_dir = destination / "src" / "deepseek_harness_runtime" / "runtime"
runtime_files = [path.name for path in runtime_dir.glob("dsh-jsonrpc-agent-pkg-*")]
assert runtime_files == [executable.name]
@pytest.mark.parametrize("target", ["macos-x64", "macos-arm64"])
def test_spawn_helper_binary_target(target: str) -> None:
assert build_python_release.spawn_helper_binary_target(helper_header(target)) == target
def test_stage_runtime_rejects_mismatched_spawn_helper(tmp_path: Path) -> None:
executable = tmp_path / "dsh-jsonrpc-agent-pkg-macos-arm64"
executable.write_bytes(b"runtime")
executable.chmod(0o755)
spawn_helper = Path(f"{executable}-spawn-helper")
spawn_helper.write_bytes(helper_header("macos-x64"))
spawn_helper.chmod(0o755)
with pytest.raises(ValueError, match="expected macos-arm64, found macos-x64"):
build_python_release.stage_runtime(
tmp_path / "staging",
"1.2.3",
executable,
executable.name,
)
def test_stage_runtime_rejects_non_binary_spawn_helper(tmp_path: Path) -> None:
executable = tmp_path / "dsh-jsonrpc-agent-pkg-macos-arm64"
executable.write_bytes(b"runtime")
executable.chmod(0o755)
spawn_helper = Path(f"{executable}-spawn-helper")
spawn_helper.write_bytes(b"helper")
spawn_helper.chmod(0o755)
with pytest.raises(ValueError, match="unsupported format or architecture"):
build_python_release.stage_runtime(
tmp_path / "staging",
"1.2.3",
executable,
executable.name,
)