From 6613a3e1a99883046a3d219182f594dcf72fe6ce Mon Sep 17 00:00:00 2001 From: Akanksha-020 Date: Mon, 20 Jul 2026 12:07:45 +0530 Subject: [PATCH 1/3] refactor(tool-manager): use centralized path handling and shared utilities --- src/toolManager/gui_fixed.py | 16 ++++++++-------- src/toolManager/main.py | 11 ++++++++--- src/toolManager/tool_manager_windows.py | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/toolManager/gui_fixed.py b/src/toolManager/gui_fixed.py index 1e96f00101..00edd569b3 100644 --- a/src/toolManager/gui_fixed.py +++ b/src/toolManager/gui_fixed.py @@ -16,20 +16,20 @@ import logging PYTHON = sys.executable -SYSTEM = platform.system() -IS_WINDOWS = SYSTEM == "Windows" -IS_LINUX = SYSTEM == "Linux" +from pathlib import Path +from constants import IS_WINDOWS, IS_LINUX +from paths import get_toolmanager_root -import os -BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +BASE_DIR = get_toolmanager_root() if IS_WINDOWS: - BACKEND = os.path.join(BASE_DIR, "tool_manager_windows.py") + BACKEND = BASE_DIR / "tool_manager_windows.py" elif IS_LINUX: - BACKEND = os.path.join(BASE_DIR, "tool_manager_linux.py") + BACKEND = BASE_DIR / "tool_manager_linux.py" else: - BACKEND = os.path.join(os.path.dirname(os.path.abspath(__file__)), "tool_manager_windows.py") + BACKEND = BASE_DIR / "tool_manager_windows.py" +BACKEND = str(BACKEND) TOOLS = { "esim": { "versions": ["latest", "2.4", "2.3", "2.2"], diff --git a/src/toolManager/main.py b/src/toolManager/main.py index e005821de0..3f60284cbf 100644 --- a/src/toolManager/main.py +++ b/src/toolManager/main.py @@ -19,9 +19,14 @@ pass # Will handle gracefully later if missing # ==================== CONFIG ==================== -BASE_DIR = Path(__file__).resolve().parent -INFO_JSON = BASE_DIR / "information.json" -FULL_GUI = BASE_DIR / "gui_fixed.py" +from paths import ( + get_toolmanager_root, + get_install_state_path, +) + +BASE_DIR = get_toolmanager_root() +INFO_JSON = get_install_state_path() +FULL_GUI = BASE_DIR / "gui_fixed.py" PYTHON = sys.executable ANALOG_TOOLS = ["esim", "kicad", "ngspice"] diff --git a/src/toolManager/tool_manager_windows.py b/src/toolManager/tool_manager_windows.py index de268df7a6..f41b2bf8b8 100644 --- a/src/toolManager/tool_manager_windows.py +++ b/src/toolManager/tool_manager_windows.py @@ -25,7 +25,7 @@ WIN_NGSPICE_PATHS, WIN_LLVM_PATHS, get_msys2_bash, get_msys2_mingw_bin, get_msys2_mingw_root ) - +MSYS2_PATH = DEFAULT_MSYS2_PATH if sys.platform == "win32": sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='ignore') sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='ignore') @@ -34,7 +34,7 @@ STATE_FILE = BASE_DIR / "information.json" BASE_DIR.mkdir(parents=True, exist_ok=True) -MSYS2_PATH = DEFAULT_MSYS2_PATH + DOWNLOAD_DIR = BASE_DIR / "Download" DOWNLOAD_DIR.mkdir(parents=True, exist_ok=True) From 3a77a01b80914979e1917b238786a94a2e1d69f7 Mon Sep 17 00:00:00 2001 From: Akanksha-020 Date: Sat, 8 Aug 2026 20:01:11 +0530 Subject: [PATCH 2/3] refactor(tool-manager): centralize tool metadata --- src/toolManager/main.py | 54 +++++++++++++++++----------------- src/toolManager/registry.py | 18 ++++++++++++ src/toolManager/updater_gui.py | 17 ++++++----- 3 files changed, 55 insertions(+), 34 deletions(-) diff --git a/src/toolManager/main.py b/src/toolManager/main.py index 3f60284cbf..b6d6697443 100644 --- a/src/toolManager/main.py +++ b/src/toolManager/main.py @@ -18,6 +18,21 @@ except ImportError: pass # Will handle gracefully later if missing +try: + from registry import ( + get_tool_label, + get_tool_versions, + get_default_version, + get_supported_tools, + ) +except ImportError: + from .registry import ( + get_tool_label, + get_tool_versions, + get_default_version, + get_supported_tools, + ) + # ==================== CONFIG ==================== from paths import ( get_toolmanager_root, @@ -31,24 +46,7 @@ ANALOG_TOOLS = ["esim", "kicad", "ngspice"] DIGITAL_TOOLS = ["esim", "kicad", "ngspice", "ghdl", "verilator", "llvm"] - -TOOL_LABELS = { - "esim": "eSim", - "kicad": "KiCad", - "ngspice": "Ngspice", - "ghdl": "GHDL", - "verilator": "Verilator", - "llvm": "LLVM", -} - -TOOL_VERSIONS = { - "esim": "2.4", - "kicad": "latest", - "ngspice": "latest", - "ghdl": "latest", - "verilator": "latest", - "llvm": "latest", -} +VISIBLE_TOOLS = [tool for tool in get_supported_tools() if tool in DIGITAL_TOOLS] def is_admin(): try: @@ -71,7 +69,7 @@ def relaunch_as_admin(): ) def load_installed_versions(): - versions = {k: "Not installed" for k in TOOL_LABELS} + versions = {k: "Not installed" for k in VISIBLE_TOOLS} try: if INFO_JSON.exists(): with open(INFO_JSON) as f: @@ -105,7 +103,7 @@ def run(self): backend = str(BASE_DIR / "tool_manager_windows.py") for tool, version in self.tools: self.progress.emit( - f"Installing {TOOL_LABELS.get(tool, tool)} {version}..." + f"Installing {get_tool_label(tool)} {version}..." ) try: proc = subprocess.Popen( @@ -224,7 +222,8 @@ def _create_status_panel(self): lbl.setStyleSheet("color: #666; background: transparent;") layout.addWidget(lbl) - for key, label in TOOL_LABELS.items(): + for key in VISIBLE_TOOLS: + label = get_tool_label(key) ver = self.installed_versions.get(key, "Not installed") if ver != "Not installed": text = (f" {label} " @@ -483,7 +482,7 @@ def _create_about_tab(self): title.setStyleSheet("color: #0056b3; margin-bottom: 5px;") layout.addWidget(title) - info_text = """ + info_text = f"""

Key Features:
• Install analog or digital simulation packages
@@ -491,9 +490,10 @@ def _create_about_tab(self): • Uninstall packages selectively and Integrated with eSim GUI

Supported Packages:
- • KiCad: 6.0.11, 7.0.11, 8.0.9
- • Ngspice: 35, 36, 37, 38, 39, 40, 41, 42, 43
- • GHDL: 3.0.0, 4.0.0, 4.1.0, nightly and Verilator: 4.228, 5.020, 5.026, 5.030

+ • KiCad: {", ".join(get_tool_versions("kicad"))}
+ • Ngspice: {", ".join(get_tool_versions("ngspice"))}
+ • GHDL: {", ".join(get_tool_versions("ghdl"))}
+ • Verilator: {", ".join(get_tool_versions("verilator"))}

""" @@ -549,7 +549,7 @@ def _install_analog(self): ) if reply == QMessageBox.StandardButton.Yes: self._run_install( - [(t, TOOL_VERSIONS[t]) for t in ANALOG_TOOLS], + [(t, get_default_version(t)) for t in ANALOG_TOOLS], "Analog Mode" ) @@ -566,7 +566,7 @@ def _install_digital(self): ) if reply == QMessageBox.StandardButton.Yes: self._run_install( - [(t, TOOL_VERSIONS[t]) for t in DIGITAL_TOOLS], + [(t, get_default_version(t)) for t in DIGITAL_TOOLS], "Digital Mode" ) diff --git a/src/toolManager/registry.py b/src/toolManager/registry.py index 3ce9702481..b566fc7fdc 100644 --- a/src/toolManager/registry.py +++ b/src/toolManager/registry.py @@ -110,6 +110,24 @@ def get_supported_tools() -> List[str]: return list(TOOLS.keys()) +def get_tool_label(tool_id: str) -> str: + """Return the display label for a tool.""" + tool = get_tool_metadata(tool_id) + return tool.label if tool else tool_id + + +def get_tool_versions(tool_id: str) -> List[str]: + """Return supported versions for a tool.""" + tool = get_tool_metadata(tool_id) + return tool.versions if tool else [] + + +def get_default_version(tool_id: str) -> str: + """Return the default version for a tool.""" + tool = get_tool_metadata(tool_id) + return tool.default_version if tool else "latest" + + def is_tool_supported(tool_id: str) -> bool: """Checks if a tool is supported by the registry.""" return tool_id in TOOLS diff --git a/src/toolManager/updater_gui.py b/src/toolManager/updater_gui.py index 6bd40e60cd..6ac839d08f 100644 --- a/src/toolManager/updater_gui.py +++ b/src/toolManager/updater_gui.py @@ -12,6 +12,11 @@ from PyQt6.QtCore import Qt, QThread, pyqtSignal from PyQt6.QtGui import QFont +try: + from registry import get_tool_metadata, get_tool_versions +except ImportError: + from .registry import get_tool_metadata, get_tool_versions + class InstallerThread(QThread): progress = pyqtSignal(str, int) log_output = pyqtSignal(str) # NEW: For terminal output @@ -97,13 +102,11 @@ class PackageUpdaterWindow(QMainWindow): def __init__(self): super().__init__() self.installed_versions = {} - - self.available_versions = { - 'KiCad': ['6.0.11', '7.0.11', '8.0.9'], - 'Ngspice': ['35', '36', '37', '38', '39', '40', '41', '42', '43'], # ALL VERSIONS! - 'GHDL': ['3.0.0', '4.0.0', '4.1.0', 'nightly'], - 'Verilator': ['4.228', '5.020', '5.026', '5.030'] - } + self.available_versions = {} + for tool_id in ('kicad', 'ngspice', 'ghdl', 'verilator'): + metadata = get_tool_metadata(tool_id) + if metadata: + self.available_versions[metadata.label] = get_tool_versions(tool_id) self.script_mapping = { 'KiCad': 'update-kicad-final.sh', 'Ngspice': 'nghdl/update-ngspice-final.sh', # Correct path! From 2a0668f8eb6c2293ad5b556f267324ecc40b8ca8 Mon Sep 17 00:00:00 2001 From: Akanksha Shrivastava Date: Sat, 8 Aug 2026 20:22:23 +0530 Subject: [PATCH 3/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/toolManager/main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/toolManager/main.py b/src/toolManager/main.py index b6d6697443..86c079d1c2 100644 --- a/src/toolManager/main.py +++ b/src/toolManager/main.py @@ -34,10 +34,16 @@ ) # ==================== CONFIG ==================== -from paths import ( - get_toolmanager_root, - get_install_state_path, -) +try: + from paths import ( + get_toolmanager_root, + get_install_state_path, + ) +except ImportError: + from .paths import ( + get_toolmanager_root, + get_install_state_path, + ) BASE_DIR = get_toolmanager_root() INFO_JSON = get_install_state_path()