Skip to content

Commit d76ac16

Browse files
committed
adding path to numpy headers in setup.py
1 parent d27eec9 commit d76ac16

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

benchmark/setup.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ def __str__(self):
2121
import pybind11
2222
return pybind11.get_include(self.user)
2323

24+
class get_numpy_include(object):
25+
"""Helper class to determine the numpy include path
26+
27+
The purpose of this class is to postpone importing numpy
28+
until it is actually installed, so that the ``get_include()``
29+
method can be invoked. """
30+
31+
def __str__(self):
32+
import numpy
33+
return numpy.get_include()
2434

2535
ext_modules = [
2636
Extension(
@@ -30,6 +40,8 @@ def __str__(self):
3040
# Path to pybind11 headers
3141
get_pybind_include(),
3242
get_pybind_include(user=True),
43+
# Path to numpy headers
44+
get_numpy_include(),
3345
os.path.join(sys.prefix, 'include'),
3446
os.path.join(sys.prefix, 'Library', 'include')
3547
],

test/setup.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ def __str__(self):
2121
import pybind11
2222
return pybind11.get_include(self.user)
2323

24+
class get_numpy_include(object):
25+
"""Helper class to determine the numpy include path
26+
27+
The purpose of this class is to postpone importing numpy
28+
until it is actually installed, so that the ``get_include()``
29+
method can be invoked. """
30+
31+
def __str__(self):
32+
import numpy
33+
return numpy.get_include()
2434

2535
ext_modules = [
2636
Extension(
@@ -30,6 +40,8 @@ def __str__(self):
3040
# Path to pybind11 headers
3141
get_pybind_include(),
3242
get_pybind_include(user=True),
43+
# Path to numpy headers
44+
get_numpy_include(),
3345
os.path.join(sys.prefix, 'include'),
3446
os.path.join(sys.prefix, 'Library', 'include')
3547
],

0 commit comments

Comments
 (0)