Re: NSXPCConnection not working in pyobjc

Ronald Oussoren via Pyobjc-dev <[email protected]> Wed, 25 Aug 2021 10:21:26 +0200
Newsgroups gmane.comp.python.pyobjc.devel
Message-ID <[email protected]>
--===============9162536498367419464==
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_39066B43-B4C4-4C05-B96B-3091025D1703"


--Apple-Mail=_39066B43-B4C4-4C05-B96B-3091025D1703
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8



> On 25 Aug 2021, at 09:01, Durgaprasad Kelkar <[email protected]> =
wrote:
>=20
> Thanks Ronald.
> I was using Python 2.7.18.

Don=E2=80=99t.  Python 2.7 is no longer support by the python =
developers, and is also no longer support by up-to-date releases of =
PyObjC.  Any fix for these problem won=E2=80=99t end up in a version of =
PyObjC that works with Python 2.7.


> After changing protocol_ext.m for Python2 and adding "{"use_protocol", =
use_protocol, METH_VARARGS, NULL}," in mod_methods I could use Protocol =
and attach to NSXPCInterface.
>=20
> Now I am having another issue with "NSXPCConnection".
> ValueError: NSInvalidArgumentException - [NSXPCConnection =
sendInvocation]: Block was not compiled using a compiler that inserts =
type information about arguments. (doSomething:withReply:)=20
>=20
> I could connect to the Security extension from my Objc C code. But =
from pyobjc sendInvocation fails. XCode and Xcode command line tools are =
installed on the machine.=20

That=E2=80=99s annoying. I=E2=80=99ll have to investigate further.=20

I don=E2=80=99t know when I=E2=80=99ll get around to doing that though, =
the first step is to create a complete example project with an =
extension. Only then I can start debugging this end to end, hopefully =
including a fix (although that=E2=80=99s far from sure given the issue =
with defining protocols).

It might be possible to use lower-level APIs to communicate with the =
extension, but that=E2=80=99s not something I=E2=80=99ve ever looked =
into.

