Skip to content

Commit c43b4d8

Browse files
committed
fix: remove PyYAML runtime dependency from Bazel flow scripts
non_stage_variables.py and defaults.py are called at runtime via exec from Tcl/Make inside the Bazel sandbox, where the system Python does not have PyYAML installed, causing ModuleNotFoundError. Switch these scripts to use json (stdlib) by reading from a checked-in variables.json instead of variables.yaml. A CI check ensures the JSON stays in sync with the YAML source of truth. Signed-off-by: saumya <saumyakr2006@gmail.com>
1 parent a166175 commit c43b4d8

6 files changed

Lines changed: 1420 additions & 12 deletions

File tree

.github/workflows/github-actions-yaml-test.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,25 @@ jobs:
1515
fetch-depth: 1
1616
sparse-checkout: |
1717
flow/scripts/generate-variables-docs.py
18+
flow/scripts/yaml_to_json.py
19+
flow/scripts/variables.yaml
20+
flow/scripts/variables.json
1821
docs/user/FlowVariables.md
1922
yamlfix.toml
23+
- name: Install dependencies
24+
run: |
25+
python3 -m venv venv
26+
venv/bin/pip install --quiet pyyaml yamlfix==1.17.0
2027
- name: Run generate-variables-docs.py
2128
run: |
22-
python3 flow/scripts/generate-variables-docs.py
29+
venv/bin/python3 flow/scripts/generate-variables-docs.py
2330
- name: Check if FlowVariables.md is up to date
2431
run: |
2532
git diff --exit-code docs/user/FlowVariables.md
26-
- name: Install dependencies
33+
- name: Check variables.json is up to date
2734
run: |
28-
python3 -m venv venv
29-
venv/bin/pip install --quiet yamlfix==1.17.0
35+
venv/bin/python3 flow/scripts/yaml_to_json.py
36+
git diff --exit-code flow/scripts/variables.json
3037
- name: Run yamlfix check
3138
run: |
3239
source venv/bin/activate

flow/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ load("@bazel-orfs//:openroad.bzl", "orfs_pdk")
22

33
# files shared between scripts/synth.sh and scripts/flow.sh steps
44
MAKEFILE_SHARED = [
5+
"scripts/*.json",
56
"scripts/*.py",
67
"scripts/*.sh",
78
"scripts/*.yaml",

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/non_stage_variables.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
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)