# HG changeset patch # User cannam # Date 1245947010 0 # Node ID 5b8167619b760dac59cf92ab8d5d26fc68a7cf60 # Parent acaa8ff2c606428781ed41eea7a362a71ac1a32d * Add simple hack for preloading python on OS/X diff -r acaa8ff2c606 -r 5b8167619b76 pyvamp-main.cpp --- a/pyvamp-main.cpp Mon Jul 07 17:09:07 2008 +0000 +++ b/pyvamp-main.cpp Thu Jun 25 16:23:30 2009 +0000 @@ -123,7 +123,7 @@ static bool preloadPython() { - // Linux-specific + // useless on Windows string pyver = Py_GetVersion(); int dots = 2; @@ -147,6 +147,16 @@ char buffer[5]; // hahaha! grossness is like a brother to us +#ifdef __APPLE__ + for (int pfxidx = 0; pfxidx < pfxs.size(); ++pfxidx) { + for (int minor = 8; minor >= 0; --minor) { + sprintf(buffer, "%d", minor); + if (tryPreload(pfxs[pfxidx] + string("libpython") + shortver + ".dylib." + buffer)) return true; + } + if (tryPreload(pfxs[pfxidx] + string("libpython") + shortver + ".dylib")) return true; + if (tryPreload(pfxs[pfxidx] + string("libpython.dylib"))) return true; + } +#else for (int pfxidx = 0; pfxidx < pfxs.size(); ++pfxidx) { for (int minor = 8; minor >= 0; --minor) { sprintf(buffer, "%d", minor); @@ -155,6 +165,7 @@ if (tryPreload(pfxs[pfxidx] + string("libpython") + shortver + ".so")) return true; if (tryPreload(pfxs[pfxidx] + string("libpython.so"))) return true; } +#endif return false; }