mirror of
https://github.com/openai/codex.git
synced 2026-05-24 13:04:29 +00:00
## Why The package builder already fetches `rg` from a checked-in DotSlash manifest. The zsh packaging work needs the same fetch/cache/size-check/SHA-256/extract path for another manifest, but keeping that refactor inside the zsh PR makes the review harder to follow. This PR factors the existing `rg`-specific implementation into a reusable helper with no intended behavior change for `rg` packaging. ## What Changed - Added `scripts/codex_package/dotslash.py` for checked-in DotSlash manifest parsing, archive download, cache reuse, size validation, SHA-256 validation, and member extraction. - Updated `scripts/codex_package/ripgrep.py` to delegate to the shared helper. - Preserved the existing `rg` manifest path, cache key, destination filename, and executable-bit behavior. ## Testing - `python3 -m py_compile scripts/codex_package/dotslash.py scripts/codex_package/ripgrep.py scripts/codex_package/cli.py scripts/codex_package/layout.py scripts/codex_package/zsh.py` - `python3 -m unittest discover scripts/codex_package` --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/24129). * #23768 * #23756 * __->__ #24129
36 lines
930 B
Python
36 lines
930 B
Python
"""Fetch ripgrep from the DotSlash manifest used by the package builder."""
|
|
|
|
from pathlib import Path
|
|
|
|
from .dotslash import fetch_dotslash_executable
|
|
from .targets import REPO_ROOT
|
|
from .targets import TargetSpec
|
|
from .targets import resolve_input_path
|
|
|
|
|
|
RG_MANIFEST = REPO_ROOT / "scripts" / "codex_package" / "rg"
|
|
|
|
|
|
def resolve_rg_bin(spec: TargetSpec, rg_bin: Path | None) -> Path:
|
|
if rg_bin is not None:
|
|
return resolve_input_path(rg_bin, "ripgrep executable", "--rg-bin")
|
|
|
|
return fetch_rg(spec)
|
|
|
|
|
|
def fetch_rg(
|
|
spec: TargetSpec,
|
|
*,
|
|
manifest_path: Path = RG_MANIFEST,
|
|
) -> Path:
|
|
rg_bin = fetch_dotslash_executable(
|
|
spec,
|
|
manifest_path=manifest_path,
|
|
artifact_label="ripgrep",
|
|
cache_key=f"{spec.target}-rg",
|
|
dest_name=spec.rg_name,
|
|
)
|
|
if rg_bin is None:
|
|
raise AssertionError("ripgrep is required for all package targets")
|
|
return rg_bin
|