Thread: [Pyobjc-dev] trying to integrate an objective C library into a Python prototype application
Brought to you by:
ronaldoussoren
|
From: John S. <joh...@gm...> - 2008-01-26 22:34:21
|
I am new to Mac/ObjC development, and intermediate in my Python skill.
I have downloaded the Darwiin wii-remote library, and I am trying to
integrate it with my existing application developed in Python. I'm working
on a MacBook running Leopard, and I've downloaded XCode 3.0, and fink, and
vpython, and a few other things. I can run parts of my app through IDLE
successfully.
In XCode, I get these messages during my build and run:
This GDB was configured as "i386-apple-darwin".warning: Unable to read
symbols for
"@executable_path/../Frameworks/WiiRemote.framework/Versions/A/WiiRemote"
(file not found).
Program loaded.
sharedlibrary apply-load-rules all
Attaching to program:
`/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS/boogiepants',
process 8515.
The Debugger has exited with status 0.
[Session started at 2008-01-22 22:28:09 -0600.]
objc[8633]: Class WiiRemote is implemented in both
/Library/Frameworks/WiiRemote.framework/Versions/A/WiiRemote and
/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS/boogiepants.
Using implementation from
/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS/boogiepants.
objc[8633]: Class WiiRemoteDiscovery is implemented in both
/Library/Frameworks/WiiRemote.framework/Versions/A/WiiRemote and
/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS/boogiepants.
Using implementation from
/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS/boogiepants.
Traceback (most recent call last):
File
"/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/Resources/main.py",
line 17, in <module>
import boogiepantsAppDelegate
File
"/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/Resources/boogiepantsAppDelegate.py",
line 14, in <module>
from WiiRemote import *
ImportError: No module named WiiRemote
In Idle, I try importing a bunch of libraries (I like IDLE better):
import sys
sys.path.extend
(['/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/PyObjC',
'/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS',
'/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/Resources',
'/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/Resources/PyObjC',
'/Library/Frameworks'],
'/Users/jstoner/Documents/projects/boogiepants/WiiRemoteFramework/build/Release/WiiRemote.framework/'])
But I still can't seem to find the right file:
import WiiRemote
...
ImportError: No module named WiiRemote
I've screwed around a lot trying to get Python to find this library to no
avail. Any ideas?
--
blog:
http://www.generosity.org/stoner/
'In knowledge is power, in wisdom, humility.'
|
|
From: Kevin A. M. <ka...@ka...> - 2008-01-26 23:35:20
|
It just needs a little bit of glue. You can't directly import a framework,
but you can get objc to load the bundle.
Create a WiiRemote.py like this:
def _load(name, g):
import objc
objc.loadBundle(name, g, bundle_path='WiiRemote.framework')
_load(__name__, globals())
and then you can
$ python
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import WiiRemote
>>> w = WiiRemote.WiiRemote.new()
>>> w
<WiiRemote: 0x6ff830>
If WiiRemote.framework isn't in the current directory, your program will
have to find it. The original template code from a Python app I'm working on
had:
from Foundation import NSBundle
bundle_path = NSBundle.mainBundle().pathForResource_ofType_(unicode(name),
u'bundle')
objc.loadBundle(name, g, bundle_path=bundle_path)
(I'm using PyObjC 1.4 on Python 2.5 on Tiger, but it should work similarly
on Leopard)
Kevin
On 1/26/08, John Stoner <joh...@gm...> wrote:
>
> I am new to Mac/ObjC development, and intermediate in my Python skill.
>
> I have downloaded the Darwiin wii-remote library, and I am trying to
> integrate it with my existing application developed in Python. I'm working
> on a MacBook running Leopard, and I've downloaded XCode 3.0, and fink, and
> vpython, and a few other things. I can run parts of my app through IDLE
> successfully.
>
> In XCode, I get these messages during my build and run:
>
> This GDB was configured as "i386-apple-darwin".warning: Unable to read
> symbols for
> "@executable_path/../Frameworks/WiiRemote.framework/Versions/A/WiiRemote"
> (file not found).
> Program loaded.
> sharedlibrary apply-load-rules all
> Attaching to program:
> `/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS/boogiepants',
> process 8515.
>
> The Debugger has exited with status 0.
> [Session started at 2008-01-22 22:28:09 -0600.]
> objc[8633]: Class WiiRemote is implemented in both
> /Library/Frameworks/WiiRemote.framework/Versions/A/WiiRemote and
> /Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS/boogiepants.
> Using implementation from
> /Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS/boogiepants.
> objc[8633]: Class WiiRemoteDiscovery is implemented in both
> /Library/Frameworks/WiiRemote.framework/Versions/A/WiiRemote and
> /Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS/boogiepants.
> Using implementation from
> /Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS/boogiepants.
> Traceback (most recent call last):
> File
> "/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/Resources/main.py",
> line 17, in <module>
> import boogiepantsAppDelegate
> File
> "/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/Resources/boogiepantsAppDelegate.py",
> line 14, in <module>
> from WiiRemote import *
> ImportError: No module named WiiRemote
>
> In Idle, I try importing a bunch of libraries (I like IDLE better):
>
> import sys
> sys.path.extend
> (['/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin',
>
> '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac',
>
> '/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python',
>
> '/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/PyObjC',
>
> '/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/MacOS',
>
> '/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/Resources',
>
> '/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/boogiepants.app/Contents/Resources/PyObjC',
> '/Library/Frameworks'],
>
> '/Users/jstoner/Documents/projects/boogiepants/WiiRemoteFramework/build/Release/WiiRemote.framework/'])
> But I still can't seem to find the right file:
>
> import WiiRemote
> ...
> ImportError: No module named WiiRemote
>
> I've screwed around a lot trying to get Python to find this library to no
> avail. Any ideas?
> --
> blog:
> http://www.generosity.org/stoner/
> 'In knowledge is power, in wisdom, humility.'
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Pyobjc-dev mailing list
> Pyo...@li...
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
>
>
|