Skip to content

Commit 6d3b29f

Browse files
authored
Merge pull request #260 from dyashuni/develop
Move setup.py into root folder
2 parents 6449e64 + 6ae02a5 commit 6d3b29f

File tree

13 files changed

+186
-145
lines changed

13 files changed

+186
-145
lines changed

.gitignore

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

.travis.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
11
language: python
22

3-
matrix:
3+
jobs:
44
include:
5-
- python: 3.6
6-
- python: 3.7
5+
- name: Linux Python 3.6
6+
os: linux
7+
python: 3.6
8+
9+
- name: Linux Python 3.7
10+
os: linux
11+
python: 3.7
12+
13+
- name: Windows Python 3.6
14+
os: windows
15+
language: shell # 'language: python' is an error on Travis CI Windows
16+
before_install:
17+
- choco install python --version 3.6.0
18+
- python -m pip install --upgrade pip
19+
- python --version
20+
env: PATH=/c/Python36:/c/Python36/Scripts:$PATH
21+
22+
- name: Windows Python 3.7
23+
os: windows
24+
language: shell # 'language: python' is an error on Travis CI Windows
25+
before_install:
26+
- choco install python --version 3.7.0
27+
- python -m pip install --upgrade pip
28+
- python --version
29+
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH
30+
731
install:
832
- |
9-
cd python_bindings
1033
pip install -r requirements.txt
1134
python setup.py install
1235
1336
script:
1437
- |
15-
cd python_bindings
1638
python setup.py test
File renamed without changes.

python_bindings/Makefile renamed to Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ test:
99
python3 setup.py test
1010

1111
clean:
12-
rm -rf *.egg-info build dist var first_half.bin tests/__pycache__ hnswlib.cpython-36m-darwin.so
12+
rm -rf *.egg-info build dist tmp var tests/__pycache__ hnswlib.cpython*.so
1313

1414
.PHONY: dist

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ You can install from sources:
214214
```bash
215215
apt-get install -y python-setuptools python-pip
216216
pip3 install pybind11 numpy setuptools
217-
cd python_bindings
218217
python3 setup.py install
219218
```
220219

@@ -244,13 +243,15 @@ Contributions are highly welcome!
244243
Please make pull requests against the `develop` branch.
245244

246245
### 200M SIFT test reproduction
247-
To download and extract the bigann dataset:
246+
To download and extract the bigann dataset (from root directory):
248247
```bash
249248
python3 download_bigann.py
250249
```
251250
To compile:
252251
```bash
253-
cmake .
252+
mkdir build
253+
cd build
254+
cmake ..
254255
make all
255256
```
256257

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.h"
66
#include <thread>
77
#include <atomic>
88
#include <stdlib.h>

python_bindings/hnswlib

Lines changed: 0 additions & 1 deletion
This file was deleted.

python_bindings/setup.py

Lines changed: 0 additions & 117 deletions
This file was deleted.

python_bindings/setup.py

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

python_bindings/tests/bindings_test.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import unittest
23

34

@@ -43,16 +44,16 @@ def testRandomSelf(self):
4344
self.assertAlmostEqual(np.mean(labels.reshape(-1) == np.arange(len(data1))),1.0,3)
4445

4546
# Serializing and deleting the index:
46-
index_path='first_half.bin'
47+
index_path = 'first_half.bin'
4748
print("Saving index to '%s'" % index_path)
48-
p.save_index("first_half.bin")
49+
p.save_index(index_path)
4950
del p
5051

5152
# Reiniting, loading the index
5253
p = hnswlib.Index(space='l2', dim=dim) # you can change the sa
5354

54-
print("\nLoading index from 'first_half.bin'\n")
55-
p.load_index("first_half.bin")
55+
print("\nLoading index from '%s'\n" % index_path)
56+
p.load_index(index_path)
5657

5758
print("Adding the second batch of %d elements" % (len(data2)))
5859
p.add_items(data2)
@@ -61,6 +62,8 @@ def testRandomSelf(self):
6162
labels, distances = p.knn_query(data, k=1)
6263

6364
self.assertAlmostEqual(np.mean(labels.reshape(-1) == np.arange(len(data))),1.0,3)
65+
66+
os.remove(index_path)
6467

6568

6669
if __name__ == "__main__":

python_bindings/tests/bindings_test_labels.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import unittest
23

34

@@ -56,9 +57,9 @@ def testRandomSelf(self):
5657
# Serializing and deleting the index.
5758
# We need the part to check that serialization is working properly.
5859

59-
index_path='first_half.bin'
60+
index_path = 'first_half.bin'
6061
print("Saving index to '%s'" % index_path)
61-
p.save_index("first_half.bin")
62+
p.save_index(index_path)
6263
print("Saved. Deleting...")
6364
del p
6465
print("Deleted")
@@ -68,8 +69,8 @@ def testRandomSelf(self):
6869
print("Reiniting")
6970
p = hnswlib.Index(space='l2', dim=dim)
7071

71-
print("\nLoading index from 'first_half.bin'\n")
72-
p.load_index("first_half.bin")
72+
print("\nLoading index from '%s'\n" % index_path)
73+
p.load_index(index_path)
7374
p.set_ef(100)
7475

7576
print("Adding the second batch of %d elements" % (len(data2)))
@@ -109,16 +110,20 @@ def testRandomSelf(self):
109110
print("All the data in data1 are removed")
110111

111112
# checking saving/loading index with elements marked as deleted
112-
p.save_index("with_deleted.bin")
113+
del_index_path = "with_deleted.bin"
114+
p.save_index(del_index_path)
113115
p = hnswlib.Index(space='l2', dim=dim)
114-
p.load_index("with_deleted.bin")
116+
p.load_index(del_index_path)
115117
p.set_ef(100)
116118

117119
labels1_after, _ = p.knn_query(data1, k=1)
118120
for la in labels1_after:
119121
for lb in labels1:
120122
if la[0] == lb[0]:
121123
self.assertTrue(False)
124+
125+
os.remove(index_path)
126+
os.remove(del_index_path)
122127

123128

124129

File renamed without changes.

0 commit comments

Comments
 (0)