Skip to content

Commit 44f20f0

Browse files
authored
Merge pull request #144 from nmslib/develop
Merge pypi package changes to master
2 parents 15e64f6 + 018cc8d commit 44f20f0

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: python
33
matrix:
44
include:
55
- python: 3.6
6+
- python: 3.7
67
install:
78
- |
89
cd python_bindings
@@ -12,4 +13,4 @@ install:
1213
script:
1314
- |
1415
cd python_bindings
15-
python setup.py test
16+
python setup.py test

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Hnswlib - fast approximate nearest neighbor search
22
Header-only C++ HNSW implementation with python bindings. Paper code for the HNSW 200M SIFT experiment
33

4+
**NEWS:**
5+
6+
**Thanks to Louis Abraham ([@louisabraham](https://github.com/louisabraham)) hnswlib is now can be installed via pip!**
7+
48
Highlights:
59
1) Lightweight, header-only, no dependencies other than C++ 11.
610
2) Interfaces for C++, python and R (https://github.com/jlmelville/rcpphnsw).
@@ -26,7 +30,7 @@ Note that inner product is not an actual metric. An element can be closer to som
2630

2731
For other spaces use the nmslib library https://github.com/nmslib/nmslib.
2832

29-
#### short API description
33+
#### Short API description
3034
* `hnswlib.Index(space, dim)` creates a non-initialized index an HNSW in space `space` with integer dimension `dim`.
3135

3236
Index methods:
@@ -45,7 +49,7 @@ Index methods:
4549
* `resize_index(new_size)` - changes the maximum capacity of the index. Not thread safe with `add_items` and `knn_query`.
4650

4751
* `set_ef(ef)` - sets the query time accuracy/speed trade-off, defined by the `ef` parameter (
48-
[ALGO_PARAMS.md](ALGO_PARAMS.md)).
52+
[ALGO_PARAMS.md](ALGO_PARAMS.md)). Note that the parameter is currently not saved along with the index, so you need to set it manually after loading.
4953

5054
* `knn_query(data, k = 1, num_threads = -1)` make a batch query for `k` closests elements for each element of the
5155
* `data` (shape:`N*dim`). Returns a numpy array of (shape:`N*k`).
@@ -166,13 +170,18 @@ print("Recall for two batches:", np.mean(labels.reshape(-1) == np.arange(len(dat
166170
```
167171

168172
### Bindings installation
173+
174+
You can install from sources:
169175
```bash
170176
apt-get install -y python-setuptools python-pip
171177
pip3 install pybind11 numpy setuptools
172178
cd python_bindings
173179
python3 setup.py install
174180
```
175181

182+
or you can install via pip:
183+
`pip install hnswlib`
184+
176185
### Other implementations
177186
* Non-metric space library (nmslib) - main library(python, C++), supports exotic distances: https://github.com/nmslib/nmslib
178187
* Faiss libary by facebook, uses own HNSW implementation for coarse quantization (python, C++):

python_bindings/MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include hnswlib/*.h

python_bindings/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pypi: dist
2+
twine upload dist/*
3+
4+
dist:
5+
-rm dist/*
6+
python3 setup.py sdist
7+
8+
test:
9+
python3 setup.py test
10+
11+
clean:
12+
rm -rf *.egg-info build dist var first_half.bin tests/__pycache__ hnswlib.cpython-36m-darwin.so
13+
14+
.PHONY: dist

python_bindings/bindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <pybind11/pybind11.h>
33
#include <pybind11/numpy.h>
44
#include <pybind11/stl.h>
5-
#include "../hnswlib/hnswlib.h"
5+
#include "hnswlib/hnswlib.h"
66
#include <thread>
77
#include <atomic>
88

python_bindings/hnswlib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../hnswlib

0 commit comments

Comments
 (0)