mirror of
https://github.com/openai/codex.git
synced 2026-09-11 20:36:49 +00:00
## What changed - Add a Bazel module extension that downloads checksum-pinned Linux x86-64 Codex release packages, with the Codex release host and GitHub Releases as sources. - Generate `codex` and `package` filegroups from each package's `codex-package.json` manifest so consumers can address the entrypoint or the complete package contents. - Register repositories for Codex `0.145.0` and `0.149.1` in `MODULE.bazel`. GitOrigin-RevId: a73225bae76cf01a588c7e1b570f3fdd9f6e12ab
77 lines
2.3 KiB
Python
77 lines
2.3 KiB
Python
"""Bazel module extension for pinned Codex release archives."""
|
|
|
|
_CODEX_RELEASE_BUILD_FILE = """\
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
filegroup(
|
|
name = "codex",
|
|
srcs = [{entrypoint}],
|
|
)
|
|
|
|
filegroup(
|
|
name = "package",
|
|
srcs = glob([
|
|
"codex-package.json",
|
|
{binaries},
|
|
{resources},
|
|
{path},
|
|
]),
|
|
)
|
|
"""
|
|
|
|
def _codex_release_repository_impl(repository_ctx):
|
|
asset = "codex-package-x86_64-unknown-linux-musl.tar.gz"
|
|
version = repository_ctx.attr.version
|
|
repository_ctx.download_and_extract(
|
|
url = [
|
|
"https://releases.openai.com/codex/releases/{}/{}".format(version, asset),
|
|
"https://github.com/openai/codex/releases/download/rust-v{}/{}".format(version, asset),
|
|
],
|
|
sha256 = repository_ctx.attr.sha256,
|
|
)
|
|
manifest = json.decode(repository_ctx.read("codex-package.json"))
|
|
entrypoint = manifest["entrypoint"]
|
|
binaries = entrypoint.rpartition("/")[0] + "/**"
|
|
repository_ctx.file(
|
|
"BUILD.bazel",
|
|
_CODEX_RELEASE_BUILD_FILE.format(
|
|
binaries = json.encode(binaries),
|
|
entrypoint = json.encode(entrypoint),
|
|
path = json.encode(manifest["pathDir"] + "/**"),
|
|
resources = json.encode(manifest["resourcesDir"] + "/**"),
|
|
),
|
|
executable = False,
|
|
)
|
|
return repository_ctx.repo_metadata(reproducible = True)
|
|
|
|
_codex_release_repository = repository_rule(
|
|
implementation = _codex_release_repository_impl,
|
|
attrs = {
|
|
"sha256": attr.string(mandatory = True),
|
|
"version": attr.string(mandatory = True),
|
|
},
|
|
)
|
|
|
|
_RELEASE = tag_class(
|
|
attrs = {
|
|
"sha256": attr.string(mandatory = True),
|
|
"version": attr.string(mandatory = True),
|
|
},
|
|
)
|
|
|
|
def _codex_release_archive_impl(module_ctx):
|
|
for module in module_ctx.modules:
|
|
for release in module.tags.release:
|
|
_codex_release_repository(
|
|
name = "codex_release_{}_linux_x86_64".format(release.version),
|
|
sha256 = release.sha256,
|
|
version = release.version,
|
|
)
|
|
|
|
return module_ctx.extension_metadata(reproducible = True)
|
|
|
|
codex_release_archive = module_extension(
|
|
implementation = _codex_release_archive_impl,
|
|
tag_classes = {"release": _RELEASE},
|
|
)
|