It would be very helpful if you could add the actual commands that are necessary to compile the Python wrappers to the readme.
Right now the instructions assume that I know what I am doing :)
Step 2: Compiling the Python interface
The Python interface is provided via SWIG (Simple Wrapper and
Interface Generator) and an additional level of manual wrappers (in faiss.py).SWIG generates two wrapper files: a Python file (swigfaiss.py) and a
C++ file that must be compiled to a dynamic library (_swigfaiss.so).The C++ compilation to the dynamic library requires to set:
SHAREDFLAGS: system-specific flags to generate a dynamic library
PYTHONCFLAGS: include flags for Python
See the example makefile.inc's on how to set the flags.
I think I have figured out step 1 by myself:
swig -c++ -python swigfaiss.swig
which generates several swigfaiss_* .py and .c files. So I assume the final step that I am missing is to make the dynamic library. It would be very helpful if you could list the actual line that needs to be run.
Hmmm... Let me clarify this:
The makefile only makes the faiss.py file for me. When I run
python -c "import faiss"
I get
Failed to load GPU Faiss: No module named swigfaiss_gpu
Faiss falling back to CPU-only.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "faiss.py", line 28, in <module>
from swigfaiss import *
File "swigfaiss.py", line 28, in <module>
_swigfaiss = swig_import_helper()
File "swigfaiss.py", line 20, in swig_import_helper
import _swigfaiss
ImportError: No module named _swigfaiss
Ok, I updated the doc, you can just run
make py
Thanks for pointing this out
Perfect - that fixed it. Test import works now.
Most helpful comment
Ok, I updated the doc, you can just run
make py
Thanks for pointing this out