|
| 1 | +From 0010e181efa28210dbf7839e6e6131139cc705bd Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?=C3=98yvind=20Harboe?= <oyvind@ascenium.com> |
| 3 | +Date: Mon, 18 May 2026 00:06:14 +0200 |
| 4 | +Subject: [PATCH] render_gds: monkey-patch PDK_CONFIGS instead of |
| 5 | + gdsii_use_custom_config |
| 6 | + |
| 7 | +The addon's gdsii_use_custom_config=True branch in import_gdsii skips |
| 8 | +initialising pdk_info and addon_dir, both of which are still used a |
| 9 | +few lines later to resolve color_path -- so any non-default |
| 10 | +layerstack YAML trips UnboundLocalError inside the addon. |
| 11 | + |
| 12 | +Patch the addon's PDK_CONFIGS dict at runtime instead, pointing the |
| 13 | +selected PDK's config_path entry at our trimmed YAML. The else |
| 14 | +branch then fires normally, pdk_info is set, color_path resolves, |
| 15 | +and Path's absolute-RHS semantic makes addon_dir / Path(abs_path) |
| 16 | +evaluate to the absolute path. |
| 17 | +--- |
| 18 | + tools/blendergds/render_gds.py | 12 ++++++++++-- |
| 19 | + 1 file changed, 10 insertions(+), 2 deletions(-) |
| 20 | + |
| 21 | +diff --git a/tools/blendergds/render_gds.py b/tools/blendergds/render_gds.py |
| 22 | +index cbe116c..b53da1e 100644 |
| 23 | +--- a/tools/blendergds/render_gds.py |
| 24 | ++++ b/tools/blendergds/render_gds.py |
| 25 | +@@ -289,11 +289,19 @@ def main(): |
| 26 | + # in seconds rather than 5-7 minutes + 16 GB RSS. No-op for |
| 27 | + # PDKs without a preset and for designs whose full stack is |
| 28 | + # already small enough. |
| 29 | ++ # We can't go through the addon's `gdsii_use_custom_config = True` |
| 30 | ++ # path: that branch in `import_gdsii` skips initialising |
| 31 | ++ # `pdk_info` and `addon_dir`, both of which are still used |
| 32 | ++ # afterwards to resolve `color_path` -- so a custom YAML trips |
| 33 | ++ # `UnboundLocalError: pdk_info` inside the addon. Instead, |
| 34 | ++ # monkey-patch PDK_CONFIGS[pdk]['config_path'] to point at the |
| 35 | ++ # trimmed YAML (absolute path -- `addon_dir / Path("/abs")` |
| 36 | ++ # evaluates to the absolute path in pathlib, so the else branch |
| 37 | ++ # in the addon picks it up correctly). |
| 38 | + trimmed = _trim_layerstack(addon, addon_root, args.pdk, tmp) |
| 39 | + if trimmed is not None: |
| 40 | + yaml_path, kept_layers, missing = trimmed |
| 41 | +- bpy.context.scene.gdsii_use_custom_config = True |
| 42 | +- bpy.context.scene.gdsii_config_path = str(yaml_path) |
| 43 | ++ addon.PDK_CONFIGS.setdefault(args.pdk, {})["config_path"] = str(yaml_path) |
| 44 | + _log_phase( |
| 45 | + "layerstack-trimmed", |
| 46 | + extra=( |
| 47 | +-- |
| 48 | +2.51.0 |
| 49 | + |
0 commit comments