Skip to content

Commit

Permalink
Take into account GSL installations not in standard path
Browse files Browse the repository at this point in the history
  • Loading branch information
mstimberg committed Sep 8, 2023
1 parent 8b8ce98 commit 9c94be2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions brian2/codegen/runtime/GSLcython_rt/GSLcython_rt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
GNU Scientific Library (GSL)
"""

import os
import subprocess
import sys
from distutils.errors import CompileError

Expand Down Expand Up @@ -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:
Expand Down
14 changes: 13 additions & 1 deletion brian2/stateupdaters/GSL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 9c94be2

Please sign in to comment.