diff --git a/codex-cli/scripts/build_npm_package.py b/codex-cli/scripts/build_npm_package.py index c9c77cba05..eda6c26152 100755 --- a/codex-cli/scripts/build_npm_package.py +++ b/codex-cli/scripts/build_npm_package.py @@ -2,7 +2,6 @@ """Stage and optionally package the @openai/codex npm module.""" import argparse -import importlib.util import json import shutil import subprocess @@ -16,18 +15,76 @@ REPO_ROOT = CODEX_CLI_ROOT.parent RESPONSES_API_PROXY_NPM_ROOT = REPO_ROOT / "codex-rs" / "responses-api-proxy" / "npm" CODEX_SDK_ROOT = REPO_ROOT / "sdk" / "typescript" CODEX_NPM_NAME = "@openai/codex" -PACKAGE_METADATA = SCRIPT_DIR / "package_metadata.py" -_SPEC = importlib.util.spec_from_file_location("codex_package_metadata", PACKAGE_METADATA) -if _SPEC is None or _SPEC.loader is None: - raise RuntimeError(f"Unable to load module from {PACKAGE_METADATA}") -_METADATA_MODULE = importlib.util.module_from_spec(_SPEC) -_SPEC.loader.exec_module(_METADATA_MODULE) -CODEX_PLATFORM_PACKAGES = getattr(_METADATA_MODULE, "CODEX_PLATFORM_PACKAGES", {}) -PACKAGE_CHOICES = getattr(_METADATA_MODULE, "PACKAGE_CHOICES", ()) -PACKAGE_EXPANSIONS = getattr(_METADATA_MODULE, "PACKAGE_EXPANSIONS", {}) -PACKAGE_NATIVE_COMPONENTS = getattr(_METADATA_MODULE, "PACKAGE_NATIVE_COMPONENTS", {}) -PACKAGE_TARGET_FILTERS = getattr(_METADATA_MODULE, "PACKAGE_TARGET_FILTERS", {}) +# `npm_name` is the local optional-dependency alias consumed by `bin/codex.js`. +# The underlying package published to npm is always `@openai/codex`. +CODEX_PLATFORM_PACKAGES: dict[str, dict[str, str]] = { + "codex-linux-x64": { + "npm_name": "@openai/codex-linux-x64", + "npm_tag": "linux-x64", + "target_triple": "x86_64-unknown-linux-musl", + "os": "linux", + "cpu": "x64", + }, + "codex-linux-arm64": { + "npm_name": "@openai/codex-linux-arm64", + "npm_tag": "linux-arm64", + "target_triple": "aarch64-unknown-linux-musl", + "os": "linux", + "cpu": "arm64", + }, + "codex-darwin-x64": { + "npm_name": "@openai/codex-darwin-x64", + "npm_tag": "darwin-x64", + "target_triple": "x86_64-apple-darwin", + "os": "darwin", + "cpu": "x64", + }, + "codex-darwin-arm64": { + "npm_name": "@openai/codex-darwin-arm64", + "npm_tag": "darwin-arm64", + "target_triple": "aarch64-apple-darwin", + "os": "darwin", + "cpu": "arm64", + }, + "codex-win32-x64": { + "npm_name": "@openai/codex-win32-x64", + "npm_tag": "win32-x64", + "target_triple": "x86_64-pc-windows-msvc", + "os": "win32", + "cpu": "x64", + }, + "codex-win32-arm64": { + "npm_name": "@openai/codex-win32-arm64", + "npm_tag": "win32-arm64", + "target_triple": "aarch64-pc-windows-msvc", + "os": "win32", + "cpu": "arm64", + }, +} + +PACKAGE_EXPANSIONS: dict[str, list[str]] = { + "codex": ["codex", *CODEX_PLATFORM_PACKAGES], +} + +PACKAGE_NATIVE_COMPONENTS: dict[str, list[str]] = { + "codex": [], + "codex-linux-x64": ["codex", "rg"], + "codex-linux-arm64": ["codex", "rg"], + "codex-darwin-x64": ["codex", "rg"], + "codex-darwin-arm64": ["codex", "rg"], + "codex-win32-x64": ["codex", "rg", "codex-windows-sandbox-setup", "codex-command-runner"], + "codex-win32-arm64": ["codex", "rg", "codex-windows-sandbox-setup", "codex-command-runner"], + "codex-responses-api-proxy": ["codex-responses-api-proxy"], + "codex-sdk": [], +} + +PACKAGE_TARGET_FILTERS: dict[str, str] = { + package_name: package_config["target_triple"] + for package_name, package_config in CODEX_PLATFORM_PACKAGES.items() +} + +PACKAGE_CHOICES = tuple(PACKAGE_NATIVE_COMPONENTS) COMPONENT_DEST_DIR: dict[str, str] = { "codex": "codex", diff --git a/codex-cli/scripts/package_metadata.py b/codex-cli/scripts/package_metadata.py deleted file mode 100644 index 8ac98acfb4..0000000000 --- a/codex-cli/scripts/package_metadata.py +++ /dev/null @@ -1,71 +0,0 @@ -"""Shared package metadata for Codex release packaging scripts.""" - -# `npm_name` is the local optional-dependency alias consumed by `bin/codex.js`. -# The underlying package published to npm is always `@openai/codex`. -CODEX_PLATFORM_PACKAGES: dict[str, dict[str, str]] = { - "codex-linux-x64": { - "npm_name": "@openai/codex-linux-x64", - "npm_tag": "linux-x64", - "target_triple": "x86_64-unknown-linux-musl", - "os": "linux", - "cpu": "x64", - }, - "codex-linux-arm64": { - "npm_name": "@openai/codex-linux-arm64", - "npm_tag": "linux-arm64", - "target_triple": "aarch64-unknown-linux-musl", - "os": "linux", - "cpu": "arm64", - }, - "codex-darwin-x64": { - "npm_name": "@openai/codex-darwin-x64", - "npm_tag": "darwin-x64", - "target_triple": "x86_64-apple-darwin", - "os": "darwin", - "cpu": "x64", - }, - "codex-darwin-arm64": { - "npm_name": "@openai/codex-darwin-arm64", - "npm_tag": "darwin-arm64", - "target_triple": "aarch64-apple-darwin", - "os": "darwin", - "cpu": "arm64", - }, - "codex-win32-x64": { - "npm_name": "@openai/codex-win32-x64", - "npm_tag": "win32-x64", - "target_triple": "x86_64-pc-windows-msvc", - "os": "win32", - "cpu": "x64", - }, - "codex-win32-arm64": { - "npm_name": "@openai/codex-win32-arm64", - "npm_tag": "win32-arm64", - "target_triple": "aarch64-pc-windows-msvc", - "os": "win32", - "cpu": "arm64", - }, -} - -PACKAGE_EXPANSIONS: dict[str, list[str]] = { - "codex": ["codex", *CODEX_PLATFORM_PACKAGES], -} - -PACKAGE_NATIVE_COMPONENTS: dict[str, list[str]] = { - "codex": [], - "codex-linux-x64": ["codex", "rg"], - "codex-linux-arm64": ["codex", "rg"], - "codex-darwin-x64": ["codex", "rg"], - "codex-darwin-arm64": ["codex", "rg"], - "codex-win32-x64": ["codex", "rg", "codex-windows-sandbox-setup", "codex-command-runner"], - "codex-win32-arm64": ["codex", "rg", "codex-windows-sandbox-setup", "codex-command-runner"], - "codex-responses-api-proxy": ["codex-responses-api-proxy"], - "codex-sdk": [], -} - -PACKAGE_TARGET_FILTERS: dict[str, str] = { - package_name: package_config["target_triple"] - for package_name, package_config in CODEX_PLATFORM_PACKAGES.items() -} - -PACKAGE_CHOICES = tuple(PACKAGE_NATIVE_COMPONENTS) diff --git a/scripts/stage_npm_packages.py b/scripts/stage_npm_packages.py index 9109608e63..3f75efc3ab 100755 --- a/scripts/stage_npm_packages.py +++ b/scripts/stage_npm_packages.py @@ -16,13 +16,12 @@ from pathlib import Path REPO_ROOT = Path(__file__).resolve().parent.parent BUILD_SCRIPT = REPO_ROOT / "codex-cli" / "scripts" / "build_npm_package.py" INSTALL_NATIVE_DEPS = REPO_ROOT / "codex-cli" / "scripts" / "install_native_deps.py" -PACKAGE_METADATA = REPO_ROOT / "codex-cli" / "scripts" / "package_metadata.py" WORKFLOW_NAME = ".github/workflows/rust-release.yml" GITHUB_REPO = "openai/codex" -_SPEC = importlib.util.spec_from_file_location("codex_package_metadata", PACKAGE_METADATA) +_SPEC = importlib.util.spec_from_file_location("codex_build_npm_package", BUILD_SCRIPT) if _SPEC is None or _SPEC.loader is None: - raise RuntimeError(f"Unable to load module from {PACKAGE_METADATA}") + raise RuntimeError(f"Unable to load module from {BUILD_SCRIPT}") _BUILD_MODULE = importlib.util.module_from_spec(_SPEC) _SPEC.loader.exec_module(_BUILD_MODULE) PACKAGE_NATIVE_COMPONENTS = getattr(_BUILD_MODULE, "PACKAGE_NATIVE_COMPONENTS", {}) diff --git a/scripts/stage_standalone_installer_archives.py b/scripts/stage_standalone_installer_archives.py index c98a611e22..af5000b94a 100755 --- a/scripts/stage_standalone_installer_archives.py +++ b/scripts/stage_standalone_installer_archives.py @@ -4,7 +4,6 @@ from __future__ import annotations import argparse -import importlib.util import json import os import shutil @@ -16,15 +15,40 @@ from pathlib import Path REPO_ROOT = Path(__file__).resolve().parent.parent INSTALL_NATIVE_DEPS = REPO_ROOT / "codex-cli" / "scripts" / "install_native_deps.py" -PACKAGE_METADATA = REPO_ROOT / "codex-cli" / "scripts" / "package_metadata.py" WORKFLOW_NAME = ".github/workflows/rust-release.yml" -_SPEC = importlib.util.spec_from_file_location("codex_package_metadata", PACKAGE_METADATA) -if _SPEC is None or _SPEC.loader is None: - raise RuntimeError(f"Unable to load module from {PACKAGE_METADATA}") -_BUILD_MODULE = importlib.util.module_from_spec(_SPEC) -_SPEC.loader.exec_module(_BUILD_MODULE) -CODEX_PLATFORM_PACKAGES = getattr(_BUILD_MODULE, "CODEX_PLATFORM_PACKAGES", {}) +CODEX_PLATFORM_PACKAGES: dict[str, dict[str, str]] = { + "codex-linux-x64": { + "npm_tag": "linux-x64", + "target_triple": "x86_64-unknown-linux-musl", + "os": "linux", + }, + "codex-linux-arm64": { + "npm_tag": "linux-arm64", + "target_triple": "aarch64-unknown-linux-musl", + "os": "linux", + }, + "codex-darwin-x64": { + "npm_tag": "darwin-x64", + "target_triple": "x86_64-apple-darwin", + "os": "darwin", + }, + "codex-darwin-arm64": { + "npm_tag": "darwin-arm64", + "target_triple": "aarch64-apple-darwin", + "os": "darwin", + }, + "codex-win32-x64": { + "npm_tag": "win32-x64", + "target_triple": "x86_64-pc-windows-msvc", + "os": "win32", + }, + "codex-win32-arm64": { + "npm_tag": "win32-arm64", + "target_triple": "aarch64-pc-windows-msvc", + "os": "win32", + }, +} STANDALONE_NATIVE_COMPONENTS = ( "codex", "codex-command-runner",