[Pyobjc-dev] fixing framework bindings at runtime
Brought to you by:
ronaldoussoren
|
From: <sp...@rn...> - 2020-05-24 10:39:20
|
hello,
I use pyobjc bindings to build an application that is distributed [0].
Unfortunately, I have to rely on the Apple provided versions of python/pyobjc (2.7.16/2.5.1 on catalina).
On Catalina, importing the AVFoundation framework leads to a runtime warning (Error parsing BridgeSupport data for AVFoundation), see below:
%python
Python 2.7.16 (default, Feb 29 2020, 01:55:37)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import objc
>>> objc.__version__
'2.5.1'
>>> import AVFoundation
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_bridgesupport.py:674: RuntimeWarning: Error parsing BridgeSupport data for AVFoundation: PyObjCRT_SkipTypeSpec: Unhandled type '5d' ]}
warnings.warn("Error parsing BridgeSupport data for %s: %s" % (frameworkName, e), RuntimeWarning)
As a consequence, many things are not loaded properly.
For example constants are missing (I can fix that by declaring the constants in my code).
But I have a problem that I could not manage to fix myself:
Methods that take a callback as parameter, like AVCaptureDevice.requestAccessForMediaType_completionHandler_, fail with a type error (Argument 3 is a block, but no signature available):
>>> AVMediaTypeVideo = "vide"
>>> from Foundation import NSObject
>>> class Test(NSObject):
... def test_(self, granted):
... print(granted)
...
>>> test = Test.alloc().init()
>>> AVFoundation.AVCaptureDevice.requestAccessForMediaType_completionHandler_(
... AVMediaTypeVideo,
... test.test_)
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
TypeError: Argument 3 is a block, but no signature available
>>> test.test_.signature
'v@:@'
>>> AVFoundation.AVCaptureDevice.requestAccessForMediaType_completionHandler_.signature
'v32@0:8@16@?24'
Any idea on how to fix this problem without altering the default python/pyobjc installation?
Thanks a lot for any suggestion,
Renaud
0. Présentation.app
http://iihm.imag.fr/blanch/software/osx-presentation/
|