How to make python load dylib on osx

Trying to load shared lib from current '.' dir in unit test on osx.

What works with Linux and Netbsd, there is a symbolic link _mymodule.so --> ../.libs/libmymodule.so

but in osx, python import mymodule will not find

 _mymodule.dylib --> ../.libs/libmymodule.dylib 

I tried adding

 export DYLD_LIBRARY_PATH=.:$DYLD_LIBRARY_PATH 

in script env, nogo. Any help was appreciated.

Red

update 4/6/10:

Solved with information from krunk below. But just copying or including dylib in the .so name did not solve it completely. All the same, it did not boot. But telling libtool to bind lib to the -module flag created by .so lib to be loaded. Now the lib version in Python is working.

Now, if I could just run perl lib. I am creating swig perl, python, ruby ​​and lua libs, and this fix only worked for python and lua.

+7
python dylib macos
source share
1 answer

Just use * .so as an extension of your module in OS X. I have vague memory about the inability to load .dylib, and this turns out to be a problem with python itself, but now I can not find the mailing list.

However, be sure to follow standard practice using * .so even on OS X. The only * .dylib in the whole structure is libsvn_swig.

 find /System/Library/Frameworks/Python.framework/Versions/2.6/ -name "*.so" /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/X11/xcb/xcb.0.0.0.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/X11/xcb/xcb.0.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/X11/xcb/xcb.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/CoreGraphics/_CoreGraphics.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/OpenSSL/SSL.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/OpenSSL/crypto.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/OpenSSL/rand.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/PyObjC/AppKit/_appmain.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/PyObjC/AppKit/_carbon.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/PyObjC/AppKit/_inlines.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/PyObjC/AppKit/_nsbezierpath.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/PyObjC/AppKit/_nsbitmap.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/PyObjC/AppKit/_nsfont.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/PyObjC/AppKit/_nsquickdrawview.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/PyObjC/AppKit/_nsview.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/PyObjC/AppKit/_nswindow.so /System/Library/Frameworks/Python.framework/Versions/2.6//Extras/lib/python/PyObjC/CFNetwork/_manual.so 
+12
source share

All Articles