Skip to content

Commit e94c5dc

Browse files
committed
Simplify include_dirs
1 parent 68b6257 commit e94c5dc

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

.gitignore

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
hnswlib.egg-info/
2-
build/
3-
dist/
4-
tmp/
5-
python_bindings/tests/__pycache__/
6-
*.pyd
7-
hnswlib.cpython*.so
1+
hnswlib.egg-info/
2+
build/
3+
dist/
4+
tmp/
5+
python_bindings/tests/__pycache__/
6+
*.pyd
7+
hnswlib.cpython*.so
8+
var/

setup.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@
33
from setuptools.command.build_ext import build_ext
44
import sys
55
import setuptools
6+
import pybind11
7+
import numpy as np
68

79
__version__ = '0.4.0'
810

11+
12+
include_dirs = [
13+
pybind11.get_include(),
14+
np.get_include(),
15+
]
16+
917
# compatibility when run in python_bindings
1018
bindings_dir = 'python_bindings'
1119
if bindings_dir in os.path.basename(os.getcwd()):
1220
source_files = ['./bindings.cpp']
13-
include_dirs = ['../hnswlib/']
21+
include_dirs.extend(['../hnswlib/'])
1422
else:
1523
source_files = ['./python_bindings/bindings.cpp']
16-
include_dirs = ['./hnswlib/']
24+
include_dirs.extend(['./hnswlib/'])
1725

1826

1927
libraries = []
@@ -90,21 +98,9 @@ def build_extensions(self):
9098
elif ct == 'msvc':
9199
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
92100

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
97101
for ext in self.extensions:
98102
ext.extra_compile_args.extend(opts)
99103
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-
])
108104

109105
build_ext.build_extensions(self)
110106

0 commit comments

Comments
 (0)