mirror of
https://github.com/openai/codex.git
synced 2026-05-02 12:21:26 +03:00
python-runtime: prepare openai-codex-cli-bin package
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
# Codex CLI Runtime for Python SDK
|
||||
|
||||
Platform-specific runtime package consumed by the published `codex-app-server-sdk`.
|
||||
Platform-specific runtime package consumed by the published `openai-codex` SDK.
|
||||
|
||||
This package is staged during release so the SDK can pin an exact Codex CLI
|
||||
version without checking platform binaries into the repo.
|
||||
version without checking platform binaries into the repo. The distribution name
|
||||
is `openai-codex-cli-bin`, while the import module remains `codex_cli_bin`.
|
||||
|
||||
`codex-cli-bin` is intentionally wheel-only. Do not build or publish an sdist
|
||||
for this package.
|
||||
`openai-codex-cli-bin` is intentionally wheel-only. Do not build or publish an
|
||||
sdist for this package.
|
||||
|
||||
Expected wheel contents:
|
||||
|
||||
- macOS/Linux: `codex_cli_bin/bin/codex`
|
||||
- Windows: `codex_cli_bin/bin/codex.exe`,
|
||||
`codex_cli_bin/bin/codex-command-runner.exe`, and
|
||||
`codex_cli_bin/bin/codex-windows-sandbox-setup.exe`
|
||||
|
||||
@@ -1,15 +1,34 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
||||
|
||||
PLATFORM_TAG_BY_TARGET = {
|
||||
"aarch64-apple-darwin": "macosx_11_0_arm64",
|
||||
"x86_64-apple-darwin": "macosx_10_12_x86_64",
|
||||
"aarch64-unknown-linux-musl": "musllinux_1_2_aarch64",
|
||||
"x86_64-unknown-linux-musl": "musllinux_1_2_x86_64",
|
||||
"aarch64-pc-windows-msvc": "win_arm64",
|
||||
"x86_64-pc-windows-msvc": "win_amd64",
|
||||
}
|
||||
|
||||
|
||||
class RuntimeBuildHook(BuildHookInterface):
|
||||
def initialize(self, version: str, build_data: dict[str, object]) -> None:
|
||||
del version
|
||||
if self.target_name == "sdist":
|
||||
raise RuntimeError(
|
||||
"codex-cli-bin is wheel-only; build and publish platform wheels only."
|
||||
"openai-codex-cli-bin is wheel-only; build and publish platform wheels only."
|
||||
)
|
||||
|
||||
build_data["pure_python"] = False
|
||||
build_data["infer_tag"] = True
|
||||
target = os.environ.get("CODEX_PYTHON_RUNTIME_TARGET")
|
||||
if target is None:
|
||||
build_data["infer_tag"] = True
|
||||
return
|
||||
|
||||
platform_tag = PLATFORM_TAG_BY_TARGET.get(target)
|
||||
if platform_tag is None:
|
||||
raise RuntimeError(f"Unsupported Codex Python runtime target: {target}")
|
||||
build_data["tag"] = f"py3-none-{platform_tag}"
|
||||
|
||||
@@ -3,7 +3,7 @@ requires = ["hatchling>=1.24.0"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "codex-cli-bin"
|
||||
name = "openai-codex-cli-bin"
|
||||
version = "0.0.0-dev"
|
||||
description = "Pinned Codex CLI runtime for the Python SDK"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -3,12 +3,25 @@ from __future__ import annotations
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
PACKAGE_NAME = "codex-cli-bin"
|
||||
PACKAGE_NAME = "openai-codex-cli-bin"
|
||||
|
||||
|
||||
def bundled_bin_dir() -> Path:
|
||||
return Path(__file__).resolve().parent / "bin"
|
||||
|
||||
|
||||
def bundled_runtime_files() -> tuple[Path, ...]:
|
||||
names = (
|
||||
("codex.exe", "codex-command-runner.exe", "codex-windows-sandbox-setup.exe")
|
||||
if os.name == "nt"
|
||||
else ("codex",)
|
||||
)
|
||||
return tuple(bundled_bin_dir() / name for name in names)
|
||||
|
||||
|
||||
def bundled_codex_path() -> Path:
|
||||
exe = "codex.exe" if os.name == "nt" else "codex"
|
||||
path = Path(__file__).resolve().parent / "bin" / exe
|
||||
path = bundled_bin_dir() / exe
|
||||
if not path.is_file():
|
||||
raise FileNotFoundError(
|
||||
f"{PACKAGE_NAME} is installed but missing its packaged codex binary at {path}"
|
||||
@@ -16,4 +29,9 @@ def bundled_codex_path() -> Path:
|
||||
return path
|
||||
|
||||
|
||||
__all__ = ["PACKAGE_NAME", "bundled_codex_path"]
|
||||
__all__ = [
|
||||
"PACKAGE_NAME",
|
||||
"bundled_bin_dir",
|
||||
"bundled_codex_path",
|
||||
"bundled_runtime_files",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user