3 # Copyright (c) 2016 Stefan Seefeld
6 # Distributed under the Boost Software License, Version 1.0.
7 # (See accompanying file LICENSE_1_0.txt or copy at
8 # http://www.boost.org/LICENSE_1_0.txt)
10 from faber.feature import set
11 from faber.types import cxx
12 from faber.tools.compiler import cxxflags, define, include
13 from faber.tools.python import python
14 from faber.config import report, cxx_checks
15 from faber.config.try_run import try_run
17 features += include('include')
18 features += define('BOOST_ALL_NO_LIB') # disable auto-linking
19 boost_include = options.get_with('boost-include')
21 features += include(boost_include)
22 python = python.instance()
23 py_suffix = '{}{}'.format(*python.version.split('.')[:2])
24 features |= set(python.include, python.linkpath, python.libs)
26 class has_numpy(try_run):
29 // If defined, enforces linking against PythonXXd.lib, which
30 // is usually not included in Python environments.
33 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
34 #include "numpy/arrayobject.h"
36 #if PY_VERSION_HEX >= 0x03000000
37 void *initialize() { import_array();}
39 void initialize() { import_array();}
54 PyObject * a = PyArray_SimpleNew(1, &dims, NPY_INT);
62 def __init__(self, features=()):
66 inc = python.check_python('import numpy; print(numpy.get_include())')
67 features |= include(inc)
69 # ignore errors, the check will fail during compilation...
71 try_run.__init__(self, 'has_numpy', has_numpy.src, cxx, features,
72 if_=(include(inc), define('HAS_NUMPY')))
74 checks = [cxx_checks.has_cxx11(features, define('HAS_CXX11')),
76 config = report('config', checks)
78 src = module('src', features=config.use)
79 test = module('test', features=config.use)
80 doc = module('doc', features=config.use)