Page MenuHomec4science

site_init.py
No OneTemporary

File Metadata

Created
Tue, Nov 19, 16:11

site_init.py

from SCons.Script import *
from os.path import *
from subprocess import check_output, STDOUT
import os
def fftw(env):
"""A Tool to search for fftw headers and libraries"""
if env.GetOption('clean'):
return
env.SetDefault(FFTW_VERSION='3')
env.SetDefault(FFTW_LIBRARY_WISH=[])
if 'FFTW_INCLUDE_DIR' in env:
env.AppendUnique(CPPPATH=env['FFTW_INCLUDE_DIR'])
if 'FFTW_LIBRARY_DIR' in env:
env.AppendUnique(LIBPATH=env['FFTW_LIBRARY_DIR'])
version = env['FFTW_VERSION']
if version == "2":
lib_names = {'main': 'fftw'}
inc_names = ['fftw.h']
else:
lib_names = {'main': 'fftw3',
'thread': 'fftw3_threads',
'omp': 'fftw3_omp'}
inc_names = ['fftw3.h']
try:
libs = [lib_names[i] for i in env['FFTW_LIBRARY_WISH']]
except:
raise SCons.Errors.StopError(
'Incompatible wishlist {0} from version {1}'.format(
env['FFTW_LIBRARY_WISH'], env['FFTW_VERSION']))
env.AppendUnique(LIBS=libs)
if version == "2":
env.Append(LIBS='m')
conf = Configure(env)
if not conf.CheckLibWithHeader(libs, inc_names, 'c++'):
raise SCons.Errors.StopError(
'Failed to find libraries {0} or '
'headers {1}.'.format(str(lib_names), str(inc_names)))
env = conf.Finish()
def boost(env):
"""A tool to confugure for boost"""
if env.GetOption('clean'):
return
if 'BOOST_INCLUDE_DIR' in env:
env.AppendUnique(CPPPATH=env['BOOST_INCLUDE_DIR'])
conf = Configure(env)
if not conf.CheckCXXHeader('boost/preprocessor/seq.hpp'):
raise SCons.Errors.StopError(
'Failed to find Boost header')
env = conf.Finish()
def pybind11(env):
"""A tool to configure pybind11"""
if env.GetOption('clean'):
return
# Run code below to get versions from user preference and not scons
versions_script = """
from __future__ import print_function
import distutils.sysconfig as dsys
from numpy.distutils.misc_util import get_numpy_include_dirs as numpy_dirs
print(dsys.get_python_inc())
for d in numpy_dirs():
print(d)"""
includes = check_output([env['py_exec'], "-c", versions_script],
universal_newlines=True).split('\n')
includes += [Dir('#third-party/pybind11/include')]
# Extension of shared library for python
extension = check_output([env['py_exec'] + '-config', "--extension-suffix"],
universal_newlines=True).split('\n')[0]
env['SHLIBSUFFIX'] = extension
env.AppendUnique(CPPPATH=includes)
conf = Configure(env)
if not conf.CheckCXXHeader('pybind11/pybind11.h'):
raise SCons.Errors.StopError(
'Failed to find pybind11 header\n' +
"Run 'git submodule update --init --recursive third-party/pybind11'")
env = conf.Finish()
def gtest(env):
"""A tool to configure GoogleTest"""
if env.GetOption('clean'):
return
conf = Configure(env)
if not conf.CheckCXXHeader('gtest/gtest.h'):
raise SCons.Errors.StopError(
'Failed to find GoogleTest header\n' +
"Run 'git submodule update --init --recursive third-party/googletest'")
env = conf.Finish()
def thrust(env):
"""A tool to confugure for thrust"""
if env.GetOption('clean'):
return
if 'THRUST_INCLUDE_DIR' in env:
env.AppendUnique(CPPPATH=env['THRUST_INCLUDE_DIR'])
conf = Configure(env)
if not conf.CheckCXXHeader('thrust/version.h'):
raise SCons.Errors.StopError(
'Failed to find Thrust library')
env = conf.Finish()

Event Timeline