sdk/python: use standalone codex-app-server runtime

This commit is contained in:
Michael Bolin
2026-04-24 16:19:11 -07:00
parent 9b8a1fbefc
commit 6aa4aed202
14 changed files with 521 additions and 206 deletions

View File

@@ -1,9 +1,9 @@
# Codex CLI Runtime for Python SDK
# Codex App Server Runtime for Python SDK
Platform-specific runtime package consumed by the published `codex-app-server-sdk`.
This package is staged during release so the SDK can pin an exact Codex CLI
This package is staged during release so the SDK can pin an exact Codex app-server
version without checking platform binaries into the repo.
`openai-codex-cli-bin` is intentionally wheel-only. Do not build or publish an
`openai-codex-app-server-bin` is intentionally wheel-only. Do not build or publish an
sdist for this package.

View File

@@ -16,12 +16,14 @@ class RuntimeBuildHook(BuildHookInterface):
del version
if self.target_name == "sdist":
raise RuntimeError(
"openai-codex-cli-bin is wheel-only; build and publish platform wheels only."
"openai-codex-app-server-bin is wheel-only; build and publish platform wheels only."
)
platform_tag = self.config.get("platform-tag") or os.environ.get(
"CODEX_CLI_BIN_PLATFORM_TAG"
"CODEX_APP_SERVER_BIN_PLATFORM_TAG"
)
if not isinstance(platform_tag, str) or not platform_tag:
platform_tag = os.environ.get("CODEX_CLI_BIN_PLATFORM_TAG")
if not isinstance(platform_tag, str) or not platform_tag:
platform_tag = _platform_tag()

View File

@@ -3,9 +3,9 @@ requires = ["hatchling>=1.24.0"]
build-backend = "hatchling.build"
[project]
name = "openai-codex-cli-bin"
name = "openai-codex-app-server-bin"
version = "0.0.0-dev"
description = "Pinned Codex CLI runtime for the Python SDK"
description = "Pinned Codex app-server runtime for the Python SDK"
readme = "README.md"
requires-python = ">=3.10"
license = { text = "Apache-2.0" }
@@ -35,8 +35,8 @@ exclude = [
]
[tool.hatch.build.targets.wheel]
packages = ["src/codex_cli_bin"]
include = ["src/codex_cli_bin/bin/**"]
packages = ["src/codex_app_server_bin", "src/codex_cli_bin"]
include = ["src/codex_app_server_bin/bin/**"]
[tool.hatch.build.targets.wheel.hooks.custom]

View File

@@ -0,0 +1,31 @@
from __future__ import annotations
import os
from pathlib import Path
PACKAGE_NAME = "openai-codex-app-server-bin"
def bundled_app_server_path() -> Path:
package_root = Path(__file__).resolve().parent
for exe in _candidate_binary_names():
path = package_root / "bin" / exe
if path.is_file():
return path
candidate_list = ", ".join(
str(package_root / "bin" / exe) for exe in _candidate_binary_names()
)
raise FileNotFoundError(
f"{PACKAGE_NAME} is installed but missing its packaged app-server binary. "
f"Checked: {candidate_list}"
)
def _candidate_binary_names() -> tuple[str, str]:
if os.name == "nt":
return ("codex-app-server.exe", "codex.exe")
return ("codex-app-server", "codex")
__all__ = ["PACKAGE_NAME", "bundled_app_server_path"]

View File

@@ -1,19 +1,13 @@
from __future__ import annotations
import os
from pathlib import Path
PACKAGE_NAME = "openai-codex-cli-bin"
from codex_app_server_bin import PACKAGE_NAME
from codex_app_server_bin import bundled_app_server_path
def bundled_codex_path() -> Path:
exe = "codex.exe" if os.name == "nt" else "codex"
path = Path(__file__).resolve().parent / "bin" / exe
if not path.is_file():
raise FileNotFoundError(
f"{PACKAGE_NAME} is installed but missing its packaged codex binary at {path}"
)
return path
return bundled_app_server_path()
__all__ = ["PACKAGE_NAME", "bundled_codex_path"]
__all__ = ["PACKAGE_NAME", "bundled_app_server_path", "bundled_codex_path"]

View File

@@ -7,6 +7,6 @@ exclude-newer = "2026-04-16T16:29:01.518541933Z"
exclude-newer-span = "P7D"
[[package]]
name = "openai-codex-cli-bin"
name = "openai-codex-app-server-bin"
version = "0.0.0.dev0"
source = { editable = "." }