Skip to content

Move setup.py into root folder #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
python_bindings/hnswlib.egg-info/
python_bindings/build/
python_bindings/dist/
python_bindings/tmp/
hnswlib.egg-info/
build/
dist/
tmp/
python_bindings/tests/__pycache__/
*.pyd
hnswlib.cpython*.so
32 changes: 27 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
language: python

matrix:
jobs:
include:
- python: 3.6
- python: 3.7
- name: Linux Python 3.6
os: linux
python: 3.6

- name: Linux Python 3.7
os: linux
python: 3.7

- name: Windows Python 3.6
os: windows
language: shell # 'language: python' is an error on Travis CI Windows
before_install:
- choco install python --version 3.6.0
- python -m pip install --upgrade pip
- python --version
env: PATH=/c/Python36:/c/Python36/Scripts:$PATH

- name: Windows Python 3.7
os: windows
language: shell # 'language: python' is an error on Travis CI Windows
before_install:
- choco install python --version 3.7.0
- python -m pip install --upgrade pip
- python --version
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH

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

script:
- |
cd python_bindings
python setup.py test
File renamed without changes.
2 changes: 1 addition & 1 deletion python_bindings/Makefile → Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ test:
python3 setup.py test

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

.PHONY: dist
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ You can install from sources:
```bash
apt-get install -y python-setuptools python-pip
pip3 install pybind11 numpy setuptools
cd python_bindings
python3 setup.py install
```

Expand Down Expand Up @@ -243,13 +242,15 @@ Contributions are highly welcome!
Please make pull requests against the `develop` branch.

### 200M SIFT test reproduction
To download and extract the bigann dataset:
To download and extract the bigann dataset (from root directory):
```bash
python3 download_bigann.py
```
To compile:
```bash
cmake .
mkdir build
cd build
cmake ..
make all
```

Expand Down
2 changes: 1 addition & 1 deletion python_bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h>
#include "hnswlib/hnswlib.h"
#include "hnswlib.h"
#include <thread>
#include <atomic>
#include <stdlib.h>
Expand Down
1 change: 0 additions & 1 deletion python_bindings/hnswlib

This file was deleted.

117 changes: 0 additions & 117 deletions python_bindings/setup.py

This file was deleted.

1 change: 1 addition & 0 deletions python_bindings/setup.py
11 changes: 7 additions & 4 deletions python_bindings/tests/bindings_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import unittest


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

# Serializing and deleting the index:
index_path='first_half.bin'
index_path = 'first_half.bin'
print("Saving index to '%s'" % index_path)
p.save_index("first_half.bin")
p.save_index(index_path)
del p

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

print("\nLoading index from 'first_half.bin'\n")
p.load_index("first_half.bin")
print("\nLoading index from '%s'\n" % index_path)
p.load_index(index_path)

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

self.assertAlmostEqual(np.mean(labels.reshape(-1) == np.arange(len(data))),1.0,3)

os.remove(index_path)


if __name__ == "__main__":
Expand Down
17 changes: 11 additions & 6 deletions python_bindings/tests/bindings_test_labels.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import unittest


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

index_path='first_half.bin'
index_path = 'first_half.bin'
print("Saving index to '%s'" % index_path)
p.save_index("first_half.bin")
p.save_index(index_path)
print("Saved. Deleting...")
del p
print("Deleted")
Expand All @@ -68,8 +69,8 @@ def testRandomSelf(self):
print("Reiniting")
p = hnswlib.Index(space='l2', dim=dim)

print("\nLoading index from 'first_half.bin'\n")
p.load_index("first_half.bin")
print("\nLoading index from '%s'\n" % index_path)
p.load_index(index_path)
p.set_ef(100)

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

# checking saving/loading index with elements marked as deleted
p.save_index("with_deleted.bin")
del_index_path = "with_deleted.bin"
p.save_index(del_index_path)
p = hnswlib.Index(space='l2', dim=dim)
p.load_index("with_deleted.bin")
p.load_index(del_index_path)
p.set_ef(100)

labels1_after, _ = p.knn_query(data1, k=1)
for la in labels1_after:
for lb in labels1:
if la[0] == lb[0]:
self.assertTrue(False)

os.remove(index_path)
os.remove(del_index_path)



Expand Down
File renamed without changes.
Loading