-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrite_pyspec_dict.patch
More file actions
48 lines (42 loc) · 1.48 KB
/
write_pyspec_dict.patch
File metadata and controls
48 lines (42 loc) · 1.48 KB
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
40
41
42
43
44
45
46
47
48
diff --git a/pysetup/generate_specs.py b/pysetup/generate_specs.py
index bcfe1d519..2222b854e 100644
--- a/pysetup/generate_specs.py
+++ b/pysetup/generate_specs.py
@@ -39,6 +39,8 @@ except ImportError:
print("Run: uv sync --all-extras", file=sys.stderr)
sys.exit(1)
+import json
+
from pysetup.constants import PHASE0
from pysetup.helpers import (
combine_spec_objects,
@@ -52,6 +54,8 @@ from pysetup.md_to_spec import MarkdownToSpec
from pysetup.spec_builders import spec_builders
from pysetup.typing import BuildTarget, SpecObject # type: ignore[attr-defined]
+pyspec = {}
+
def get_spec(
file_name: Path,
@@ -119,6 +123,14 @@ def build_spec(
spec_object = all_specs[0]
for value in all_specs[1:]:
spec_object = combine_spec_objects(spec_object, value)
+
+ if preset_name not in pyspec:
+ pyspec[preset_name] = {}
+ if fork not in pyspec[preset_name]:
+ pyspec[preset_name][fork] = {}
+ for key, value in spec_object._asdict().items():
+ pyspec[preset_name][fork][key] = value.copy()
+
spec_object = finalized_spec_object(spec_object)
class_objects = {**spec_object.ssz_objects, **spec_object.dataclasses}
@@ -248,6 +260,10 @@ def generate_fork_specs(
if verbose:
print(f" Wrote: {init_file}")
+ # Write pyspec dictionary to JSON file
+ with open("pyspec.json", "w") as file:
+ json.dump(pyspec, file)
+
def main() -> int:
"""Main entry point for the spec generation script."""