From 19bbb1b404cd659609471a2d331639e21cfd7388 Mon Sep 17 00:00:00 2001 From: Ben Frederickson Date: Mon, 1 Oct 2018 16:33:56 -0700 Subject: [PATCH] various windows build fixes 'and' isn't a valid operator on C++ (though apparently works in linux), and on some windows configurations we needed to include a different header file for _mm_prefetch. Also if git wasn't configured with symlinks succesfully, fallback to a relative path in setup.py. Fixes https://github.com/nmslib/nmslib/issues/295 and https://github.com/nmslib/nmslib/issues/348 --- python_bindings/setup.py | 7 ++++++- similarity_search/src/method/hnsw.cc | 2 +- similarity_search/src/method/small_world_rand.cc | 4 ++++ similarity_search/src/method/vptree.cc | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/python_bindings/setup.py b/python_bindings/setup.py index 239d8ca..d7874bb 100755 --- a/python_bindings/setup.py +++ b/python_bindings/setup.py @@ -7,6 +7,11 @@ __version__ = '1.7.3.4' libdir = os.path.join(".", "nmslib", "similarity_search") +if not os.path.isdir(libdir) and sys.platform.startswith("win"): + # If the nmslib symlink doesn't work (windows symlink support w/ git is + # a little iffy), fallback to use a relative path + libdir = os.path.join("..", "similarity_search") + library_file = os.path.join(libdir, "release", "libNonMetricSpaceLib.a") source_files = ['nmslib.cc'] @@ -22,7 +27,7 @@ exclude_files = set("""bbtree.cc lsh.cc lsh_multiprobe.cc lsh_space.cc falconn.cc nndes.cc space_sqfd.cc dummy_app.cc main.cc""".split()) - for root, subdirs, files in os.walk(os.path.join("nmslib", "similarity_search", "src")): + for root, subdirs, files in os.walk(os.path.join(libdir, "src")): source_files.extend(os.path.join(root, f) for f in files if f.endswith(".cc") and f not in exclude_files) diff --git a/similarity_search/src/method/hnsw.cc b/similarity_search/src/method/hnsw.cc index f88e7f9..f5c7fca 100644 --- a/similarity_search/src/method/hnsw.cc +++ b/similarity_search/src/method/hnsw.cc @@ -684,7 +684,7 @@ namespace similarity { void Hnsw::Search(KNNQuery *query, IdType) const { - if (this->data_.empty() and this->data_rearranged_.empty()) { + if (this->data_.empty() && this->data_rearranged_.empty()) { return; } bool useOld = searchAlgoType_ == kOld || (searchAlgoType_ == kHybrid && ef_ >= 1000); diff --git a/similarity_search/src/method/small_world_rand.cc b/similarity_search/src/method/small_world_rand.cc index 59e13f7..e8280cb 100644 --- a/similarity_search/src/method/small_world_rand.cc +++ b/similarity_search/src/method/small_world_rand.cc @@ -18,6 +18,10 @@ // This is only for _mm_prefetch #include +#if defined(_WIN32) || defined(WIN32) +#include +#endif + #include "portable_simd.h" #include "space.h" #include "knnquery.h" diff --git a/similarity_search/src/method/vptree.cc b/similarity_search/src/method/vptree.cc index d0262ad..04f481e 100644 --- a/similarity_search/src/method/vptree.cc +++ b/similarity_search/src/method/vptree.cc @@ -21,6 +21,9 @@ // This is only for _mm_prefetch #include +#if defined(_WIN32) || defined(WIN32) +#include +#endif #include "portable_simd.h" #include "space.h"