Base: codex-main originale (prima del fork aKode)
This commit is contained in:
23
bazel/schema/BUILD.bazel
Normal file
23
bazel/schema/BUILD.bazel
Normal file
@@ -0,0 +1,23 @@
|
||||
load("//bazel/rules:schema_bundle.bzl", "schema_bundle")
|
||||
|
||||
schema_bundle(
|
||||
name = "public-schema-bundle",
|
||||
testonly = True,
|
||||
generator = "//codex-rs/app-server-protocol:schema-generator-on-demand",
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
schema_bundle(
|
||||
name = "app-server",
|
||||
generator = "//codex-rs/app-server-protocol:schema-generator-on-demand",
|
||||
tags = ["manual"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "stable",
|
||||
srcs = [":app-server"],
|
||||
output_group = "stable",
|
||||
tags = ["manual"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
16
bazel/schema/tools/BUILD.bazel
Normal file
16
bazel/schema/tools/BUILD.bazel
Normal file
@@ -0,0 +1,16 @@
|
||||
load("@rules_python//python:defs.bzl", "py_binary")
|
||||
load("@schema_python//:requirements.bzl", "requirement")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
py_binary(
|
||||
name = "python-codegen",
|
||||
srcs = ["python_codegen.py"],
|
||||
main = "python_codegen.py",
|
||||
python_version = "3.12",
|
||||
tags = ["manual"],
|
||||
deps = [
|
||||
requirement("datamodel-code-generator"),
|
||||
requirement("packaging"),
|
||||
],
|
||||
)
|
||||
51
bazel/schema/tools/python_codegen.py
Normal file
51
bazel/schema/tools/python_codegen.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""Generate SDK build outputs in scratch space without formatting."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main() -> None:
|
||||
files = json.loads(Path(sys.argv[1]).read_text())
|
||||
schema = Path(sys.argv[2]).resolve()
|
||||
output = Path(sys.argv[3]).resolve()
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
sdk = Path(temporary) / "sdk/python"
|
||||
for source, relative in files:
|
||||
destination = sdk / relative
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(source, destination)
|
||||
|
||||
environment = {
|
||||
**os.environ,
|
||||
"PYTHONPATH": os.pathsep.join(sys.path),
|
||||
}
|
||||
subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
str(sdk / "scripts/update_sdk_artifacts.py"),
|
||||
"generate-types",
|
||||
"--no-format",
|
||||
"--schema-dir",
|
||||
str(schema),
|
||||
],
|
||||
cwd=sdk,
|
||||
env=environment,
|
||||
check=True,
|
||||
)
|
||||
for relative in (
|
||||
"src/openai_codex/api.py",
|
||||
"src/openai_codex/generated/v2_all.py",
|
||||
"src/openai_codex/generated/notification_registry.py",
|
||||
):
|
||||
destination = output / relative
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copyfile(sdk / relative, destination)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user