From 5b990139cc8d30567d46f197068ab5ac304e4d42 Mon Sep 17 00:00:00 2001 From: Kreijstal Date: Sat, 23 Nov 2024 21:56:18 +0100 Subject: [PATCH] Allowing msys2 to run pyspice --- PySpice/Spice/NgSpice/Shared.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/PySpice/Spice/NgSpice/Shared.py b/PySpice/Spice/NgSpice/Shared.py index 8d805f0a..7ac78f71 100644 --- a/PySpice/Spice/NgSpice/Shared.py +++ b/PySpice/Spice/NgSpice/Shared.py @@ -416,10 +416,22 @@ def setup_platform(cls): cls.LIBRARY_PATH = _ else: if ConfigInstall.OS.on_windows: - ngspice_path = Path(__file__).parent.joinpath('Spice64_dll') - cls.NGSPICE_PATH = ngspice_path - # path = ngspice_path.joinpath('dll-vs', 'ngspice-{version}{id}.dll') - path = ngspice_path.joinpath('dll-vs', 'ngspice{}.dll') + # Check for MSYSTEM environment first + msystem = os.environ.get('MSYSTEM') + mingw_prefix = os.environ.get('MINGW_PREFIX') + + if msystem and mingw_prefix: + # Use MINGW paths + path = str(Path(mingw_prefix) / 'bin' / 'libngspice-0{}.dll') + if 'SPICE_LIB_DIR' not in os.environ: + os.environ['SPICE_LIB_DIR'] = str(Path(mingw_prefix) / 'share' / 'ngspice' / 'scripts') + else: + # Fall back to original Windows paths + ngspice_path = Path(__file__).parent.joinpath('Spice64_dll') + cls.NGSPICE_PATH = ngspice_path + # path = ngspice_path.joinpath('dll-vs', 'ngspice-{version}{id}.dll') + path = str(ngspice_path.joinpath('dll-vs', 'ngspice{}.dll')) + elif ConfigInstall.OS.on_osx: path = 'libngspice{}.dylib' elif ConfigInstall.OS.on_linux: @@ -619,7 +631,8 @@ def _send_char(message_c, ngspice_id, user_data): func = self._logger.info elif content.startswith('Warning:'): func = self._logger.warning - # elif content.startswith('Warning:'): + elif content.startswith('Using'): # Ignore "Using ... as Direct Linear Solver" messages + func = self._logger.debug else: self._error_in_stderr = True func = self._logger.error