Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
hnswlib.egg-info/
build/
dist/
tmp/
python_bindings/tests/__pycache__/
*.pyd
hnswlib.cpython*.so
hnswlib.egg-info/
build/
dist/
tmp/
python_bindings/tests/__pycache__/
*.pyd
hnswlib.cpython*.so
var/
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:

install:
- |
pip install -r requirements.txt
python setup.py install
python -m pip install .

script:
- |
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ print("Recall for two batches:", np.mean(labels.reshape(-1) == np.arange(len(dat
You can install from sources:
```bash
apt-get install -y python-setuptools python-pip
pip3 install pybind11 numpy setuptools
python3 setup.py install
python3 -m pip install .
```

or you can install via pip:
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"numpy>=1.10.0",
"pybind11>=2.0",
]

build-backend = "setuptools.build_meta"
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

24 changes: 10 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@
from setuptools.command.build_ext import build_ext
import sys
import setuptools
import pybind11
import numpy as np

__version__ = '0.4.0'


include_dirs = [
pybind11.get_include(),
np.get_include(),
]

# compatibility when run in python_bindings
bindings_dir = 'python_bindings'
if bindings_dir in os.path.basename(os.getcwd()):
source_files = ['./bindings.cpp']
include_dirs = ['../hnswlib/']
include_dirs.extend(['../hnswlib/'])
else:
source_files = ['./python_bindings/bindings.cpp']
include_dirs = ['./hnswlib/']
include_dirs.extend(['./hnswlib/'])


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

# extend include dirs here (don't assume numpy/pybind11 are installed when first run, since
# pip could have installed them as part of executing this script
import pybind11
import numpy as np
for ext in self.extensions:
ext.extra_compile_args.extend(opts)
ext.extra_link_args.extend(self.link_opts.get(ct, []))
ext.include_dirs.extend([
# Path to pybind11 headers
pybind11.get_include(),
pybind11.get_include(True),

# Path to numpy headers
np.get_include()
])

build_ext.build_extensions(self)

Expand Down