File size: 1,005 Bytes
f15fb1d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import os
from pathlib import Path
PACKAGE_NAME = "openai-codex-cli-bin"
PACKAGE_METADATA_FILENAME = "codex-package.json"
def bundled_package_dir() -> Path:
path = Path(__file__).resolve().parent
metadata_path = path / PACKAGE_METADATA_FILENAME
if not metadata_path.is_file():
raise FileNotFoundError(
f"{PACKAGE_NAME} is installed but missing its package metadata at {metadata_path}"
)
return path
def bundled_codex_path() -> Path:
exe = "codex.exe" if os.name == "nt" else "codex"
path = bundled_package_dir() / "bin" / exe
if not path.is_file():
raise FileNotFoundError(
f"{PACKAGE_NAME} is installed but missing its packaged codex binary at {path}"
)
return path
def bundled_path_dir() -> Path | None:
path = bundled_package_dir() / "codex-path"
return path if path.is_dir() else None
__all__ = [
"PACKAGE_NAME",
"bundled_codex_path",
"bundled_package_dir",
"bundled_path_dir",
]
|