mirror of
https://github.com/openai/codex.git
synced 2026-05-16 09:12:54 +00:00
sdk/python: use standalone codex-app-server runtime
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
31
sdk/python-runtime/src/codex_app_server_bin/__init__.py
Normal file
31
sdk/python-runtime/src/codex_app_server_bin/__init__.py
Normal 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"]
|
||||
@@ -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"]
|
||||
|
||||
2
sdk/python-runtime/uv.lock
generated
2
sdk/python-runtime/uv.lock
generated
@@ -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 = "." }
|
||||
|
||||
Reference in New Issue
Block a user