More particularly, i'm going to be working on some opencv compatibility for scikits.image. The idea is the user can build scikits.image once, regardless of whether or not OpenCV is currently on their system. If and when the user does put OpenCV on their system, then scikits.image.opencv automagically works...
Perhaps, that's what you meant in point a)... I was thinking more along the lines of point b).... if the user tries to import scikits.image.opencv and opencv .so's are not present, then i would raise an exception when dlopen returned None. Chris On Wed, Oct 7, 2009 at 7:58 PM, Dag Sverre Seljebotn <[email protected]> wrote: > Chris Colbert wrote: >> using something similar to ctypes dlopen? >> >> I would like to be able to create a wrapper for a library that can >> built on the client machine without the necessity of the target >> libraries being present. > > Consider having multiple modules -- say, mylib and mylib.withsolib. > > a) Have the build fail gracefully for withsolib > b) In mylib, import withsolib with a try/except. > > This is by far the most cross-platform, robust etc. etc. way of doing it > -- it basically pushes everything to the build system. > >> >> Then, upon import of the library, the library would check for the >> presence of the .so's and raise an exception if they are not found. >> >> This way, once the user installs the libraries, the functionality >> automagically works. >> >> I've searched around, but not really found anything on the topic. >> >> Is it as easy as just using "cdef extern from dlfcn.h" and declaring >> the appropriate dlopen machinery and using as normal? > > Yes, should be. That is, you need to declare function pointers and use > the functions through these: > > cdef double (*cosine)(double) > > And then assign and call them. The example from "man dlopen" can > probably be ported almost verbatim to Cython. > > -- > Dag Sverre > _______________________________________________ > Cython-dev mailing list > [email protected] > http://codespeak.net/mailman/listinfo/cython-dev > _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
