setupEM 0.18.1__tar.gz → 0.18.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. {setupem-0.18.1/src/setupEM.egg-info → setupem-0.18.2}/PKG-INFO +13 -16
  2. {setupem-0.18.1 → setupem-0.18.2}/README_pypi.md +12 -15
  3. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/__init__.py +1 -1
  4. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/config_update.py +18 -2
  5. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/setupEM.py +20 -5
  6. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/setupThermal.py +17 -2
  7. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/setup_common.py +38 -6
  8. {setupem-0.18.1 → setupem-0.18.2/src/setupEM.egg-info}/PKG-INFO +13 -16
  9. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM.egg-info/SOURCES.txt +2 -0
  10. {setupem-0.18.1 → setupem-0.18.2}/tests/test_config_update.py +30 -0
  11. {setupem-0.18.1 → setupem-0.18.2}/tests/test_config_update_gui.py +18 -0
  12. setupem-0.18.2/tests/test_export_no_gui.py +43 -0
  13. setupem-0.18.2/tests/test_return_applies.py +89 -0
  14. {setupem-0.18.1 → setupem-0.18.2}/LICENSE +0 -0
  15. {setupem-0.18.1 → setupem-0.18.2}/README.md +0 -0
  16. {setupem-0.18.1 → setupem-0.18.2}/pyproject.toml +0 -0
  17. {setupem-0.18.1 → setupem-0.18.2}/setup.cfg +0 -0
  18. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/__main__.py +0 -0
  19. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/cli_common.py +0 -0
  20. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/data/SG13CMOS5L_200um.xml +0 -0
  21. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/data/SG13G2_100um.xml +0 -0
  22. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/data/SG13G2_200um.xml +0 -0
  23. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/data/SG13G2_FEM_200um.xml +0 -0
  24. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/data/SG13G2_FEM_200um_passi3D.xml +0 -0
  25. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/data/SG13G2_nosub.xml +0 -0
  26. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/field_viewer.py +0 -0
  27. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/gds_hierarchy_scan.py +0 -0
  28. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/join_pieces.py +0 -0
  29. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/layout_preview.py +0 -0
  30. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/momentum_import.py +0 -0
  31. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/palace_results.py +0 -0
  32. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/piece_set.py +0 -0
  33. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/result_viewer.py +0 -0
  34. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/run_with_overrides.py +0 -0
  35. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/script_model.py +0 -0
  36. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/script_probe.py +0 -0
  37. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/simplify_gds.py +0 -0
  38. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/stackupEditor.py +0 -0
  39. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/stackup_writer.py +0 -0
  40. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM/thermal_results.py +0 -0
  41. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM.egg-info/dependency_links.txt +0 -0
  42. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM.egg-info/entry_points.txt +0 -0
  43. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM.egg-info/requires.txt +0 -0
  44. {setupem-0.18.1 → setupem-0.18.2}/src/setupEM.egg-info/top_level.txt +0 -0
  45. {setupem-0.18.1 → setupem-0.18.2}/tests/test_cli_startup.py +0 -0
  46. {setupem-0.18.1 → setupem-0.18.2}/tests/test_deembedded_view.py +0 -0
  47. {setupem-0.18.1 → setupem-0.18.2}/tests/test_join_pieces.py +0 -0
  48. {setupem-0.18.1 → setupem-0.18.2}/tests/test_margin_per_side.py +0 -0
  49. {setupem-0.18.1 → setupem-0.18.2}/tests/test_piece_set.py +0 -0
  50. {setupem-0.18.1 → setupem-0.18.2}/tests/test_port_walls.py +0 -0
  51. {setupem-0.18.1 → setupem-0.18.2}/tests/test_qt_platform_noise.py +0 -0
  52. {setupem-0.18.1 → setupem-0.18.2}/tests/test_run_with_overrides.py +0 -0
  53. {setupem-0.18.1 → setupem-0.18.2}/tests/test_script_model.py +0 -0
  54. {setupem-0.18.1 → setupem-0.18.2}/tests/test_script_probe.py +0 -0
  55. {setupem-0.18.1 → setupem-0.18.2}/tests/test_table_rows.py +0 -0
  56. {setupem-0.18.1 → setupem-0.18.2}/tests/test_thermal_powers.py +0 -0
  57. {setupem-0.18.1 → setupem-0.18.2}/tests/test_thermal_results.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: setupEM
3
- Version: 0.18.1
3
+ Version: 0.18.2
4
4
  Summary: Python tool for configuration of gds2palace workflow with GUI.
5
5
  Author-email: Volker Muehlhaus <volker@muehlhaus.com>
6
6
  License-Expression: GPL-3.0-or-later
@@ -40,6 +40,18 @@ https://github.com/VolkerMuehlhaus/setupEM
40
40
 
41
41
  ## Recent changes
42
42
 
