Support resource binaries in Python runtime packages

Allow runtime package staging to include extra executables beside the bundled Codex binary so Windows runtime wheels can carry sandbox helpers.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Ahmed Ibrahim
2026-05-08 20:28:45 +03:00
parent 0a0d09ad21
commit a114208641
2 changed files with 70 additions and 3 deletions

View File

@@ -60,6 +60,10 @@ def staged_runtime_bin_path(root: Path) -> Path:
return root / "src" / "codex_cli_bin" / "bin" / runtime_binary_name()
def staged_runtime_resource_path(root: Path, resource: Path) -> Path:
return root / "src" / "codex_cli_bin" / "bin" / resource.name
def run(cmd: list[str], cwd: Path) -> None:
subprocess.run(cmd, cwd=str(cwd), check=True)
@@ -211,6 +215,7 @@ def stage_python_runtime_package(
codex_version: str,
binary_path: Path,
platform_tag: str | None = None,
resource_binaries: Sequence[Path] = (),
) -> Path:
package_version = normalize_codex_version(codex_version)
_copy_package_tree(python_runtime_root(), staging_dir)
@@ -230,6 +235,13 @@ def stage_python_runtime_package(
out_bin.chmod(
out_bin.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
)
for resource_binary in resource_binaries:
out_resource = staged_runtime_resource_path(staging_dir, resource_binary)
shutil.copy2(resource_binary, out_resource)
if not _is_windows():
out_resource.chmod(
out_resource.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
)
return staging_dir
@@ -632,7 +644,9 @@ class PublicFieldSpec:
class CliOps:
generate_types: Callable[[], None]
stage_python_sdk_package: Callable[[Path, str], Path]
stage_python_runtime_package: Callable[[Path, str, Path, str | None], Path]
stage_python_runtime_package: Callable[
[Path, str, Path, str | None, Sequence[Path]], Path
]
current_sdk_version: Callable[[], str]
@@ -1047,6 +1061,13 @@ def build_parser() -> argparse.ArgumentParser:
"macosx_11_0_arm64 or musllinux_1_1_x86_64."
),
)
stage_runtime_parser.add_argument(
"--resource-binary",
action="append",
default=[],
type=Path,
help="Additional executable to package beside the codex runtime binary.",
)
return parser
@@ -1101,6 +1122,7 @@ def run_command(args: argparse.Namespace, ops: CliOps) -> None:
codex_version,
args.runtime_binary.resolve(),
args.platform_tag,
tuple(path.resolve() for path in args.resource_binary),
)