Ronald
=20
>=20
>=20
> On Tue, Aug 24, 2021 at 12:22 PM Ronald Oussoren =
<[email protected] <mailto:[email protected]>> wrote:
>=20
>=20
>> On 23 Aug 2021, at 10:06, Durgaprasad Kelkar <[email protected] =
<mailto:[email protected]>> wrote:
>>=20
>> Hi Ronald,
>> Thanks a lot for quick response.=20
>> I don=E2=80=99t have any experience of writing C extension. I have =
started learning the same.=20
>> I found some blogs explaining this. They are writing .c files and =
then compiling with python setup.py install
>>=20
>> I can=E2=80=99t find any help to compile with Xcode clang compiler.
>> Can you please help me out. Any pointers or examples would be =
helpful.
>=20
> I=E2=80=99ve added a complete extension to the documentation =
(https://pyobjc.readthedocs.io/en/latest/notes/using-nsxpcinterface.html =
<https://pyobjc.readthedocs.io/en/latest/notes/using-nsxpcinterface.html>)=
.=20
>=20
> Use =E2=80=9Cpython setup.py install=E2=80=9D to build and install the =
C extension. This should work when either Xcode or the Xcode command =
line tools are installed.
>=20
> The example assumes that you only need definition in the core Cocoa =
frameworks (Foundation, AppKit), you may have to adjust the includes and =
link flags if you need definitions from other frameworks.
>=20
> Ronald
>=20
>>=20
>>=20
>> On Sat, 21 Aug 2021 at 3:33 PM, Ronald Oussoren =
<[email protected] <mailto:[email protected]>> wrote:
>> Sadly enough the issue is not fixed and cannot be fixed. I=E2=80=99ve =
described the workaround in =
<https://pyobjc.readthedocs.io/en/latest/notes/using-nsxpcinterface.html =
<https://pyobjc.readthedocs.io/en/latest/notes/using-nsxpcinterface.html>>=
, that description assumes you know how to write C extensions.
>>=20
>> I=E2=80=99ve closed the the issue at GitHub =
(https://github.com/ronaldoussoren/pyobjc/issues/256 =
<https://github.com/ronaldoussoren/pyobjc/issues/256>) as wontfix =
because there are no public APIs that can be used to register the =
=E2=80=9Cextended method signature=E2=80=9D information needed by =
NSXPCInterface.   I have filed an issue with Apple about this, but have =
little hope that this will accomplish anything. And even if my request =
is granted this would end up in macOS 13 at the earliest.
>>=20
>> Ronald
>>=20
>>> On 20 Aug 2021, at 11:43, Durgaprasad Kelkar <[email protected] =
<mailto:[email protected]>> wrote:
>>>=20
>>=20
>>> I am working on NSXPCConnection in Pyobjc.
>>> I could not create NSXPCInterface with a protocol.
>>> I referred =
https://stackoverflow.com/questions/52284089/is-it-possible-to-use-pyobjc-=
with-a-privilved-xpc-helper-tool-and-xpcinterface-a =
<https://stackoverflow.com/questions/52284089/is-it-possible-to-use-pyobjc=
-with-a-privilved-xpc-helper-tool-and-xpcinterface-a>.
>>> Links given in the answers are not working.
>>> Can you give latest links or code snippet for the same.
>>>=20
>>> Does issue =
https://bitbucket.org/ronaldoussoren/pyobjc/issues/256/enable-using-xpcint=
erface-with-protocols =
<https://bitbucket.org/ronaldoussoren/pyobjc/issues/256/enable-using-xpcin=
terface-with-protocols>. is fixed.
>>>=20
>>> Any help around this would be helpful.=20
>>=20
>>> _______________________________________________
>>> Pyobjc-dev mailing list
>>> [email protected] =
<mailto:[email protected]>
>>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev =
<https://lists.sourceforge.net/lists/listinfo/pyobjc-dev>
>>=20
>>=20
>> =E2=80=94
>>=20
>> Twitter / micro.blog: @ronaldoussoren
>> Blog: https://blog.ronaldoussoren.net/ =
<https://blog.ronaldoussoren.net/>
>=20
> =E2=80=94
>=20
> Twitter / micro.blog: @ronaldoussoren
> Blog: https://blog.ronaldoussoren.net/ =
<https://blog.ronaldoussoren.net/>
> <TestProtocol.zip>

=E2=80=94

Twitter / micro.blog: @ronaldoussoren
Blog: https://blog.ronaldoussoren.net/


--Apple-Mail=_39066B43-B4C4-4C05-B96B-3091025D1703
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""><br =
class=3D""><div><br class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D"">On 25 Aug 2021, at 09:01, Durgaprasad Kelkar &lt;<a =
href=3D"mailto:[email protected]" class=3D"">[email protected]</a>&gt; =
wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D""><div =
dir=3D"ltr" class=3D""><div class=3D"">Thanks&nbsp;Ronald.</div>I was =
using Python 2.7.18. </div></div></blockquote><div><br =
class=3D""></div>Don=E2=80=99t. &nbsp;Python 2.7 is no longer support by =
the python developers, and is also no longer support by up-to-date =
releases of PyObjC. &nbsp;Any fix for these problem won=E2=80=99t end up =
in a version of PyObjC that works with Python 2.7.<br class=3D""><div><br =
class=3D""></div><br class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D""><div dir=3D"ltr" class=3D"">After changing protocol_ext.m for =
Python2 and adding "{"use_protocol", use_protocol, METH_VARARGS, NULL}," =
in mod_methods I could use Protocol and attach to NSXPCInterface.<div =
class=3D""><br class=3D""></div><div class=3D"">Now I am having another =
issue with "<span style=3D"font-family: Menlo; font-size: 11px;" =
class=3D"">NSXPCConnection".</span></div><div class=3D""><span =
style=3D"font-family: Menlo; font-size: 11px;" class=3D"">ValueError: =
NSInvalidArgumentException - [NSXPCConnection sendInvocation]: Block was =
not compiled using a compiler that inserts type information about =
arguments. (doSomething:withReply:)</span>&nbsp;</div><div class=3D""><br =
class=3D""></div><div class=3D"">I could connect to the Security =
extension&nbsp;from my Objc C code. But from pyobjc sendInvocation =
fails. XCode and Xcode command line tools are installed on the =
machine.&nbsp;</div></div></div></blockquote><div><br =
class=3D""></div>That=E2=80=99s annoying. I=E2=80=99ll have to =
investigate further.&nbsp;</div><div><br class=3D""></div><div>I don=E2=80=
=99t know when I=E2=80=99ll get around to doing that though, the first =
step is to create a complete example project with an extension. Only =
then I can start debugging this end to end, hopefully including a fix =
(although that=E2=80=99s far from sure given the issue with defining =
protocols).</div><div><br class=3D""></div><div>It might be possible to =
use lower-level APIs to communicate with the extension, but that=E2=80=99s=
 not something I=E2=80=99ve ever looked into.</div><div><br =
class=3D""></div><div>Ronald</div><div>&nbsp;<br class=3D""><blockquote =
type=3D"cite" class=3D""><div class=3D""><div dir=3D"ltr" class=3D""><div =
class=3D""><br class=3D""></div></div><br class=3D""><div =
class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, Aug =
24, 2021 at 12:22 PM Ronald Oussoren &lt;<a =
href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a>&gt; wrote:<br =
class=3D""></div><blockquote class=3D"gmail_quote" style=3D"margin:0px =
0px 0px =
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(=
204,204,204);padding-left:1ex"><div =
style=3D"word-wrap:break-word;line-break:after-white-space" class=3D""><br=
 class=3D""><div class=3D""><br class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D"">On 23 Aug 2021, at 10:06, Durgaprasad Kelkar =
&lt;<a href=3D"mailto:[email protected]" target=3D"_blank" =
class=3D"">[email protected]</a>&gt; wrote:</div><br class=3D""><div =
class=3D""><div class=3D""><div dir=3D"auto" class=3D"">Hi =
Ronald,</div></div><div dir=3D"auto" class=3D"">Thanks a lot for quick =
response.&nbsp;</div><div dir=3D"auto" class=3D"">I don=E2=80=99t have =
any experience of writing C extension. I have started learning the =
same.&nbsp;</div><div dir=3D"auto" class=3D"">I found some blogs =
explaining this. They are writing .c files and then compiling with =
python setup.py install</div><div dir=3D"auto" class=3D""><br =
class=3D""></div><div dir=3D"auto" class=3D"">I can=E2=80=99t find any =
help to compile with Xcode clang compiler.</div><div dir=3D"auto" =
class=3D"">Can you please help me out. Any pointers or examples would be =
helpful.</div></div></blockquote><div class=3D""><br =
class=3D""></div>I=E2=80=99ve added a complete extension to the =
documentation (<a =
href=3D"https://pyobjc.readthedocs.io/en/latest/notes/using-nsxpcinterface=
.html" target=3D"_blank" =
class=3D"">https://pyobjc.readthedocs.io/en/latest/notes/using-nsxpcinterf=
ace.html</a>).&nbsp;</div><div class=3D""><br class=3D""></div><div =
class=3D"">Use =E2=80=9Cpython setup.py install=E2=80=9D to build and =
install the C extension. This should work when either Xcode or the Xcode =
command line tools are installed.</div><div class=3D""><br =
class=3D""></div><div class=3D"">The example assumes that you only need =
definition in the core Cocoa frameworks (Foundation, AppKit), you may =
have to adjust the includes and link flags if you need definitions from =
other frameworks.</div><div class=3D""><br class=3D""></div><div =
class=3D"">Ronald</div><div class=3D""><br class=3D""></div><div =
class=3D""><blockquote type=3D"cite" class=3D""><div class=3D""><div =
dir=3D"auto" class=3D""><br class=3D""></div><div class=3D""><br =
class=3D""><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"">On =
Sat, 21 Aug 2021 at 3:33 PM, Ronald Oussoren &lt;<a =
href=3D"mailto:[email protected]" target=3D"_blank" =
class=3D"">[email protected]</a>&gt; wrote:<br =
class=3D""></div><blockquote class=3D"gmail_quote" style=3D"margin:0px =
0px 0px =
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(=
204,204,204);padding-left:1ex"><div =
style=3D"word-wrap:break-word;line-break:after-white-space" =
class=3D"">Sadly enough the issue is not fixed and cannot be fixed. =
I=E2=80=99ve described the workaround in &lt;<font face=3D"-apple-system, =
BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color =
Emoji, Segoe UI Emoji" class=3D""><span =
style=3D"box-sizing:border-box;font-size:14px" class=3D""><a =
href=3D"https://pyobjc.readthedocs.io/en/latest/notes/using-nsxpcinterface=
.html" target=3D"_blank" =
class=3D"">https://pyobjc.readthedocs.io/en/latest/notes/using-nsxpcinterf=
ace.html</a></span></font>&gt;, that description assumes you know how to =
write C extensions.<div class=3D""><br class=3D""></div><div =
class=3D"">I=E2=80=99ve closed the the issue at GitHub (<a =
href=3D"https://github.com/ronaldoussoren/pyobjc/issues/256" =
target=3D"_blank" =
class=3D"">https://github.com/ronaldoussoren/pyobjc/issues/256</a>) as =
wontfix because there are no public APIs that can be used to register =
the =E2=80=9Cextended method signature=E2=80=9D information needed by =
NSXPCInterface. &nbsp; I have filed an issue with Apple about this, but =
have little hope that this will accomplish anything. And even if my =
request is granted this would end up in macOS 13 at the =
earliest.</div><div class=3D""><br class=3D""></div><div =
class=3D"">Ronald<br class=3D""><div class=3D""><br class=3D""><blockquote=
 type=3D"cite" class=3D""><div class=3D"">On 20 Aug 2021, at 11:43, =
Durgaprasad Kelkar &lt;<a href=3D"mailto:[email protected]" =
target=3D"_blank" class=3D"">[email protected]</a>&gt; wrote:</div><br =
class=3D""><div class=3D""></div></blockquote></div></div></div><div =
style=3D"word-wrap:break-word;line-break:after-white-space" =
class=3D""><div class=3D""><div class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D""><div dir=3D"auto" class=3D"">I am working on =
NSXPCConnection in Pyobjc.</div><div dir=3D"auto" class=3D"">I could not =
create NSXPCInterface with a protocol.</div><div dir=3D"auto" class=3D"">I=
 referred <a =
href=3D"https://stackoverflow.com/questions/52284089/is-it-possible-to-use=
-pyobjc-with-a-privilved-xpc-helper-tool-and-xpcinterface-a" =
target=3D"_blank" =
class=3D"">https://stackoverflow.com/questions/52284089/is-it-possible-to-=
use-pyobjc-with-a-privilved-xpc-helper-tool-and-xpcinterface-a</a>.</div><=
div dir=3D"auto" class=3D"">Links given in the answers are not =
working.</div><div dir=3D"auto" class=3D"">Can you give latest links or =
code snippet for the same.</div><div dir=3D"auto" class=3D""><br =
class=3D""></div><div dir=3D"auto" class=3D"">Does issue <a =
href=3D"https://bitbucket.org/ronaldoussoren/pyobjc/issues/256/enable-usin=
g-xpcinterface-with-protocols" target=3D"_blank" =
class=3D"">https://bitbucket.org/ronaldoussoren/pyobjc/issues/256/enable-u=
sing-xpcinterface-with-protocols</a>. is fixed.</div><div dir=3D"auto" =
class=3D""><br class=3D""></div><div dir=3D"auto" class=3D"">Any help =
around this would be =
helpful.&nbsp;</div></div></blockquote></div></div></div><div =
style=3D"word-wrap:break-word;line-break:after-white-space" =
class=3D""><div class=3D""><div class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D"">
_______________________________________________<br class=3D"">Pyobjc-dev =
mailing list<br class=3D""><a =
href=3D"mailto:[email protected]" target=3D"_blank" =
class=3D"">[email protected]</a><br class=3D""><a =
href=3D"https://lists.sourceforge.net/lists/listinfo/pyobjc-dev" =
target=3D"_blank" =
class=3D"">https://lists.sourceforge.net/lists/listinfo/pyobjc-dev</a><br =
class=3D""></div></blockquote></div></div></div><div =
style=3D"word-wrap:break-word;line-break:after-white-space" =
class=3D""><div class=3D""><br class=3D""><div class=3D"">
<div dir=3D"auto" =
style=3D"word-wrap:break-word;line-break:after-white-space" =
class=3D""><div =
style=3D"font-family:Helvetica;font-size:12px;font-style:normal;font-varia=
nt-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;t=
ext-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;tex=
t-decoration:none" class=3D"">=E2=80=94</div><div =
style=3D"font-family:Helvetica;font-size:12px;font-style:normal;font-varia=
nt-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;t=
ext-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;tex=
t-decoration:none" class=3D""><br class=3D""></div><div =
style=3D"font-family:Helvetica;font-size:12px;font-style:normal;font-varia=
nt-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;t=
ext-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;tex=
t-decoration:none" class=3D"">Twitter / micro.blog: =
@ronaldoussoren</div><div =
style=3D"font-family:Helvetica;font-size:12px;font-style:normal;font-varia=
nt-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;t=
ext-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;tex=
t-decoration:none" class=3D"">Blog: <a =
href=3D"https://blog.ronaldoussoren.net/" target=3D"_blank" =
class=3D"">https://blog.ronaldoussoren.net/</a></div></div>
</div>
<br class=3D""></div></div></blockquote></div></div>
</div></blockquote></div><br class=3D""><div class=3D"">
<div dir=3D"auto" =
style=3D"word-wrap:break-word;line-break:after-white-space" =
class=3D""><div style=3D"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; =
text-decoration: none;" class=3D"">=E2=80=94</div><div =
style=3D"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; text-decoration: none;" class=3D""><br =
class=3D""></div><div style=3D"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; =
text-decoration: none;" class=3D"">Twitter / micro.blog: =
@ronaldoussoren</div><div style=3D"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; =
text-decoration: none;" class=3D"">Blog: <a =
href=3D"https://blog.ronaldoussoren.net/" target=3D"_blank" =
class=3D"">https://blog.ronaldoussoren.net/</a></div></div>
</div>
<br class=3D""></div></blockquote></div>
<span =
id=3D"cid:f_ksr5bw8w0">&lt;TestProtocol.zip&gt;</span></div></blockquote><=
/div><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>
<br class=3D""></body></html>=

--Apple-Mail=_39066B43-B4C4-4C05-B96B-3091025D1703--


--===============9162536498367419464==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============9162536498367419464==
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

--===============9162536498367419464==--