diff --git a/brian2/codegen/runtime/GSLcython_rt/GSLcython_rt.py b/brian2/codegen/runtime/GSLcython_rt/GSLcython_rt.py index 288709dc6..bf9752289 100644 --- a/brian2/codegen/runtime/GSLcython_rt/GSLcython_rt.py +++ b/brian2/codegen/runtime/GSLcython_rt/GSLcython_rt.py @@ -3,6 +3,8 @@ GNU Scientific Library (GSL) """ +import os +import subprocess import sys from distutils.errors import CompileError @@ -47,6 +49,15 @@ def compile(self): self.define_macros += [("WIN32", "1"), ("GSL_DLL", "1")] if prefs.GSL.directory is not None: self.include_dirs += [prefs.GSL.directory] + else: + try: + p = subprocess.run( + "gsl-config --prefix", shell=True, capture_output=True, check=True + ) + output = p.stdout.decode("utf-8").strip() + self.include_dirs += [os.path.join(output, "include")] + except subprocess.CalledProcessError: + pass # ignore try: super().compile() except CompileError as err: diff --git a/brian2/stateupdaters/GSL.py b/brian2/stateupdaters/GSL.py index ca3032fea..7b403cc9b 100644 --- a/brian2/stateupdaters/GSL.py +++ b/brian2/stateupdaters/GSL.py @@ -2,7 +2,8 @@ Module containg the StateUpdateMethod for integration using the ODE solver provided in the GNU Scientific Library (GSL) """ - +import os +import subprocess import sys from brian2.utils.logger import get_logger @@ -105,6 +106,17 @@ def get_codeobj_class(self): device.define_macros += [("WIN32", "1"), ("GSL_DLL", "1")] if prefs.GSL.directory is not None: device.include_dirs += [prefs.GSL.directory] + try: + p = subprocess.run( + "gsl-config --prefix", + shell=True, + capture_output=True, + check=True, + ) + output = p.stdout.decode("utf-8").strip() + device.include_dirs += [os.path.join(output, "include")] + except subprocess.CalledProcessError: + pass # ignore return GSLCPPStandaloneCodeObject elif isinstance(device, RuntimeDevice):