Re: [Pyobjc-dev] Mixing py2app with Python C interface plugins
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2010-01-26 10:18:57
|
On 24 Jan, 2010, at 18:18, Ian Beck wrote: > Hey folks, > > I'm working on a plugin that adds several Python scripts to a program. Previously I was just compiling it with py2app, but this slowed the main application launch way down so the developer asked me to switch to manually setting things up via Objective-C and the Python C interface. I did so, and it works great. > > However, now there's a second plugin that uses py2app, and it's conflicting with my plugin because the Python interpreter is already setup by the time my plugin gets to it and for some reason it's causing my main Python file to try and import from both the Python 2.5 framework and the 2.6 framework when I run it using PyRun_SimpleFile (I'm on 10.6, obviously). I get a bunch of error messages along these lines in the console before the whole thing crashes: > > Class OC_NSBundleHack is implemented in both /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/objc/_objc.so and /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/PyObjC/objc/_objc.so. One of the two will be used. Which one is undefined. > > Any ideas how I can get my C API plugin and the third party py2app plugin to live happily in the same Python interpreter? I'm pretty sure this is a simple problem of the Python environment being setup differently by py2app and my C API code, but I'm not sure what types of things I might need to change to fix the problem. > > Thanks for any suggestions you can give me! You cannot link to multiple python interpreters in the same proces when you also use PyObjC due to conflicting symbols. Even without PyObjC using multiple Python versions at the same time is hairy and only works on OSX due to two-level namespaces. The only workaround for this is to use the same version of Python in your plugin and the py2app one. Ronald P.S. It is probably possible to work around this using preprocessor trickery in the PyObjC sources to ensure that all used symbols are version specific but I'm not interested in working on that any time soon (but would be willing to review and apply patches). |