Skip to content

Commit 0cf8542

Browse files
oharboeclaude
andcommitted
generate variables.json from variables.yaml to avoid yaml dependency
generate-variables-docs.py now also outputs variables.json alongside the FlowVariables.md documentation. This allows defaults.py, non_stage_variables.py, and AutoTuner/utils.py to use the built-in json module instead of depending on the external yaml module. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 75efeff commit 0cf8542

5 files changed

Lines changed: 1201 additions & 14 deletions

File tree

‎flow/scripts/defaults.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env python3
22

3+
import json
34
import os
4-
import yaml
55

66
dir_path = os.path.dirname(os.path.realpath(__file__))
77

8-
yaml_path = os.path.join(dir_path, "variables.yaml")
9-
with open(yaml_path, "r") as file:
10-
data = yaml.safe_load(file)
8+
json_path = os.path.join(dir_path, "variables.json")
9+
with open(json_path, "r") as file:
10+
data = json.load(file)
1111

1212
for key, value in data.items():
1313
if value.get("default", None) is None:

‎flow/scripts/generate-variables-docs.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#
55
# This script injects an autogenerated section in FlowVariables.md with
66
# information about the variables from variables.yaml.
7+
# It also outputs variables.json so other scripts can use the built-in json
8+
# module instead of depending on the external yaml module.
9+
import json
710
import os
811
import yaml
912

@@ -14,6 +17,11 @@
1417
with open(yaml_path, "r") as file:
1518
data = yaml.safe_load(file)
1619

20+
json_path = os.path.join(dir_path, "variables.json")
21+
with open(json_path, "w") as file:
22+
json.dump(data, file, indent=2)
23+
file.write("\n")
24+
1725
preferred_order = ["synth", "floorplan", "place", "cts", "grt", "route", "final"]
1826
stages = {stage for value in data.values() for stage in value.get("stages", [])}
1927
# convert set of stages to stages in a list in the preferred order, but

‎flow/scripts/non_stage_variables.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#!/usr/bin/env python3
22
#
33
# Reading .yaml from tcl is tedious and we already have
4-
# a yaml library in Python.
4+
# a json library in Python.
55
#
66
# This script generates a list of variables known
77
# not to be in the current stage.
8+
import json
89
import os
910
import sys
10-
import yaml
1111

1212
dir_path = os.path.dirname(os.path.realpath(__file__))
1313

14-
yaml_path = os.path.join(dir_path, "variables.yaml")
15-
with open(yaml_path, "r") as file:
16-
data = yaml.safe_load(file)
14+
json_path = os.path.join(dir_path, "variables.json")
15+
with open(json_path, "r") as file:
16+
data = json.load(file)
1717

1818
for key, value in data.items():
1919
if "stages" not in value:

0 commit comments

Comments
 (0)