# HG changeset patch # User cannam # Date 1255096105 0 # Node ID 7e59caea821b77f62b528cb793f1213e0a0835ae # Parent d56f48aafb99fc87066c5c484b111f38487a7c44 * Make a better job of preloading Python, especially when it's in a framework. Go for the Python file in the frameworks directory in preference to any libpythonX.Y.dylib. Particularly, don't try to preload any library without an absolute path until we've exhausted all our framework possibilities (so as to avoid picking up an ancient system library). diff -r d56f48aafb99 -r 7e59caea821b Makefile.osx.universal --- a/Makefile.osx.universal Thu Oct 08 08:59:08 2009 +0000 +++ b/Makefile.osx.universal Fri Oct 09 13:48:25 2009 +0000 @@ -1,7 +1,7 @@ -CXXFLAGS := -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -D_DEBUG -DHAVE_NUMPY -I../vamp-plugin-sdk -O2 -Wall -I/usr/include/python2.5 -I/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy/core/include/ +CXXFLAGS := -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -D_DEBUG -DHAVE_NUMPY -I../vamp-plugin-sdk -O2 -Wall -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/include/ -LDFLAGS := -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -install_name vampy.dylib -exported_symbols_list vamp-plugin.list ../vamp-plugin-sdk/libvamp-sdk.a -dynamiclib -lpython2.5 -lpthread +LDFLAGS := -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -install_name vampy.dylib -exported_symbols_list vamp-plugin.list ../vamp-plugin-sdk/libvamp-sdk.a -dynamiclib -framework Python -lpthread default: vampy.dylib all: vampy.dylib vampymod.so @@ -11,10 +11,10 @@ # The standard python extension is .so (even on the Mac) vampymod.so: PyExtensionModule.o PyRealTime.o PyFeature.o PyParameterDescriptor.o PyOutputDescriptor.o PyFeatureSet.o - g++ -shared $^ -o $@ $(LDFLAGS) + g++ -dynamiclib $^ -o $@ $(LDFLAGS) vampy.dylib: PyPlugin.o PyPlugScanner.o vampy-main.o Mutex.o PyTypeInterface.o PyExtensionModule.a PyExtensionManager.o - g++ -shared $^ -o $@ $(LDFLAGS) + g++ -dynamiclib $^ -o $@ $(LDFLAGS) # Install plugin # diff -r d56f48aafb99 -r 7e59caea821b vampy-main.cpp --- a/vampy-main.cpp Thu Oct 08 08:59:08 2009 +0000 +++ b/vampy-main.cpp Fri Oct 09 13:48:25 2009 +0000 @@ -208,6 +208,7 @@ static bool tryPreload(string name) { +// cerr << "tryPreload: " << name << endl; #ifdef _WIN32 void *lib = LoadLibrary(name.c_str()); if (!lib) { @@ -216,9 +217,11 @@ #else void *lib = dlopen(name.c_str(), RTLD_NOW | RTLD_GLOBAL); if (!lib) { + perror("dlopen"); return false; } #endif + cerr << "Preloaded Python from " << name << endl; return true; } @@ -245,9 +248,9 @@ cerr << "Python exec prefix: " << Py_GetExecPrefix() << endl; vector pfxs; + pfxs.push_back(string(Py_GetExecPrefix()) + "/"); + pfxs.push_back(string(Py_GetExecPrefix()) + "/lib/"); pfxs.push_back(""); - pfxs.push_back(string(Py_GetExecPrefix()) + "/lib/"); - pfxs.push_back(string(Py_GetExecPrefix()) + "/"); pfxs.push_back("/usr/lib/"); pfxs.push_back("/usr/local/lib/"); char buffer[5]; @@ -255,6 +258,8 @@ // hahaha! grossness is like a brother to us #ifdef __APPLE__ for (size_t pfxidx = 0; pfxidx < pfxs.size(); ++pfxidx) { +// cerr << "prefix: " << pfxs[pfxidx] << endl; + if (tryPreload(pfxs[pfxidx] + string("Python"))) return true; for (int minor = 8; minor >= 0; --minor) { sprintf(buffer, "%d", minor); if (tryPreload(pfxs[pfxidx] + string("libpython") + shortver + ".dylib." + buffer)) return true;