Mercurial > hg > vampy
diff vampy-main.cpp @ 53:7e59caea821b
* 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).
author | cannam |
---|---|
date | Fri, 09 Oct 2009 13:48:25 +0000 |
parents | c1e4f706ca9a |
children | f0592002c61d |
line wrap: on
line diff
--- 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<string> 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;