djsutherland / cyflann

A Cython interface to FLANN
BSD 3-Clause "New" or "Revised" License
25 stars 6 forks source link

Compile to a single library file ? #24

Closed MonkeyChap closed 7 years ago

MonkeyChap commented 7 years ago

Hi Dougal,

Thanks for doing this. I'm pretty new to Cython and my C/C++ is from 20 years ago. I'd ideally like to wrap the FLANN C++ code in Cython and then compile it all to a single .so / .pyd file. Is this possible or will there always be two libs (one Cython, one FLANN native) ?

Thanks

Ian

djsutherland commented 7 years ago

Hi, I think that should be possible, but I don't see how to do it in a small amount of work.

You could probably adjust cyflann to use nanoflann, which would definitely fit that bill.

Depending on your needs, you also might prefer using FALCONN or annoy.

MonkeyChap commented 7 years ago

Thanks - I looked at Annoy, but it doesn't have some of the features we need. I'll take a look at nanoflann though !

MonkeyChap commented 7 years ago

Just looked at nanoflann - seems it's just 2D and 3D optimised (we've got 100s of features). So...cyflann it is ! When I compile the pyd / so file, what dependencies do I need to package with it if I want to run it in a vanilla python/anaconda environment ? (I found a 1MB .o file - not sure if that's been compiled into the final file)

djsutherland commented 7 years ago

@MonkeyChap Sorry, I just found a partially-written reply to this in my drafts folder -- thought I had forever ago!

The .o file isn't necessary. It's easiest if you use setuptools to build everything, of yours; then setup.py install will only install the .so that you need. Same for cyflann itself. Check out https://github.com/dougalsutherland/skl-groups/blob/master/setup_accel.py for an example of doing that.

If you use conda, cyflann will hopefully be in conda-forge soon and then you can just install it that way. flann already is.

djsutherland commented 7 years ago

cyflann is now in conda-forge, so if you just conda install -c conda-forge cyflann then that should give you all the dependencies you need. Let me know if you need any help and I'll try to reply more promptly. :)