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 features |= set(python.include, python.linkpath, python.libs)
25 class has_numpy(try_run):
28 // If defined, enforces linking against PythonXXd.lib, which
29 // is usually not included in Python environments.
32 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
33 #include "numpy/arrayobject.h"
35 #if PY_VERSION_HEX >= 0x03000000
36 void *initialize() { import_array();}
38 void initialize() { import_array();}
53 PyObject * a = PyArray_SimpleNew(1, &dims, NPY_INT);
61 def __init__(self, features=()):
65 inc = python.check_python('import numpy; print(numpy.get_include())')
66 features |= include(inc)
68 # ignore errors, the check will fail during compilation...
70 try_run.__init__(self, 'has_numpy', has_numpy.src, cxx, features,
71 if_=(include(inc), define('HAS_NUMPY')))
73 checks = [cxx_checks.has_cxx11(features, define('HAS_CXX11')),
75 config = report('config', checks)
77 src = module('src', features=config.use)
78 test = module('test', features=config.use)