Mercurial > hg > vampy
comparison 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 |
comparison
equal
deleted
inserted
replaced
24:7d28bed0864e | 25:7648f3f2fa14 |
---|---|
139 } | 139 } |
140 #endif | 140 #endif |
141 | 141 |
142 return false; | 142 return false; |
143 } | 143 } |
144 | 144 |
145 /* This doesn't work: don't try it again. | |
146 static bool initPython() | |
147 { | |
148 // preloadPython(); | |
149 Py_Initialize(); | |
150 #ifndef _WIN32 | |
151 //set dlopen flags form Python | |
152 string pyCmd = "from sys import setdlopenflags\nimport dl\nsetdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)\n"; | |
153 if (PyRun_SimpleString(pyCmd.c_str()) == -1) | |
154 { | |
155 cerr << "Warning: Could not set dlopen flasgs. Dynamic loading in scripts will fail." << endl; | |
156 return false; | |
157 } | |
158 #endif | |
159 PyEval_InitThreads(); | |
160 return Py_IsInitialized(); | |
161 } | |
162 */ | |
145 | 163 |
146 const VampPluginDescriptor | 164 const VampPluginDescriptor |
147 *vampGetPluginDescriptor(unsigned int version,unsigned int index) | 165 *vampGetPluginDescriptor(unsigned int version,unsigned int index) |
148 { | 166 { |
149 if (version < 1) return 0; | 167 if (version < 1) return 0; |
152 cerr << "# isPythonInitialized: " << isPythonInitialized << endl; | 170 cerr << "# isPythonInitialized: " << isPythonInitialized << endl; |
153 cerr << "# haveScannedPlugins: " << haveScannedPlugins << endl; | 171 cerr << "# haveScannedPlugins: " << haveScannedPlugins << endl; |
154 | 172 |
155 if (!haveScannedPlugins) { | 173 if (!haveScannedPlugins) { |
156 | 174 |
157 if (!isPythonInitialized) { | 175 if (!isPythonInitialized){ |
158 | 176 |
159 if (!preloadPython()) { | 177 if (!preloadPython()) |
160 cerr << "Warning: Could not preload Python." | 178 cerr << "Warning: Could not preload Python. Dynamic loading in scripts will fail." << endl; |
161 << " Dynamic loading in scripts will fail." << endl; | |
162 } | |
163 | |
164 /* | |
165 void *pylib = 0; | |
166 | |
167 cerr << "Loading Python Interpreter at: " << pythonPath << endl; | |
168 //Preloading the binary allows the load of shared libs | |
169 //TODO: check how to do RTLD_NOW on Windows | |
170 #ifdef _WIN32 | |
171 pylib = LoadLibrary(pythonPath.c_str()); | |
172 #else | |
173 pylib = dlopen(pythonPath.c_str(), RTLD_NOW|RTLD_GLOBAL); | |
174 #endif | |
175 if (!pylib) cerr << "Warning: Could not preload Python." | |
176 << " Dynamic loading in scripts will fail." << endl; | |
177 */ | |
178 Py_Initialize(); | 179 Py_Initialize(); |
179 cerr << "# isPythonInitialized after initialize: " << Py_IsInitialized() << endl; | 180 cerr << "# isPythonInitialized after initialize: " << Py_IsInitialized() << endl; |
180 PyEval_InitThreads(); | 181 // PyEval_InitThreads(); //not sure why this was needed |
181 } else { | |
182 //Py_InitializeEx(1); | |
183 } | 182 } |
183 | |
184 | 184 |
185 vector<string> pyPlugs; | 185 vector<string> pyPlugs; |
186 vector<string> pyPath; | 186 vector<string> pyPath; |
187 vector<PyObject *> pyClasses; | 187 vector<PyObject *> pyClasses; |
188 static PyPlugScanner *scanner; | 188 static PyPlugScanner *scanner; |