Re: [Pyobjc-dev] fixing framework bindings at runtime
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2020-05-24 13:36:14
|
Hi, Sorry about the bad news, but… The version of PyObjC shipped with macOS is ancient and unsupported, and its framework bindings aren’t based on upstream code. Not only that, but macOS has never shipped with good data in BridgeSupport files and that has gotten worse in the last couple of releases (which is why upstream PyObjC has never used these files). The only good solution is to switch to a current version of PyObjC (and Python). That should work and has tests for the bindings. That said, it might be possible to use the manual binding system implement the minimal set of metadata needed for your script. I can’t recall which parts of that system were implemented in the version of PyObjC that Apple ships. Ronald — Twitter / micro.blog: @ronaldoussoren Blog: https://blog.ronaldoussoren.net/ > On 24 May 2020, at 12:09, sp...@rn... wrote: > > 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/ > > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |