Mercurial > hg > vampy
diff pyvamp-main.cpp @ 25:7648f3f2fa14
cleaned up vampy preloading, no functional change. tried python preload, did not work.
author | fazekasgy |
---|---|
date | Tue, 18 Aug 2009 08:32:45 +0000 |
parents | 7d28bed0864e |
children | ba3686eb697c |
line wrap: on
line diff
--- a/pyvamp-main.cpp Mon Aug 17 15:22:06 2009 +0000 +++ b/pyvamp-main.cpp Tue Aug 18 08:32:45 2009 +0000 @@ -141,7 +141,25 @@ return false; } - + +/* This doesn't work: don't try it again. +static bool initPython() +{ + // preloadPython(); + Py_Initialize(); +#ifndef _WIN32 + //set dlopen flags form Python + string pyCmd = "from sys import setdlopenflags\nimport dl\nsetdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)\n"; + if (PyRun_SimpleString(pyCmd.c_str()) == -1) + { + cerr << "Warning: Could not set dlopen flasgs. Dynamic loading in scripts will fail." << endl; + return false; + } +#endif + PyEval_InitThreads(); + return Py_IsInitialized(); +} +*/ const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int version,unsigned int index) @@ -154,33 +172,15 @@ if (!haveScannedPlugins) { - if (!isPythonInitialized) { + if (!isPythonInitialized){ - if (!preloadPython()) { - cerr << "Warning: Could not preload Python." - << " Dynamic loading in scripts will fail." << endl; - } + if (!preloadPython()) + cerr << "Warning: Could not preload Python. Dynamic loading in scripts will fail." << endl; + Py_Initialize(); + cerr << "# isPythonInitialized after initialize: " << Py_IsInitialized() << endl; + // PyEval_InitThreads(); //not sure why this was needed + } -/* - void *pylib = 0; - - cerr << "Loading Python Interpreter at: " << pythonPath << endl; - //Preloading the binary allows the load of shared libs - //TODO: check how to do RTLD_NOW on Windows -#ifdef _WIN32 - pylib = LoadLibrary(pythonPath.c_str()); -#else - pylib = dlopen(pythonPath.c_str(), RTLD_NOW|RTLD_GLOBAL); -#endif - if (!pylib) cerr << "Warning: Could not preload Python." - << " Dynamic loading in scripts will fail." << endl; -*/ - Py_Initialize(); - cerr << "# isPythonInitialized after initialize: " << Py_IsInitialized() << endl; - PyEval_InitThreads(); - } else { - //Py_InitializeEx(1); - } vector<string> pyPlugs; vector<string> pyPath;