Skip to content

Commit

Permalink
Merge 960495e into d6e3944
Browse files Browse the repository at this point in the history
  • Loading branch information
mstimberg committed Sep 28, 2021
2 parents d6e3944 + 960495e commit 6c8ae4e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
31 changes: 22 additions & 9 deletions brian2/codegen/cpp_prefs.py
Expand Up @@ -111,6 +111,11 @@
else:
default_buildopts = ['-w']

if sys.platform == 'win32':
prefix_dir = os.path.join(sys.prefix, 'Library')
else:
prefix_dir = sys.prefix

# Preferences
prefs.register_preferences(
'codegen.cpp',
Expand Down Expand Up @@ -154,26 +159,34 @@
'''
),
include_dirs=BrianPreference(
default=[],
default=[os.path.join(prefix_dir, 'include')],
docs='''
Include directories to use. Note that ``$prefix/include`` will be
appended to the end automatically, where ``$prefix`` is Python's
site-specific directory prefix as returned by `sys.prefix`.
Include directories to use.
The default value is ``$prefix/include`` (or ``$prefix/Library/include``
on Windows), where ``$prefix`` is Python's site-specific directory
prefix as returned by `sys.prefix`. This will make compilation use
library files installed into a conda environment.
'''
),
library_dirs=BrianPreference(
default=[],
default=[os.path.join(prefix_dir, 'lib')],
docs='''
List of directories to search for C/C++ libraries at link time.
Note that ``$prefix/lib`` will be appended to the end automatically,
where ``$prefix`` is Python's site-specific directory prefix as returned
by `sys.prefix`.
The default value is ``$prefix/lib`` (or ``$prefix/Library/lib``
on Windows), where ``$prefix`` is Python's site-specific directory
prefix as returned by `sys.prefix`. This will make compilation use
library files installed into a conda environment.
'''
),
runtime_library_dirs=BrianPreference(
default=[],
default=[os.path.join(prefix_dir, 'lib')]
if sys.platform != 'win32' else [],
docs='''
List of directories to search for C/C++ libraries at run time.
The default value is ``$prefix/lib`` (not used on Windows), where
``$prefix`` is Python's site-specific directory prefix as returned by
`sys.prefix`. This will make compilation use library files installed
into a conda environment.
'''
),
libraries=BrianPreference(
Expand Down
14 changes: 4 additions & 10 deletions brian2/codegen/runtime/cython_rt/cython_rt.py
Expand Up @@ -93,19 +93,11 @@ def __init__(self, owner, code, variables, variable_indices,
self.include_dirs = (list(prefs['codegen.cpp.include_dirs']) +
compiler_kwds.get('include_dirs', []))
self.include_dirs = list(prefs['codegen.cpp.include_dirs'])
if sys.platform == 'win32':
self.include_dirs += [os.path.join(sys.prefix, 'Library', 'include')]
else:
self.include_dirs += [os.path.join(sys.prefix, 'include')]

self.library_dirs = (list(prefs['codegen.cpp.library_dirs']) +
compiler_kwds.get('library_dirs', []))
if sys.platform == 'win32':
self.library_dirs += [os.path.join(sys.prefix, 'Library', 'lib')]
else:
self.library_dirs += [os.path.join(sys.prefix, 'lib')]

self.runtime_library_dirs = (list(prefs['codegen.cpp.runtime_library_dirs']),
self.runtime_library_dirs = (list(prefs['codegen.cpp.runtime_library_dirs']) +
compiler_kwds.get('runtime_library_dirs', []))

self.libraries = (list(prefs['codegen.cpp.libraries']) +
Expand All @@ -126,7 +118,8 @@ def main():
extra_compile_args=extra_compile_args,
extra_link_args=prefs['codegen.cpp.extra_link_args'],
include_dirs=prefs['codegen.cpp.include_dirs'],
library_dirs=prefs['codegen.cpp.library_dirs'])
library_dirs=prefs['codegen.cpp.library_dirs'],
runtime_library_dirs=prefs['codegen.cpp.runtime_library_dirs'])
compiled.main()
return True
except Exception as ex:
Expand All @@ -148,6 +141,7 @@ def compile_block(self, block):
extra_link_args=self.extra_link_args,
include_dirs=self.include_dirs,
library_dirs=self.library_dirs,
runtime_library_dirs=self.runtime_library_dirs,
compiler=self.compiler,
owner_name=self.owner.name+'_'+self.template_name,
sources=self.sources
Expand Down
2 changes: 2 additions & 0 deletions brian2/codegen/runtime/cython_rt/extension_manager.py
Expand Up @@ -191,6 +191,8 @@ def _load_module(self, module_path, define_macros, include_dirs, library_dirs,
include_dirs = []
if library_dirs is None:
library_dirs = []
if runtime_library_dirs is None:
runtime_library_dirs = []
if extra_compile_args is None:
extra_compile_args = []
if extra_link_args is None:
Expand Down
10 changes: 0 additions & 10 deletions brian2/devices/cpp_standalone/device.py
Expand Up @@ -205,18 +205,8 @@ def __init__(self):
self.define_macros = []
self.headers = []
self.include_dirs = ['brianlib/randomkit']
if sys.platform == 'win32':
self.include_dirs += [os.path.join(sys.prefix, 'Library', 'include')]
else:
self.include_dirs += [os.path.join(sys.prefix, 'include')]
self.library_dirs = ['brianlib/randomkit']
if sys.platform == 'win32':
self.library_dirs += [os.path.join(sys.prefix, 'Library', 'Lib')]
else:
self.library_dirs += [os.path.join(sys.prefix, 'lib')]
self.runtime_library_dirs = []
if sys.platform.startswith('linux'):
self.runtime_library_dirs += [os.path.join(sys.prefix, 'lib')]
self.run_environment_variables = {}
if sys.platform.startswith('darwin'):
if 'DYLD_LIBRARY_PATH' in os.environ:
Expand Down

0 comments on commit 6c8ae4e

Please sign in to comment.