changeset 17:5b8167619b76

* Add simple hack for preloading python on OS/X
author cannam
date Thu, 25 Jun 2009 16:23:30 +0000
parents acaa8ff2c606
children e9cf443b18f5
files pyvamp-main.cpp
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }