|
3 | 3 | from setuptools.command.build_ext import build_ext |
4 | 4 | import sys |
5 | 5 | import setuptools |
| 6 | +import pybind11 |
| 7 | +import numpy as np |
6 | 8 |
|
7 | 9 | __version__ = '0.4.0' |
8 | 10 |
|
| 11 | + |
| 12 | +include_dirs = [ |
| 13 | + pybind11.get_include(), |
| 14 | + np.get_include(), |
| 15 | +] |
| 16 | + |
9 | 17 | # compatibility when run in python_bindings |
10 | 18 | bindings_dir = 'python_bindings' |
11 | 19 | if bindings_dir in os.path.basename(os.getcwd()): |
12 | 20 | source_files = ['./bindings.cpp'] |
13 | | - include_dirs = ['../hnswlib/'] |
| 21 | + include_dirs.extend(['../hnswlib/']) |
14 | 22 | else: |
15 | 23 | source_files = ['./python_bindings/bindings.cpp'] |
16 | | - include_dirs = ['./hnswlib/'] |
| 24 | + include_dirs.extend(['./hnswlib/']) |
17 | 25 |
|
18 | 26 |
|
19 | 27 | libraries = [] |
@@ -90,21 +98,9 @@ def build_extensions(self): |
90 | 98 | elif ct == 'msvc': |
91 | 99 | opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version()) |
92 | 100 |
|
93 | | - # extend include dirs here (don't assume numpy/pybind11 are installed when first run, since |
94 | | - # pip could have installed them as part of executing this script |
95 | | - import pybind11 |
96 | | - import numpy as np |
97 | 101 | for ext in self.extensions: |
98 | 102 | ext.extra_compile_args.extend(opts) |
99 | 103 | ext.extra_link_args.extend(self.link_opts.get(ct, [])) |
100 | | - ext.include_dirs.extend([ |
101 | | - # Path to pybind11 headers |
102 | | - pybind11.get_include(), |
103 | | - pybind11.get_include(True), |
104 | | - |
105 | | - # Path to numpy headers |
106 | | - np.get_include() |
107 | | - ]) |
108 | 104 |
|
109 | 105 | build_ext.build_extensions(self) |
110 | 106 |
|
|
0 commit comments