]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/python/fabscript
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / python / fabscript
1 # -*- python -*-
2 #
3 # Copyright (c) 2016 Stefan Seefeld
4 # All rights reserved.
5 #
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)
9
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
16
17 features += include('include')
18 features += define('BOOST_ALL_NO_LIB') # disable auto-linking
19 boost_include = options.get_with('boost-include')
20 if 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)
25
26 class has_numpy(try_run):
27
28 src = r"""
29 // If defined, enforces linking against PythonXXd.lib, which
30 // is usually not included in Python environments.
31 #undef _DEBUG
32 #include "Python.h"
33 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
34 #include "numpy/arrayobject.h"
35
36 #if PY_VERSION_HEX >= 0x03000000
37 void *initialize() { import_array();}
38 #else
39 void initialize() { import_array();}
40 #endif
41
42 int main()
43 {
44 int result = 0;
45 Py_Initialize();
46 initialize();
47 if (PyErr_Occurred())
48 {
49 result = 1;
50 }
51 else
52 {
53 npy_intp dims = 2;
54 PyObject * a = PyArray_SimpleNew(1, &dims, NPY_INT);
55 if (!a) result = 1;
56 Py_DECREF(a);
57 }
58 Py_Finalize();
59 return result;
60 }
61 """
62 def __init__(self, features=()):
63
64 inc = ''
65 try:
66 inc = python.check_python('import numpy; print(numpy.get_include())')
67 features |= include(inc)
68 except Exception:
69 # ignore errors, the check will fail during compilation...
70 pass
71 try_run.__init__(self, 'has_numpy', has_numpy.src, cxx, features,
72 if_=(include(inc), define('HAS_NUMPY')))
73
74 checks = [cxx_checks.has_cxx11(features, define('HAS_CXX11')),
75 has_numpy(features)]
76 config = report('config', checks)
77
78 src = module('src', features=config.use)
79 test = module('test', features=config.use)
80 doc = module('doc', features=config.use)
81
82 default = src.default