43
+ # What's New - November 13, 2026 (setupEM 0.18.2)
44
+
45
+ **Ports and thermal objects:** Return in a text field of the form (source layer, Z0, voltage; in setupThermal layer, power, temperature) applies the settings to the selected row, like the Apply button. With no row selected, the status bar says so.
46
+
47
+ **Command line fixes** (from issue #52):
48
+ - A script from File > Export runs without a display: gds2palace 0.10.4 and newer builds the model without the gmsh window on Linux with no display (ssh, container, batch job). Before, the script stopped with "Can't open display". The exported script also has the switch as a comment, `# settings['no_gui'] = True`, for unattended runs where a display exists.
49
+ - `combine_extend_snp.py` (`combine_snp`, in `scripts/`) has `--help` and `--version`, and takes the folder to search as an optional argument. Before, any option was ignored and the conversion ran. Same file as in gds2palace 0.10.4.
50
+
51
+ **Scripts used on two machines** (e.g. Windows and Linux):
52
+ - A model script edited in place whose GDS file was taken from its folder on opening (the script had the other machine's path, e.g. `/mnt/pub/...` for `P:/...`) now gets that path when it is saved or the model is created; the Code tab shows it. Before, the GUI showed the new path and the script kept the old one, and the model was made from the old one.
53
+ - On Linux, a path with a drive letter from Windows (`D:/...`) in a script or settings file is no longer taken as relative to the script's folder (`/mnt/.../D:/...`, "Load a GDSII file and XML stackup first"). A stackup that is not found, also not next to the script, is taken from the stackups that ship with gds2palace if one has that name; the log says so.
54
+
43
55
  # What's New - November 11, 2026 (setupEM 0.18.1)
44
56
 
45
57
  **Command line fixes** (from issue #52, use without a display):
@@ -71,21 +83,6 @@ The dielectric oversize can be set per side (xmin, xmax, ymin, ymax): in setupEM
71
83
 
72
84
  Bundled IHP stackups (from gds2palace 0.10.0): heat source target layers `HEAT_TRANSISTOR` and `HEAT_RESISTOR`, for thermal models. Nothing is drawn on them, so EM models are unchanged.
73
85
 
74
- # What's New - November 5, 2026 (setupEM 0.17.0)
75
-
76
- setupThermal works with the thermal export of the KLayout plug-in klayout_em_export (one heat source per transistor and resistor, with the schematic instance names from LVS in `<layout>_thermalmap.json`):
77
- - **Load powers...** below the Thermal Sources + Boundaries list sets the powers from a file of your circuit simulation, by instance name. Needs gds2palace with `util_thermal_map`.
78
- - The list names the device of each heat source (instance and pcell) and the region outline. Heat source layers above 299 count as present in the layout.
79
- - The export's placeholder boundary (constant temperature on the region outline, no target layer) is listed as "region outline: choose the target layer"; Create Model refuses a boundary without a target layer.
80
- - **Temperature per device**: after a run, the log lists the average and peak temperature of each heat source and their rise above the fixed temperature, and `<model>_temperatures.csv` next to the model script has the same per instance. Command line: `python -m setupEM.thermal_results <model>.tsimcfg`.
81
-
82
- **Changes:**
83
- - **Create Model also writes the settings file**, `<model>.simcfg` / `<model>.tsimcfg` next to the model script (as Save Config would), so that a layout tool's next export keeps your settings and the KLayout plug-in finds the layout's stackup, datatypes and thermal objects. It overwrites only a settings file of the same application. Opening a `.simcfg` that Create Model wrote with a script continues that script without asking.
84
- - The Mesh tab's "Mesh refinement at metal edges" is now **"Mesh size at heat sources"**, which is what it sets in a thermal model (metal edges are not refined there).
85
-
86
- **Fixes:**
87
- - ElmerSolver no longer hangs at start on a Linux desktop where an X display does not accept connections ("Authorization required, but no authorization protocol specified"): setupThermal starts it with hwloc's OpenGL plug-in off (`HWLOC_COMPONENTS=-gl`, unless you set that variable).
88
-
89
86
  Full history: [CHANGES.md](https://github.com/VolkerMuehlhaus/setupEM/blob/main/doc/CHANGES.md)
90
87
 
91
88
  ---
@@ -11,6 +11,18 @@ https://github.com/VolkerMuehlhaus/setupEM
11
11
 
12
12
  ## Recent changes
13
13
 
14
+ # What's New - November 13, 2026 (setupEM 0.18.2)
15
+
16
+ **Ports and thermal objects:** Return in a text field of the form (source layer, Z0, voltage; in setupThermal layer, power, temperature) applies the settings to the selected row, like the Apply button. With no row selected, the status bar says so.
17
+
18
+ **Command line fixes** (from issue #52):
19
+ - A script from File > Export runs without a display: gds2palace 0.10.4 and newer builds the model without the gmsh window on Linux with no display (ssh, container, batch job). Before, the script stopped with "Can't open display". The exported script also has the switch as a comment, `# settings['no_gui'] = True`, for unattended runs where a display exists.
20
+ - `combine_extend_snp.py` (`combine_snp`, in `scripts/`) has `--help` and `--version`, and takes the folder to search as an optional argument. Before, any option was ignored and the conversion ran. Same file as in gds2palace 0.10.4.
21
+
22
+ **Scripts used on two machines** (e.g. Windows and Linux):
23
+ - A model script edited in place whose GDS file was taken from its folder on opening (the script had the other machine's path, e.g. `/mnt/pub/...` for `P:/...`) now gets that path when it is saved or the model is created; the Code tab shows it. Before, the GUI showed the new path and the script kept the old one, and the model was made from the old one.
24
+ - On Linux, a path with a drive letter from Windows (`D:/...`) in a script or settings file is no longer taken as relative to the script's folder (`/mnt/.../D:/...`, "Load a GDSII file and XML stackup first"). A stackup that is not found, also not next to the script, is taken from the stackups that ship with gds2palace if one has that name; the log says so.
25
+
14
26
  # What's New - November 11, 2026 (setupEM 0.18.1)
15
27
 
16
28
  **Command line fixes** (from issue #52, use without a display):
@@ -42,21 +54,6 @@ The dielectric oversize can be set per side (xmin, xmax, ymin, ymax): in setupEM
42
54
 
43
55
  Bundled IHP stackups (from gds2palace 0.10.0): heat source target layers `HEAT_TRANSISTOR` and `HEAT_RESISTOR`, for thermal models. Nothing is drawn on them, so EM models are unchanged.
44
56
 
45
- # What's New - November 5, 2026 (setupEM 0.17.0)
46
-
47
- setupThermal works with the thermal export of the KLayout plug-in klayout_em_export (one heat source per transistor and resistor, with the schematic instance names from LVS in `<layout>_thermalmap.json`):
48
- - **Load powers...** below the Thermal Sources + Boundaries list sets the powers from a file of your circuit simulation, by instance name. Needs gds2palace with `util_thermal_map`.
49
- - The list names the device of each heat source (instance and pcell) and the region outline. Heat source layers above 299 count as present in the layout.
50
- - The export's placeholder boundary (constant temperature on the region outline, no target layer) is listed as "region outline: choose the target layer"; Create Model refuses a boundary without a target layer.
51
- - **Temperature per device**: after a run, the log lists the average and peak temperature of each heat source and their rise above the fixed temperature, and `<model>_temperatures.csv` next to the model script has the same per instance. Command line: `python -m setupEM.thermal_results <model>.tsimcfg`.
52
-
53
- **Changes:**
54
- - **Create Model also writes the settings file**, `<model>.simcfg` / `<model>.tsimcfg` next to the model script (as Save Config would), so that a layout tool's next export keeps your settings and the KLayout plug-in finds the layout's stackup, datatypes and thermal objects. It overwrites only a settings file of the same application. Opening a `.simcfg` that Create Model wrote with a script continues that script without asking.
55
- - The Mesh tab's "Mesh refinement at metal edges" is now **"Mesh size at heat sources"**, which is what it sets in a thermal model (metal edges are not refined there).
56
-
57
- **Fixes:**
58
- - ElmerSolver no longer hangs at start on a Linux desktop where an X display does not accept connections ("Authorization required, but no authorization protocol specified"): setupThermal starts it with hwloc's OpenGL plug-in off (`HWLOC_COMPONENTS=-gl`, unless you set that variable).
59
-
60
57
  Full history: [CHANGES.md](https://github.com/VolkerMuehlhaus/setupEM/blob/main/doc/CHANGES.md)
61
58
 
62
59
  ---
@@ -31,4 +31,4 @@ def main():
31
31
 
32
32
 
33
33
  __all__ = ["main"]
34
- __version__ = "0.18.1"
34
+ __version__ = "0.18.2"
@@ -32,9 +32,25 @@ import glob
32
32
  import json
33
33
  import math
34
34
  import os
35
+ import pathlib
35
36
 
36
37
  __all__ = ["LAYOUT_KEYS", "port_differences", "layout_differences", "newer_configs", "model_scripts",
37
- "same_path", "linked_scripts", "model_settings_snapshot", "settings_differences"]
38
+ "same_path", "linked_scripts", "model_settings_snapshot", "settings_differences", "is_absolute_path",
39
+ "join_path"]
40
+
41
+
42
+ def is_absolute_path(path):
43
+ """True for an absolute path of this or the other OS: a script or settings file written on Windows names
44
+ D:/... or a UNC path, which os.path.isabs() on Linux takes as relative (and a join with the file's folder
45
+ gives /mnt/.../D:/...)."""
46
+ path = str(path)
47
+ return os.path.isabs(path) or bool(pathlib.PureWindowsPath(path).drive) or path.startswith(("/", "\\"))
48
+
49
+
50
+ def join_path(base_dir, path):
51
+ """path taken from base_dir if it is relative (of either OS, see is_absolute_path), else path itself."""
52
+ return path if is_absolute_path(path) else os.path.join(base_dir, path)
53
+
38
54
 
39
55
  # saved_values that belong to the layout export, besides the ports
40
56
  LAYOUT_KEYS = ("GdsFile", "SubstrateFile", "cellname", "purpose")
@@ -92,7 +108,7 @@ def same_path(a, b, base_dir=""):
92
108
  def _same_path(a, b, base_dir=""):
93
109
  if not a or not b:
94
110
  return a == b
95
- norm = lambda p: os.path.normcase(os.path.abspath(os.path.join(base_dir, p)))
111
+ norm = lambda p: os.path.normcase(os.path.abspath(join_path(base_dir, p)))
96
112
  return norm(a) == norm(b)
97
113
 
98
114
 
@@ -62,11 +62,11 @@ if __package__ in (None, ""):
62
62
  eval_simple_python_expression, collect_module_level_constants,
63
63
  find_paraview_exe, FILL_FACTOR_CORRECTION_SOLVERS, PALACE_LINEAR_SOLVER_SETTINGS,
64
64
  GDS2PALACE_CONDUCTOR_MODELS, MODEL_KIND_EM,
65
- protected_script_message, resolve_missing_file_paths,
65
+ protected_script_message, resolve_missing_file_paths, NO_GUI_EXPORT_LINE,
66
66
  )
67
67
  from palace_results import build_results_summary, find_output_dir, find_paraview_files
68
68
  from script_model import ScriptModel
69
- from config_update import LAYOUT_KEYS, layout_differences, port_differences
69
+ from config_update import LAYOUT_KEYS, layout_differences, port_differences, join_path
70
70
  from cli_common import add_version_argument, start_file_errors
71
71
  else:
72
72
  from .setup_common import (
@@ -81,11 +81,11 @@ else:
81
81
  eval_simple_python_expression, collect_module_level_constants,
82
82
  find_paraview_exe, FILL_FACTOR_CORRECTION_SOLVERS, PALACE_LINEAR_SOLVER_SETTINGS,
83
83
  GDS2PALACE_CONDUCTOR_MODELS, MODEL_KIND_EM,
84
- protected_script_message, resolve_missing_file_paths,
84
+ protected_script_message, resolve_missing_file_paths, NO_GUI_EXPORT_LINE,
85
85
  )
86
86
  from .palace_results import build_results_summary, find_output_dir, find_paraview_files
87
87
  from .script_model import ScriptModel
88
- from .config_update import LAYOUT_KEYS, layout_differences, port_differences
88
+ from .config_update import LAYOUT_KEYS, layout_differences, port_differences, join_path
89
89
  from .cli_common import add_version_argument, start_file_errors
90
90
 
91
91
 
@@ -591,6 +591,11 @@ class PortsTab(QWidget):
591
591
  self.buttons_layout.setAlignment(Qt.AlignRight)
592
592
  self.apply_button.setFixedWidth(button_width)
593
593
  self.apply_button.clicked.connect(self.apply_port_values_to_table)
594
+ # Return in a text field of the form applies it, like the button. Not the combo boxes (Return there also
595
+ # confirms an open list), and not on focus loss (a click on another row would write into the old one).
596
+ self.apply_button.setToolTip("Write these settings into the selected row. Return in a text field does the same.")
597
+ for edit in (self.sourcelayer_edit, self.impedance_edit, self.voltage_edit):
598
+ edit.returnPressed.connect(self.apply_from_return)
594
599
 
595
600
  self.remove_button = QPushButton(text="Remove")
596
601
  self.buttons_layout.addWidget(self.remove_button)
@@ -696,6 +701,14 @@ class PortsTab(QWidget):
696
701
  self.portslist.itemSelectionChanged.connect(self.portslist_selection_changed)
697
702
 
698
703
 
704
+ def apply_from_return(self):
705
+ """Return in a text field of the form: apply, or say why nothing happens."""
706
+ if not self.portslist.selectedIndexes():
707
+ self.MainWindow.statusBar().showMessage("Select a row in the table first, then Apply.", 5000)
708
+ return
709
+ self.apply_port_values_to_table()
710
+
711
+
699
712
  # callback when applying changes to the selected port
700
713
  def apply_port_values_to_table(self):
701
714
  selected_indexes = self.portslist.selectedIndexes()
@@ -3589,6 +3602,8 @@ class ModelEditorTab(QWidget):
3589
3602
 
3590
3603
  add_text("\n# ===================== input files and settings =======================")
3591
3604
  add_text("settings={}")
3605
+ if forExport:
3606
+ add_text(NO_GUI_EXPORT_LINE)
3592
3607
 
3593
3608
 
3594
3609
  # List of keys that must be included in Python code AFTER reading stackups and GDSII, not before
@@ -4505,7 +4520,7 @@ class MainWindow(MainWindowBase):
4505
4520
  layout = {key: saved[key] for key in LAYOUT_KEYS if key in saved}
4506
4521
  for key in ("GdsFile", "SubstrateFile"):
4507
4522
  if layout.get(key):
4508
- layout[key] = os.path.join(base_dir, layout[key]).replace("\\", "/")
4523
+ layout[key] = join_path(base_dir, layout[key]).replace("\\", "/")
4509
4524
  resolve_missing_file_paths(layout, base_dir)
4510
4525
  self.saved_values.update(layout)
4511
4526
  self.ports_tab.update_port_from_import(data.get("ports", []))
@@ -60,7 +60,7 @@ if __package__ in (None, ""):
60
60
  MarginSidesDialog, margin_from_saved, margin_to_saved,
61
61
  next_available_source_layer, update_missing_layer_column, ensure_table_rows,
62
62
  get_preference, get_preference_bool, set_preference, clear_preferences,
63
- find_paraview_exe, MODEL_KIND_THERMAL,
63
+ find_paraview_exe, MODEL_KIND_THERMAL, NO_GUI_EXPORT_LINE,
64
64
  protected_script_message,
65
65
  )
66
66
  from thermal_results import build_thermal_summary, format_source_table, find_thermal_paraview_file, \
@@ -75,7 +75,7 @@ else:
75
75
  MarginSidesDialog, margin_from_saved, margin_to_saved,
76
76
  next_available_source_layer, update_missing_layer_column, ensure_table_rows,
77
77
  get_preference, get_preference_bool, set_preference, clear_preferences,
78
- find_paraview_exe, MODEL_KIND_THERMAL,
78
+ find_paraview_exe, MODEL_KIND_THERMAL, NO_GUI_EXPORT_LINE,
79
79
  protected_script_message,
80
80
  )
81
81
  from .thermal_results import build_thermal_summary, format_source_table, find_thermal_paraview_file, \
@@ -256,6 +256,11 @@ class PortsTab(QWidget):
256
256
  self.buttons_layout.setAlignment(Qt.AlignRight)
257
257
  self.apply_button.setFixedWidth(button_width)
258
258
  self.apply_button.clicked.connect(self.apply_port_values_to_table)
259
+ # Return in a text field of the form applies it, like the button. Not the combo boxes (Return there also
260
+ # confirms an open list), and not on focus loss (a click on another row would write into the old one).
261
+ self.apply_button.setToolTip("Write these settings into the selected row. Return in a text field does the same.")
262
+ for edit in (self.sourcelayer_edit, self.power_edit, self.temp_edit):
263
+ edit.returnPressed.connect(self.apply_from_return)
259
264
 
260
265
  self.remove_button = QPushButton(text="Remove")
261
266
  self.buttons_layout.addWidget(self.remove_button)
@@ -301,6 +306,14 @@ class PortsTab(QWidget):
301
306
  self.thermalobjectslist.itemSelectionChanged.connect(self.portslist_selection_changed)
302
307
 
303
308
 
309
+ def apply_from_return(self):
310
+ """Return in a text field of the form: apply, or say why nothing happens."""
311
+ if not self.thermalobjectslist.selectedIndexes():
312
+ self.MainWindow.statusBar().showMessage("Select a row in the table first, then Apply.", 5000)
313
+ return
314
+ self.apply_port_values_to_table()
315
+
316
+
304
317
  # callback when applying changes to the selected port
305
318
  def apply_port_values_to_table(self):
306
319
  selected_indexes = self.thermalobjectslist.selectedIndexes()
@@ -1234,6 +1247,8 @@ class ModelEditorTab(QWidget):
1234
1247
 
1235
1248
  add_text("\n# ===================== input files and settings =======================")
1236
1249
  add_text("settings={}")
1250
+ if forExport:
1251
+ add_text(NO_GUI_EXPORT_LINE)
1237
1252
 
1238
1253
 
1239
1254
  # List of keys that must be included in Python code AFTER reading stackups and GDSII, not before
@@ -64,13 +64,13 @@ if __package__ in (None, ""):
64
64
  from script_model import eval_simple_python_expression, ScriptModel, patch_script, LEGACY_SETTINGS
65
65
  from script_probe import probe_script
66
66
  from config_update import (model_scripts, newer_configs, same_path, linked_scripts, model_settings_snapshot,
67
- settings_differences)
67
+ settings_differences, is_absolute_path)
68
68
  else:
69
69
  from . import gds_hierarchy_scan
70
70
  from .script_model import eval_simple_python_expression, ScriptModel, patch_script, LEGACY_SETTINGS
71
71
  from .script_probe import probe_script
72
72
  from .config_update import (model_scripts, newer_configs, same_path, linked_scripts, model_settings_snapshot,
73
- settings_differences)
73
+ settings_differences, is_absolute_path)
74
74
 
75
75
  # ------------------------------------------------------------------
76
76
  # gds2palace feature-compatibility detection: an older gds2palace (e.g. a stale
@@ -364,14 +364,20 @@ def resolve_missing_file_paths(saved_values, reference_dir, keys=("GdsFile", "Su
364
364
  messages describing each substitution made, for the caller to show the user -
365
365
  silently swapping in a different file (even same-named) without saying so could
366
366
  be confusing if it's actually a stale/different copy.
367
+
368
+ A stackup not found there is looked up among the stackups that ship with gds2palace (the same name): a
369
+ script written on Windows names D:/.../XML_stackup/latest/IHP/<name>, the same file is elsewhere on Linux.
367
370
  """
368
371
  messages = []
369
372
  for key in keys:
370
373
  old_path = saved_values.get(key)
371
374
  if not old_path or os.path.isfile(old_path):
372
375
  continue
373
- candidate = os.path.join(reference_dir, os.path.basename(old_path))
374
- if os.path.isfile(candidate):
376
+ name = os.path.basename(str(old_path).replace('\\', '/'))
377
+ candidate = os.path.join(reference_dir, name)
378
+ if not os.path.isfile(candidate) and key == "SubstrateFile":
379
+ candidate = _bundled_stackup_path(name)
380
+ if candidate and os.path.isfile(candidate):
375
381
  saved_values[key] = candidate.replace('\\', '/')
376
382
  messages.append(
377
383
  f"{key}: {shorten_path_for_display(old_path)} not found, "
@@ -380,6 +386,15 @@ def resolve_missing_file_paths(saved_values, reference_dir, keys=("GdsFile", "Su
380
386
  return messages
381
387
 
382
388
 
389
+ def _bundled_stackup_path(name):
390
+ """Path of the stackup of that name that ships with gds2palace (0.9.1 and later), else None."""
391
+ try:
392
+ path = gds2palace.utilities.get_stackup_path(name)
393
+ except Exception: # noqa: BLE001 - older gds2palace, or no stackup of that name
394
+ return None
395
+ return str(path) if path and os.path.isfile(str(path)) else None
396
+
397
+
383
398
  def collect_module_level_constants(file_path):
384
399
  # Build a symbol table of simple module-level constants (e.g. "Z0 = 50" or
385
400
  # "ftarget = 30e9"), so that references to them elsewhere in the same script (e.g.
@@ -436,6 +451,12 @@ def is_openems_model_script(file_path):
436
451
  return bool(re.search(r'^\s*(?:from|import)\s+(?:openEMS|CSXCAD)\b', text, re.MULTILINE))
437
452
 
438
453
 
454
+ # File > Export: the switch for running the exported script with no gmsh window, commented out (an import
455
+ # reads no settings from comments). gds2palace 0.10.4 and newer turns it on by itself without a display.
456
+ NO_GUI_EXPORT_LINE = ("# settings['no_gui'] = True # no gmsh window, for unattended runs "
457
+ "(on Linux without a display, gds2palace 0.10.4 and newer skips it by itself)")
458
+
459
+
439
460
  # Which kind of model each app handles - MainWindow.MODEL_KIND, and the kind
440
461
  # detect_model_script_kind() reports for a script.
441
462
  MODEL_KIND_EM = "EM"
@@ -5358,7 +5379,7 @@ class MainWindowBase(QMainWindow):
5358
5379
  # a relative path in the script is relative to the script's
5359
5380
  # folder (also "../XML_stackup/..."), not to setupEM's own
5360
5381
  # working directory
5361
- if not os.path.isabs(import_value):
5382
+ if not is_absolute_path(import_value):
5362
5383
  import_value = os.path.normpath(
5363
5384
  os.path.join(modelcode_path, import_value)).replace('\\', '/')
5364
5385
  saved_values[varname] = import_value
@@ -5384,7 +5405,12 @@ class MainWindowBase(QMainWindow):
5384
5405
  # often don't resolve here even as a full absolute path (the bare-relative-
5385
5406
  # path fallback above only fires when there's no directory component at
5386
5407
  # all) - fall back to a same-named file next to this model script instead
5408
+ script_paths = {key: saved_values.get(key) for key in ("GdsFile", "SubstrateFile")}
5387
5409
  path_messages = resolve_missing_file_paths(saved_values, modelcode_path)
5410
+ # the paths swapped here are not what the script says: edited in place, the script gets the
5411
+ # path the GUI shows (see _start_preserve_mode)
5412
+ self._swapped_script_paths = {key: path for key, path in script_paths.items()
5413
+ if path and saved_values.get(key) != path}
5388
5414
  for key, label in (("GdsFile", "GDSII file"), ("SubstrateFile", "Stackup file")):
5389
5415
  path = saved_values.get(key)
5390
5416
  if path and not os.path.isfile(path):
@@ -5557,7 +5583,7 @@ class MainWindowBase(QMainWindow):
5557
5583
  return int(value)
5558
5584
  if key in ("GdsFile", "SubstrateFile"):
5559
5585
  value = str(value)
5560
- if not os.path.isabs(value):
5586
+ if not is_absolute_path(value):
5561
5587
  value = os.path.normpath(os.path.join(modelcode_path, value)).replace('\\', '/')
5562
5588
  return value
5563
5589
  if isinstance(value, tuple):
@@ -6187,6 +6213,12 @@ class MainWindowBase(QMainWindow):
6187
6213
  self.save_all_tabs()
6188
6214
  self.script_model = model
6189
6215
  self.preserve_baseline = self._preserve_snapshot()
6216
+ # a GDS / stackup path of another machine, swapped on import for the same-named file next to the script
6217
+ # (resolve_missing_file_paths): the script still has the old path, so the swap is a change to write,
6218
+ # else the Code tab and Create Model keep a path the GUI doesn't show
6219
+ for key, path in (getattr(self, "_swapped_script_paths", None) or {}).items():
6220
+ self.preserve_baseline["values"][key] = path
6221
+ self._swapped_script_paths = {}
6190
6222
  # Create Model always writes back to this script
6191
6223
  self.create_model_tab.set_output_locked(True)
6192
6224
  self.load_script_runs()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: setupEM
3
- Version: 0.18.1
3
+ Version: 0.18.2
4
4
  Summary: Python tool for configuration of gds2palace workflow with GUI.
5
5
  Author-email: Volker Muehlhaus <volker@muehlhaus.com>
6
6
  License-Expression: GPL-3.0-or-later
@@ -40,6 +40,18 @@ https://github.com/VolkerMuehlhaus/setupEM
40
40
 
41
41
  ## Recent changes
42
42
 
43
+ # What's New - November 13, 2026 (setupEM 0.18.2)
44
+
45
+ **Ports and thermal objects:** Return in a text field of the form (source layer, Z0, voltage; in setupThermal layer, power, temperature) applies the settings to the selected row, like the Apply button. With no row selected, the status bar says so.
46
+
47
+ **Command line fixes** (from issue #52):
48
+ - A script from File > Export runs without a display: gds2palace 0.10.4 and newer builds the model without the gmsh window on Linux with no display (ssh, container, batch job). Before, the script stopped with "Can't open display". The exported script also has the switch as a comment, `# settings['no_gui'] = True`, for unattended runs where a display exists.
49
+ - `combine_extend_snp.py` (`combine_snp`, in `scripts/`) has `--help` and `--version`, and takes the folder to search as an optional argument. Before, any option was ignored and the conversion ran. Same file as in gds2palace 0.10.4.
50
+
51
+ **Scripts used on two machines** (e.g. Windows and Linux):
52
+ - A model script edited in place whose GDS file was taken from its folder on opening (the script had the other machine's path, e.g. `/mnt/pub/...` for `P:/...`) now gets that path when it is saved or the model is created; the Code tab shows it. Before, the GUI showed the new path and the script kept the old one, and the model was made from the old one.
53
+ - On Linux, a path with a drive letter from Windows (`D:/...`) in a script or settings file is no longer taken as relative to the script's folder (`/mnt/.../D:/...`, "Load a GDSII file and XML stackup first"). A stackup that is not found, also not next to the script, is taken from the stackups that ship with gds2palace if one has that name; the log says so.
54
+
43
55
  # What's New - November 11, 2026 (setupEM 0.18.1)
44
56
 
45
57
  **Command line fixes** (from issue #52, use without a display):
@@ -71,21 +83,6 @@ The dielectric oversize can be set per side (xmin, xmax, ymin, ymax): in setupEM
71
83
 
72
84
  Bundled IHP stackups (from gds2palace 0.10.0): heat source target layers `HEAT_TRANSISTOR` and `HEAT_RESISTOR`, for thermal models. Nothing is drawn on them, so EM models are unchanged.
73
85
 
74
- # What's New - November 5, 2026 (setupEM 0.17.0)
75
-
76
- setupThermal works with the thermal export of the KLayout plug-in klayout_em_export (one heat source per transistor and resistor, with the schematic instance names from LVS in `<layout>_thermalmap.json`):
77
- - **Load powers...** below the Thermal Sources + Boundaries list sets the powers from a file of your circuit simulation, by instance name. Needs gds2palace with `util_thermal_map`.
78
- - The list names the device of each heat source (instance and pcell) and the region outline. Heat source layers above 299 count as present in the layout.
79
- - The export's placeholder boundary (constant temperature on the region outline, no target layer) is listed as "region outline: choose the target layer"; Create Model refuses a boundary without a target layer.
80
- - **Temperature per device**: after a run, the log lists the average and peak temperature of each heat source and their rise above the fixed temperature, and `<model>_temperatures.csv` next to the model script has the same per instance. Command line: `python -m setupEM.thermal_results <model>.tsimcfg`.
81
-
82
- **Changes:**
83
- - **Create Model also writes the settings file**, `<model>.simcfg` / `<model>.tsimcfg` next to the model script (as Save Config would), so that a layout tool's next export keeps your settings and the KLayout plug-in finds the layout's stackup, datatypes and thermal objects. It overwrites only a settings file of the same application. Opening a `.simcfg` that Create Model wrote with a script continues that script without asking.
84
- - The Mesh tab's "Mesh refinement at metal edges" is now **"Mesh size at heat sources"**, which is what it sets in a thermal model (metal edges are not refined there).
85
-
86
- **Fixes:**
87
- - ElmerSolver no longer hangs at start on a Linux desktop where an X display does not accept connections ("Authorization required, but no authorization protocol specified"): setupThermal starts it with hwloc's OpenGL plug-in off (`HWLOC_COMPONENTS=-gl`, unless you set that variable).
88
-
89
86
  Full history: [CHANGES.md](https://github.com/VolkerMuehlhaus/setupEM/blob/main/doc/CHANGES.md)
90
87
 
91
88
  ---
@@ -40,11 +40,13 @@ tests/test_cli_startup.py
40
40
  tests/test_config_update.py
41
41
  tests/test_config_update_gui.py
42
42
  tests/test_deembedded_view.py
43
+ tests/test_export_no_gui.py
43
44
  tests/test_join_pieces.py
44
45
  tests/test_margin_per_side.py
45
46
  tests/test_piece_set.py
46
47
  tests/test_port_walls.py
47
48
  tests/test_qt_platform_noise.py
49
+ tests/test_return_applies.py
48
50
  tests/test_run_with_overrides.py
49
51
  tests/test_script_model.py
50
52
  tests/test_script_probe.py
@@ -147,3 +147,33 @@ def test_settings_differences():
147
147
  "['ABC', 'ABC', 'ABC', 'ABC', 'PORTWALL', 'ABC'] in the config",
148
148
  "order: 2 in the script, 3 in the config"]
149
149
 
150
+
151
+
152
+ from setupEM.config_update import is_absolute_path, join_path # noqa: E402
153
+
154
+
155
+ def test_paths_of_the_other_os_are_absolute():
156
+ """A script written on Windows names D:/...: on Linux that must not be joined to the script's folder
157
+ (/mnt/.../D:/github-claude/...)."""
158
+ for path in ("D:/github-claude/x.xml", r"D:\x\y.xml", r"\\server\share\a.gds", "/mnt/pub/a.gds"):
159
+ assert is_absolute_path(path), path
160
+ assert join_path("/somewhere", path) == path
161
+ for path in ("a.gds", "../XML_stackup/x.xml", "sub/a.gds"):
162
+ assert not is_absolute_path(path), path
163
+ assert join_path("base", path) == os.path.join("base", path)
164
+
165
+
166
+ def test_missing_stackup_falls_back_to_the_bundled_one(tmp_path):
167
+ """A stackup path of another machine: the same-named stackup that ships with gds2palace (if there is one)."""
168
+ from setupEM.setup_common import resolve_missing_file_paths
169
+ from gds2palace import utilities
170
+ name = "SG13G2_FEM_200um_passi3D.xml"
171
+ try:
172
+ bundled = str(utilities.get_stackup_path(name))
173
+ except Exception:
174
+ import pytest
175
+ pytest.skip("gds2palace without bundled stackups")
176
+ values = {"SubstrateFile": "D:/elsewhere/" + name, "GdsFile": "D:/elsewhere/missing.gds"}
177
+ messages = resolve_missing_file_paths(values, str(tmp_path))
178
+ assert os.path.normcase(os.path.abspath(values["SubstrateFile"])) == os.path.normcase(os.path.abspath(bundled))
179
+ assert values["GdsFile"] == "D:/elsewhere/missing.gds" and len(messages) == 1
@@ -332,3 +332,21 @@ def test_notice_about_newer_config(win, layout):
332
332
  win.hide_info_bar()
333
333
  win.refresh_config_notice() # the settings now match the config: no notice
334
334
  assert win.info_bar.isHidden()
335
+
336
+
337
+ def test_path_of_another_machine_is_written(win, layout):
338
+ """A script saved on another machine (/mnt/... for P:/...): on opening it the GDS path is swapped for the
339
+ same-named file next to it. The Code tab and Create Model write the path the GUI shows, not the old one
340
+ (it was kept, because the swapped path counted as unchanged)."""
341
+ folder, _ = layout
342
+ script = folder / "chip_em.py"
343
+ gds = str(folder / "chip_em.gds").replace(os.sep, "/")
344
+ text = script.read_text(encoding="utf-8").replace(repr(gds), repr("/mnt/pub/other_machine/chip_em.gds"))
345
+ assert "/mnt/pub/other_machine/chip_em.gds" in text
346
+ script.write_text(text, encoding="utf-8")
347
+ win.edit_py_model(str(script))
348
+ assert win.script_model is not None
349
+ assert win.file_tab.gds_file_edit.text().replace(os.sep, "/") == gds
350
+ code = code_of(win)
351
+ assert "/mnt/pub" not in code
352
+ assert "settings['GdsFile'] = 'chip_em.gds'" in code # next to the script: relative
@@ -0,0 +1,43 @@
1
+ # File > Export writes the no_gui switch as a comment (issue #52): visible in the exported script, but not a
2
+ # setting, so Create Model's own script and an import of the export are unchanged.
3
+ #
4
+ # Run from the repo root: python -m pytest tests
5
+
6
+ import os
7
+ import sys
8
+
9
+ import pytest
10
+
11
+ os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
12
+ HERE = os.path.dirname(os.path.abspath(__file__))
13
+ sys.path.insert(0, os.path.join(HERE, "..", "src"))
14
+
15
+ from PySide6.QtWidgets import QApplication # noqa: E402
16
+
17
+ from setupEM.setup_common import NO_GUI_EXPORT_LINE, parse_assignments # noqa: E402
18
+
19
+
20
+ @pytest.fixture(scope="module")
21
+ def app():
22
+ return QApplication.instance() or QApplication([])
23
+
24
+
25
+ @pytest.mark.parametrize("module_name", ["setupEM", "setupThermal"])
26
+ def test_export_has_no_gui_comment(monkeypatch, app, tmp_path, module_name):
27
+ module = __import__(f"setupEM.{module_name}", fromlist=["MainWindow"])
28
+ monkeypatch.setattr(module, "get_preference", lambda app_name, key, default=None: default)
29
+ window = module.MainWindow()
30
+ try:
31
+ editor = window.modeleditor_tab
32
+ editor.create_model_text(forExport=True)
33
+ exported = editor.model_edit.toPlainText()
34
+ assert NO_GUI_EXPORT_LINE in exported
35
+ script = tmp_path / "model.py"
36
+ script.write_text(exported, encoding="utf-8")
37
+ assert "no_gui" not in parse_assignments(str(script))
38
+
39
+ editor.create_model_text() # Create Model: setupEM runs the script with its own window settings
40
+ assert "no_gui" not in editor.model_edit.toPlainText()
41
+ finally:
42
+ window._script_dirty = False
43
+ window.close()
@@ -0,0 +1,89 @@
1
+ # Return in a text field of the port / thermal object form applies it to the selected row, like the Apply button.
2
+ #
3
+ # Run from the repo root: python -m pytest tests
4
+
5
+ import os
6
+ import sys
7
+
8
+ import pytest
9
+
10
+ os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
11
+ HERE = os.path.dirname(os.path.abspath(__file__))
12
+ sys.path.insert(0, os.path.join(HERE, "..", "src"))
13
+
14
+ from PySide6.QtWidgets import QApplication # noqa: E402
15
+
16
+
17
+ @pytest.fixture(scope="module")
18
+ def app():
19
+ return QApplication.instance() or QApplication([])
20
+
21
+
22
+ def open_window(monkeypatch, module_name):
23
+ module = __import__(f"setupEM.{module_name}", fromlist=["MainWindow"])
24
+ monkeypatch.setattr(module, "get_preference", lambda app_name, key, default=None: default)
25
+ return module.MainWindow()
26
+
27
+
28
+ def close_window(window):
29
+ window._script_dirty = False
30
+ window.close()
31
+
32
+
33
+ def text(table, row, col):
34
+ item = table.item(row, col)
35
+ return None if item is None else item.text()
36
+
37
+
38
+ def test_setupem_port(monkeypatch, app):
39
+ window = open_window(monkeypatch, "setupEM")
40
+ try:
41
+ tab, table = window.ports_tab, window.ports_tab.portslist
42
+ # no row selected: nothing is written, the status bar says why
43
+ table.clearSelection()
44
+ tab.impedance_edit.setText("75")
45
+ tab.impedance_edit.returnPressed.emit()
46
+ assert text(table, 0, 0) is None and "Select a row" in window.statusBar().currentMessage()
47
+
48
+ # an empty row: Return adds the port
49
+ table.selectRow(0)
50
+ tab.sourcelayer_edit.setText("201")
51
+ tab.impedance_edit.setText("75")
52
+ tab.impedance_edit.returnPressed.emit()
53
+ assert (text(table, 0, 0), text(table, 0, 2)) == ("75", "201")
54
+
55
+ # an existing port: Return in another field changes it
56
+ tab.voltage_edit.setText("0")
57
+ tab.voltage_edit.returnPressed.emit()
58
+ assert text(table, 0, 1) == "0" and text(table, 0, 0) == "75"
59
+ tab.sourcelayer_edit.setText("202")
60
+ tab.sourcelayer_edit.returnPressed.emit()
61
+ assert text(table, 0, 2) == "202"
62
+ assert "Return" in tab.apply_button.toolTip()
63
+ finally:
64
+ close_window(window)
65
+
66
+
67
+ def test_setupthermal_object(monkeypatch, app):
68
+ window = open_window(monkeypatch, "setupThermal")
69
+ try:
70
+ tab, table = window.thermal_tab, window.thermal_tab.thermalobjectslist
71
+ table.clearSelection()
72
+ tab.power_edit.setText("0.5")
73
+ tab.power_edit.returnPressed.emit()
74
+ assert text(table, 0, 0) is None and "Select a row" in window.statusBar().currentMessage()
75
+
76
+ table.selectRow(0)
77
+ tab.sourcelayer_edit.setText("401")
78
+ tab.thermaltype_box.setCurrentIndex(tab.thermaltype_box.findText("source") if tab.thermaltype_box.findText("source") >= 0
79
+ else next(i for i in range(tab.thermaltype_box.count())
80
+ if "SOURCE" in tab.thermaltype_box.itemText(i).upper()))
81
+ tab.power_edit.setText("0.5")
82
+ tab.power_edit.returnPressed.emit()
83
+ assert (text(table, 0, 0), text(table, 0, 2), text(table, 0, 3)) == ("401", "source", "0.5")
84
+
85
+ tab.power_edit.setText("0.25")
86
+ tab.power_edit.returnPressed.emit()
87
+ assert text(table, 0, 3) == "0.25"
88
+ finally:
89
+ close_window(window)
File without changes
File without changes
File without changes
File without changes