Re: fixing framework bindings at runtime
Ronald Oussoren via Pyobjc-dev <[email protected]> Sun, 24 May 2020 15:35:57 +0200
| Newsgroups | gmane.comp.python.pyobjc.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============8279289276772715344== Content-Type: multipart/alternative; boundary="Apple-Mail=_BF31A657-134F-4790-9EFD-5F64E15700B4" --Apple-Mail=_BF31A657-134F-4790-9EFD-5F64E15700B4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi, Sorry about the bad news, but=E2=80=A6 The version of PyObjC shipped with macOS is ancient and unsupported, and = its framework bindings aren=E2=80=99t 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). =20 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=E2=80= =99t recall which parts of that system were implemented in the version = of PyObjC that Apple ships.=20 Ronald =E2=80=94 Twitter / micro.blog: @ronaldoussoren Blog: https://blog.ronaldoussoren.net/ > On 24 May 2020, at 12:09, [email protected] wrote: >=20 > hello, >=20 > 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: >=20 > %python =20 > Python 2.7.16 (default, Feb 29 2020, 01:55:37)=20 > [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) >=20 > 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): >=20 >>>> AVMediaTypeVideo =3D "vide" >>>> from Foundation import NSObject >>>> class Test(NSObject): > ... def test_(self, granted): > ... print(granted) > ...=20 >>>> test =3D 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 >=20 >>>> test.test_.signature > 'v@:@' >>>> = AVFoundation.AVCaptureDevice.requestAccessForMediaType_completionHandler_.= signature > 'v32@0:8@16@?24' >=20 > Any idea on how to fix this problem without altering the default = python/pyobjc installation? > Thanks a lot for any suggestion, >=20 > Renaud >=20 > 0. Pr=C3=A9sentation.app > http://iihm.imag.fr/blanch/software/osx-presentation/ >=20 > _______________________________________________ > Pyobjc-dev mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev --Apple-Mail=_BF31A657-134F-4790-9EFD-5F64E15700B4 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; = -webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><div = class=3D"">Hi,</div><div class=3D""><br class=3D""></div><div = class=3D"">Sorry about the bad news, but=E2=80=A6</div><div class=3D""><br= class=3D""></div>The version of PyObjC shipped with macOS is ancient = and unsupported, and its framework bindings aren=E2=80=99t 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). = <div class=3D""><br class=3D""></div><div class=3D"">The only good = solution is to switch to a current version of PyObjC (and Python). = That should work and has tests for the bindings.<div class=3D""><br = class=3D""></div><div class=3D"">That said, it might be possible to use = the manual binding system implement the minimal set of metadata needed = for your script. I can=E2=80=99t recall which parts of that system = were implemented in the version of PyObjC that Apple = ships. </div><div class=3D""><div class=3D""><br = class=3D""></div><div class=3D"">Ronald<br class=3D""><div class=3D""> <div dir=3D"auto" style=3D"word-wrap: break-word; -webkit-nbsp-mode: = space; line-break: after-white-space;" class=3D""><div = style=3D"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: = Helvetica; font-size: 12px; font-style: normal; font-variant-caps: = normal; font-weight: normal; letter-spacing: normal; text-align: start; = text-indent: 0px; text-transform: none; white-space: normal; = word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: = none;">=E2=80=94</div><div style=3D"caret-color: rgb(0, 0, 0); color: = rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: = normal; font-variant-caps: normal; font-weight: normal; letter-spacing: = normal; text-align: start; text-indent: 0px; text-transform: none; = white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; = text-decoration: none;"><br class=3D""></div><div style=3D"caret-color: = rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: = 12px; font-style: normal; font-variant-caps: normal; font-weight: = normal; letter-spacing: normal; text-align: start; text-indent: 0px; = text-transform: none; white-space: normal; word-spacing: 0px; = -webkit-text-stroke-width: 0px; text-decoration: none;">Twitter / = micro.blog: @ronaldoussoren</div><div style=3D"caret-color: rgb(0, 0, = 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; = font-style: normal; font-variant-caps: normal; font-weight: normal; = letter-spacing: normal; text-align: start; text-indent: 0px; = text-transform: none; white-space: normal; word-spacing: 0px; = -webkit-text-stroke-width: 0px; text-decoration: none;">Blog: <a = href=3D"https://blog.ronaldoussoren.net/" = class=3D"">https://blog.ronaldoussoren.net/</a></div></div> </div> <div><br class=3D""><blockquote type=3D"cite" class=3D""><div = class=3D"">On 24 May 2020, at 12:09, <a href=3D"mailto:[email protected]" = class=3D"">[email protected]</a> wrote:</div><br = class=3D"Apple-interchange-newline"><div class=3D""><div = class=3D"">hello,<br class=3D""><br class=3D"">I use pyobjc bindings to = build an application that is distributed [0].<br class=3D"">Unfortunately,= I have to rely on the Apple provided versions of python/pyobjc = (2.7.16/2.5.1 on catalina).<br class=3D"">On Catalina, importing the = AVFoundation framework leads to a runtime warning (Error parsing = BridgeSupport data for AVFoundation), see below:<br class=3D""><br = class=3D""> %python <br class=3D""> = Python 2.7.16 (default, Feb 29 2020, 01:55:37) <br = class=3D""> [GCC 4.2.1 Compatible Apple LLVM 11.0.3 = (clang-1103.0.29.20) (-macos10.15-objc- on darwin<br class=3D""> = Type "help", "copyright", "credits" or "license" for = more information.<br class=3D""><blockquote type=3D"cite" = class=3D""><blockquote type=3D"cite" class=3D""><blockquote type=3D"cite" = class=3D"">import objc<br class=3D"">objc.__version__<br = class=3D""></blockquote></blockquote></blockquote> = '2.5.1'<br class=3D""><blockquote type=3D"cite" = class=3D""><blockquote type=3D"cite" class=3D""><blockquote type=3D"cite" = class=3D"">import AVFoundation<br = class=3D""></blockquote></blockquote></blockquote> = /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' ]}<br class=3D""> = warnings.warn("Error parsing BridgeSupport = data for %s: %s" % (frameworkName, e), RuntimeWarning)<br class=3D""><br = class=3D"">As a consequence, many things are not loaded properly.<br = class=3D"">For example constants are missing (I can fix that by = declaring the constants in my code).<br class=3D"">But I have a problem = that I could not manage to fix myself:<br class=3D"">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):<br = class=3D""><br class=3D""><blockquote type=3D"cite" class=3D""><blockquote= type=3D"cite" class=3D""><blockquote type=3D"cite" = class=3D"">AVMediaTypeVideo =3D "vide"<br class=3D"">from Foundation = import NSObject<br class=3D"">class Test(NSObject):<br = class=3D""></blockquote></blockquote></blockquote> ... = def test_(self, granted):<br class=3D""> = ... print(granted)<br = class=3D""> ... <br class=3D""><blockquote type=3D"cite"= class=3D""><blockquote type=3D"cite" class=3D""><blockquote type=3D"cite"= class=3D"">test =3D Test.alloc().init()<br = class=3D"">AVFoundation.AVCaptureDevice.requestAccessForMediaType_completi= onHandler_(<br class=3D""></blockquote></blockquote></blockquote> = ... AVMediaTypeVideo,<br class=3D""> = ... test.test_)<br class=3D""> = Traceback (most recent call last):<br class=3D""> = File "<stdin>", line 3, in = <module><br class=3D""> TypeError: Argument 3 is = a block, but no signature available<br class=3D""><br = class=3D""><blockquote type=3D"cite" class=3D""><blockquote type=3D"cite" = class=3D""><blockquote type=3D"cite" class=3D"">test.test_.signature<br = class=3D""></blockquote></blockquote></blockquote> = 'v@:@'<br class=3D""><blockquote type=3D"cite" = class=3D""><blockquote type=3D"cite" class=3D""><blockquote type=3D"cite" = class=3D"">AVFoundation.AVCaptureDevice.requestAccessForMediaType_completi= onHandler_.signature<br class=3D""></blockquote></blockquote></blockquote>= 'v32@0:8@16@?24'<br class=3D""><br class=3D"">Any = idea on how to fix this problem without altering the default = python/pyobjc installation?<br class=3D"">Thanks a lot for any = suggestion,<br class=3D""><br class=3D"">Renaud<br class=3D""><br = class=3D"">0. Pr=C3=A9sentation.app<br class=3D""><a = href=3D"http://iihm.imag.fr/blanch/software/osx-presentation/" = class=3D"">http://iihm.imag.fr/blanch/software/osx-presentation/</a><br = class=3D""><br = class=3D"">_______________________________________________<br = class=3D"">Pyobjc-dev mailing list<br = class=3D"">[email protected]<br = class=3D"">https://lists.sourceforge.net/lists/listinfo/pyobjc-dev<br = class=3D""></div></div></blockquote></div><br = class=3D""></div></div></div></body></html>= --Apple-Mail=_BF31A657-134F-4790-9EFD-5F64E15700B4-- --===============8279289276772715344== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============8279289276772715344== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Pyobjc-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pyobjc-dev --===============8279289276772715344==--