mirror of
https://github.com/openai/codex.git
synced 2026-08-24 13:20:07 +00:00
## Summary - build, strip, sign, and publish `codex-code-mode-host` with the primary Codex release binaries on Linux, macOS, and Windows - place the host beside `codex[.exe]` in canonical package archives, macOS DMGs, and the legacy Linux bundle so the runtime's sibling lookup succeeds - preserve and validate the host through standalone installers and Python runtime wheel staging - add package-builder coverage for source selection and the resulting package layout ## Why The process-owned code-mode client launches `codex-code-mode-host` as a sibling of the running Codex executable. Release artifacts currently build and bundle `codex` without that host, so code mode cannot start from installed packages.
124 lines
4.4 KiB
Python
124 lines
4.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
from pathlib import Path
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
|
|
from codex_package.cargo import build_source_binaries
|
|
from codex_package.cargo import source_binaries_for_target
|
|
from codex_package.targets import PACKAGE_VARIANTS
|
|
from codex_package.targets import TARGET_SPECS
|
|
|
|
|
|
class SourceBinariesForTargetTest(unittest.TestCase):
|
|
def test_macos_package_with_prebuilt_entrypoint_builds_nothing(self) -> None:
|
|
self.assertEqual(
|
|
source_binaries_for_target(
|
|
TARGET_SPECS["aarch64-apple-darwin"],
|
|
PACKAGE_VARIANTS["codex"],
|
|
build_entrypoint=False,
|
|
build_code_mode_host=False,
|
|
build_bwrap=False,
|
|
build_codex_command_runner=False,
|
|
build_codex_windows_sandbox_setup=False,
|
|
),
|
|
[],
|
|
)
|
|
|
|
def test_linux_package_with_prebuilt_entrypoint_and_bwrap_builds_nothing(
|
|
self,
|
|
) -> None:
|
|
self.assertEqual(
|
|
source_binaries_for_target(
|
|
TARGET_SPECS["x86_64-unknown-linux-musl"],
|
|
PACKAGE_VARIANTS["codex"],
|
|
build_entrypoint=False,
|
|
build_code_mode_host=False,
|
|
build_bwrap=False,
|
|
build_codex_command_runner=False,
|
|
build_codex_windows_sandbox_setup=False,
|
|
),
|
|
[],
|
|
)
|
|
|
|
def test_windows_package_with_prebuilt_entrypoint_and_helpers_builds_nothing(
|
|
self,
|
|
) -> None:
|
|
self.assertEqual(
|
|
source_binaries_for_target(
|
|
TARGET_SPECS["x86_64-pc-windows-msvc"],
|
|
PACKAGE_VARIANTS["codex"],
|
|
build_entrypoint=False,
|
|
build_code_mode_host=False,
|
|
build_bwrap=False,
|
|
build_codex_command_runner=False,
|
|
build_codex_windows_sandbox_setup=False,
|
|
),
|
|
[],
|
|
)
|
|
|
|
def test_missing_windows_helpers_are_built(self) -> None:
|
|
self.assertEqual(
|
|
source_binaries_for_target(
|
|
TARGET_SPECS["x86_64-pc-windows-msvc"],
|
|
PACKAGE_VARIANTS["codex"],
|
|
build_entrypoint=False,
|
|
build_code_mode_host=False,
|
|
build_bwrap=False,
|
|
build_codex_command_runner=True,
|
|
build_codex_windows_sandbox_setup=True,
|
|
),
|
|
["codex-command-runner", "codex-windows-sandbox-setup"],
|
|
)
|
|
|
|
def test_missing_code_mode_host_is_built_for_app_server(self) -> None:
|
|
self.assertEqual(
|
|
source_binaries_for_target(
|
|
TARGET_SPECS["aarch64-apple-darwin"],
|
|
PACKAGE_VARIANTS["codex-app-server"],
|
|
build_entrypoint=False,
|
|
build_code_mode_host=True,
|
|
build_bwrap=False,
|
|
build_codex_command_runner=False,
|
|
build_codex_windows_sandbox_setup=False,
|
|
),
|
|
["codex-code-mode-host"],
|
|
)
|
|
|
|
def test_build_uses_prebuilt_windows_helpers_without_running_cargo(self) -> None:
|
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
root = Path(temp_dir)
|
|
entrypoint = touch_file(root / "codex.exe")
|
|
code_mode_host = touch_file(root / "codex-code-mode-host.exe")
|
|
command_runner = touch_file(root / "codex-command-runner.exe")
|
|
sandbox_setup = touch_file(root / "codex-windows-sandbox-setup.exe")
|
|
|
|
outputs = build_source_binaries(
|
|
TARGET_SPECS["x86_64-pc-windows-msvc"],
|
|
PACKAGE_VARIANTS["codex"],
|
|
cargo=str(root / "cargo-that-should-not-run"),
|
|
profile="release",
|
|
entrypoint_bin=entrypoint,
|
|
code_mode_host_bin=code_mode_host,
|
|
bwrap_bin=None,
|
|
codex_command_runner_bin=command_runner,
|
|
codex_windows_sandbox_setup_bin=sandbox_setup,
|
|
)
|
|
|
|
self.assertEqual(outputs.entrypoint_bin, entrypoint)
|
|
self.assertEqual(outputs.code_mode_host_bin, code_mode_host)
|
|
self.assertEqual(outputs.codex_command_runner_bin, command_runner)
|
|
self.assertEqual(outputs.codex_windows_sandbox_setup_bin, sandbox_setup)
|
|
|
|
|
|
def touch_file(path: Path) -> Path:
|
|
path.write_text("", encoding="utf-8")
|
|
return path.resolve()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|