1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
# vim:syntax=python
from os.path import join as pjoin, basename as pbasename
import sys
from numpy.distutils.misc_util import get_numpy_include_dirs
from numscons import GetNumpyEnvironment
from numscons import CheckF77Clib
env = GetNumpyEnvironment(ARGUMENTS)
env.Tool('f2py')
if sys.platform=='win32':
# define_macros.append(('NOINFINITIES',None))
# define_macros.append(('NONANS',None))
env.AppendUnique(CPPDEFINES = '_USE_MATH_DEFINES')
config = env.NumpyConfigure(custom_tests = {'CheckF77Clib' : CheckF77Clib})
if not config.CheckF77Clib():
raise RuntimeError("Could not get C/F77 runtime information")
config.Finish()
env.AppendUnique(CPPPATH = env["PYEXTCPPPATH"])
env.AppendUnique(CPPPATH = get_numpy_include_dirs())
def build_lib(name, ext, libname = None):
"""ext should be .f or .c"""
if not libname:
libname = name
src = env.Glob(pjoin(name, '*%s' % ext))
assert len(src) > 0
env.DistutilsStaticExtLibrary(libname, source = src)
# C libraries
build_lib('c_misc', '.c', 'sc_c_misc')
build_lib('cephes', '.c', 'sc_cephes')
# F libraries
# XXX: handle no opt flags for mach
build_lib('mach', '.f', 'sc_mach')
build_lib('toms', '.f', 'sc_toms')
build_lib('amos', '.f', 'sc_amos')
build_lib('cdflib', '.f', 'sc_cdf')
build_lib('specfun', '.f', 'sc_specfunlib')
env.AppendUnique(LIBPATH = ['.'])
# Cephes extension
src = ['_cephesmodule.c', 'amos_wrappers.c', 'specfun_wrappers.c', \
'toms_wrappers.c','cdf_wrappers.c','ufunc_extras.c']
env.NumpyPythonExtension('_cephes',
source = src,
LIBS = ['sc_amos', 'sc_toms', 'sc_c_misc', 'sc_cephes', 'sc_mach',\
'sc_cdf', 'sc_specfunlib'])
# Specfun extension
env.Prepend(LIBS = ['sc_specfunlib'])
env.NumpyPythonExtension('specfun', source = 'specfun.pyf',
F2PYOPTIONS = ["--no-wrap-functions"])
|