Re: [Pythonmac-SIG] [ANN] PyObjC 5.0

Ronald Oussoren via Pyobjc-dev <[email protected]> Sun, 23 Sep 2018 12:00:53 +0200
Newsgroups gmane.comp.python.pyobjc.devel,gmane.comp.python.apple
Message-ID <[email protected]>
--===============6512101562315522018==
Content-type: multipart/alternative;
 boundary="Apple-Mail=_EBA0AD6A-C505-4D6E-A4F7-AEE0CECD4CE0"


--Apple-Mail=_EBA0AD6A-C505-4D6E-A4F7-AEE0CECD4CE0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8



> On 21 Sep 2018, at 23:24, Glyph <[email protected]> wrote:
>=20
>=20
>=20
>> On Sep 21, 2018, at 4:50 AM, Ronald Oussoren <[email protected] =
<mailto:[email protected]>> wrote:
>>=20
>>=20
>>=20
>>> On 21 Sep 2018, at 05:59, Glyph <[email protected] =
<mailto:[email protected]>> wrote:
>>>=20
>>> On Sep 18, 2018, at 1:22 PM, Ronald Oussoren via Pythonmac-SIG =
<[email protected] <mailto:[email protected]>> wrote:
>>>>=20
>>>> PyObjC 5.0 is out
>>>=20
>>> Thanks again for your tireless (or at least apparently tireless) =
maintenance, Ronald!
>>>=20
>>>> * Added bindings for the =E2=80=9CCarbonCore=E2=80=9D subframework =
of the =E2=80=9CCoreServices=E2=80=9D framework.
>>>>=20
>>>> Most APIs in this subframework are not available to Python, only =
those APIs that are not deprecated and seem interesting are exposed.
>>>=20
>>> One thing I wondered about when I saw "carbon" here is that I wonder =
if the APIs that could make =
https://pythonhosted.org/pyobjc/examples/Cocoa/AppKit/HotKeyPython/index.h=
tml =
<https://pythonhosted.org/pyobjc/examples/Cocoa/AppKit/HotKeyPython/index.=
html> are exposed again? =20
>>=20
>> The API used in that example is not exposed through PyObjC at this =
time (AFAIK it is part of =E2=80=9CCarbon.framework=E2=80=9D, not the =
CarbonCore sub framework of =E2=80=9CCoreServices.framework=E2=80=9D.=20
>>=20
>> I=E2=80=99m open to adding bindings to interesting APIs, but note =
that =E2=80=9CRegisterEventHotKey=E2=80=9D is not documented on =
Apple=E2=80=99s website and might not be the right solution for modern =
code. I don=E2=80=99t know yet what the right solution is though (a =
number of APIs that are exposed through PyObjC can be used to implement =
similar functionality).
>=20
> If there were a more modern solution I'd gladly use it rather than =
asking you to expose gross and ancient Carbon APIs :).  Which APIs that =
are already exposed can do this?

Good question :-).  I thought CGEventTapCreate and related APIs could be =
used for this, but now that I=E2=80=99ve reread the documentation I no =
longer think so. MASShortCut still uses the Carbon APIs in its =
implementation, which seems to confirm that there is no good modern =
alternative for the RegisterEventHotKey API.

>=20
>>> The cautions that the relevant Carbon APIs require 32-bit mode are =
inaccurate; =
https://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.htm=
l =
<https://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.ht=
ml> explains that they're still supported in sandboxed Mac App Store =
apps, so they're just poorly documented, not deprecated.  (It seems that =
there's never been a proper Cocoa replacement for this functionality, =
just a couple of popular wrappers floating around out there=E2=80=A6)
>>>=20
>>> This is something I have wanted to do in Python many times, but =
never quite badly enough to figure out all the build gymnastics required =
to get the bindings for https://github.com/shpakovski/MASShortcut =
<https://github.com/shpakovski/MASShortcut> built and bundled with my =
application.
>>=20
>> I=E2=80=99ll look into exposing this API for PyObjC 5.1, even if that =
means adding a very limited set of bindings for Carbon.framework.
>=20
> Thanks!
>=20
>>> -glyph
>>>=20
>>> P.S.: speaking of build gymnastics, does anyone on this list happen =
to have a way to use CocoaPods or something similar to pull in open =
source Cocoa frameworks to a PyObjC application?
>>=20
>> I haven=E2=80=99t looked into this yet.  I guess the hardest part is =
creating the metadata for constants and pointer arguments. Could you =
file and issue for this?=20
>=20
> Sure, sometime this weekend I'll try to write it up.

I have created an experimental binding to MASShortcut on my bitbucket =
account: https://bitbucket.org/ronaldoussoren/pyobjc-masshortcut =
<https://bitbucket.org/ronaldoussoren/pyobjc-masshortcut>. This library =
can be installed using =E2=80=9Cpip install pyobjc-MASShortcut=3D=3D1.0a0=E2=
=80=9D (and has a wheel if you use a 64-bit installation of Python 3.7)

This =E2=80=9Cworks=E2=80=9D in the sense that I ran my unit tests with =
Python 3.6 (64-bit), but I have done no testing beyond that.

Creating the bindings was fairly easy, but harder than it should be =
because the tooling I use to create bindings is primarily created for =
Apple=E2=80=99s system frameworks and has some issues with 3th-party =
frameworks. I do want to improve the tooling for this, but don=E2=80=99t =
know when I=E2=80=99ll get around to actually doing this.

Ronald=

--Apple-Mail=_EBA0AD6A-C505-4D6E-A4F7-AEE0CECD4CE0
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 21 Sep 2018, at 23:24, Glyph &lt;<a =
href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a>&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><meta =
http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8" =
class=3D""><div style=3D"word-wrap: break-word; -webkit-nbsp-mode: =
space; 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 Sep 21, 2018, at 4:50 AM, Ronald Oussoren &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 =
style=3D"caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; =
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;" class=3D""><br class=3D"Apple-interchange-newline"><br =
class=3D""><blockquote type=3D"cite" class=3D""><div class=3D"">On 21 =
Sep 2018, at 05:59, Glyph &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 class=3D"" =
style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; line-break: =
after-white-space;"><div class=3D"">On Sep 18, 2018, at 1:22 PM, Ronald =
Oussoren via Pythonmac-SIG &lt;<a href=3D"mailto:[email protected]"=
 class=3D"">[email protected]</a>&gt; wrote:</div><div =
class=3D""><blockquote type=3D"cite" class=3D""><br class=3D""><div =
class=3D""><div class=3D"" style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;"><b =
class=3D"">PyObjC 5.0 is out</b><br =
class=3D""></div></div></blockquote><div class=3D""><br =
class=3D""></div><div class=3D"">Thanks again for your tireless (or at =
least apparently tireless) maintenance, Ronald!</div><br =
class=3D""><blockquote type=3D"cite" class=3D""><div class=3D""><div =
class=3D"" style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
line-break: after-white-space;"><div class=3D""><div class=3D""><div =
class=3D"">* Added bindings for the =E2=80=9CCarbonCore=E2=80=9D =
subframework of the =E2=80=9CCoreServices=E2=80=9D&nbsp;framework.</div><d=
iv class=3D""><br class=3D""></div><div class=3D"">Most APIs in this =
subframework are not available to Python, only those APIs that&nbsp;are =
not deprecated and seem interesting are exposed.<br =
class=3D""></div></div></div></div></div></blockquote><div class=3D""><br =
class=3D""></div><div class=3D"">One thing I wondered about when I saw =
"carbon" here is that I wonder if the APIs that could make&nbsp;<a =
href=3D"https://pythonhosted.org/pyobjc/examples/Cocoa/AppKit/HotKeyPython=
/index.html" =
class=3D"">https://pythonhosted.org/pyobjc/examples/Cocoa/AppKit/HotKeyPyt=
hon/index.html</a>&nbsp;are exposed again? =
&nbsp;</div></div></div></div></blockquote><div class=3D""><br =
class=3D""></div><div class=3D"">The API used in that example is not =
exposed through PyObjC at this time (AFAIK it is part of =
=E2=80=9CCarbon.framework=E2=80=9D, not the CarbonCore sub framework of =
=E2=80=9CCoreServices.framework=E2=80=9D.&nbsp;</div><div class=3D""><br =
class=3D""></div><div class=3D"">I=E2=80=99m open to adding bindings to =
interesting APIs, but note that =E2=80=9C<span class=3D"" =
style=3D"background-color: rgb(255, 255, 255);"><font color=3D"#222222" =
class=3D""><span class=3D"" style=3D"font-size: =
1.1em;">RegisterEventHotKey</span></font><font color=3D"#222222" =
size=3D"2" class=3D""><span class=3D"" style=3D"caret-color: rgb(34, 34, =
34);">=E2=80=9D</span></font><font color=3D"#222222" class=3D""><span =
class=3D"" style=3D"font-size: 1.1em;">&nbsp;is not documented on =
Apple</span><font size=3D"2" class=3D"">=E2=80=99</font><span class=3D"" =
style=3D"font-size: 1.1em;">s website and might not be the right =
solution for modern code. I don</span><font size=3D"2" =
class=3D"">=E2=80=99</font><span class=3D"" style=3D"font-size: =
1.1em;">t know yet what the right solution is though (a number of APIs =
that are exposed through PyObjC can be used to =
implement&nbsp;</span><font size=3D"2" class=3D"">similar</font><span =
class=3D"" style=3D"font-size: =
1.1em;">&nbsp;functionality).</span></font></span></div></div></div></bloc=
kquote><div class=3D""><br class=3D""></div><div class=3D"">If there =
were a more modern solution I'd gladly use it rather than asking you to =
expose gross and ancient Carbon APIs :). &nbsp;Which APIs that are =
already exposed can do =
this?</div></div></div></div></blockquote><div><br =
class=3D""></div><div>Good question :-). &nbsp;I thought =
CGEventTapCreate and related APIs could be used for this, but now that =
I=E2=80=99ve reread the documentation I no longer think so. MASShortCut =
still uses the Carbon APIs in its implementation, which seems to confirm =
that there is no good modern alternative for the RegisterEventHotKey =
API.</div><div><br class=3D""></div><blockquote type=3D"cite" =
class=3D""><div class=3D""><div style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><div =
class=3D""><br class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D""><div style=3D"caret-color: rgb(0, 0, 0); font-family: =
Menlo-Regular; 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;" class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D""><div class=3D"" style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;"><div =
class=3D""><div class=3D"">The cautions that the relevant Carbon APIs =
require 32-bit mode are inaccurate;&nbsp;<a =
href=3D"https://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-c=
ocoa.html" =
class=3D"">https://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-i=
n-cocoa.html</a>&nbsp;explains that they're still supported in sandboxed =
Mac App Store apps, so they're just poorly documented, not deprecated. =
&nbsp;(It seems that there's never been a proper Cocoa replacement for =
this functionality, just a couple of popular wrappers floating around =
out there=E2=80=A6)</div></div></div></div></blockquote><blockquote =
type=3D"cite" class=3D""><div class=3D""><div class=3D"" =
style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; line-break: =
after-white-space;"><div class=3D""><div class=3D""><br =
class=3D""></div><div class=3D"">This is something I have wanted to do =
in Python many times, but never quite badly enough to figure out all the =
build gymnastics required to get the bindings for&nbsp;<a =
href=3D"https://github.com/shpakovski/MASShortcut" =
class=3D"">https://github.com/shpakovski/MASShortcut</a>&nbsp;built and =
bundled with my application.</div></div></div></div></blockquote><div =
class=3D""><br class=3D""></div>I=E2=80=99ll look into exposing this API =
for PyObjC 5.1, even if that means adding a very limited set of bindings =
for Carbon.framework.</div></div></blockquote><div class=3D""><br =
class=3D""></div><div class=3D"">Thanks!</div><br class=3D""><blockquote =
type=3D"cite" class=3D""><div style=3D"caret-color: rgb(0, 0, 0); =
font-family: Menlo-Regular; 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;" class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D""><div class=3D"" style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; line-break: =
after-white-space;"><div class=3D""><div class=3D"">-glyph</div><div =
class=3D""><br class=3D""></div><div class=3D"">P.S.: speaking of build =
gymnastics, does anyone on this list happen to have a way to use =
CocoaPods or something similar to pull in open source Cocoa frameworks =
to a PyObjC application?</div></div></div></div></blockquote></div><br =
class=3D"" style=3D"caret-color: rgb(0, 0, 0); font-family: =
Menlo-Regular; 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;"><div class=3D"" style=3D"caret-color: rgb(0, 0, 0); font-family: =
Menlo-Regular; 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;">I haven=E2=80=99t looked into this yet. &nbsp;I guess the hardest =
part is creating the metadata for constants and pointer arguments. Could =
you file and issue for this?&nbsp;</div></blockquote><br =
class=3D""></div><div class=3D"">Sure, sometime this weekend I'll try to =
write it up.</div></div></div></blockquote><div><br =
class=3D""></div><div>I have created an experimental binding to =
MASShortcut on my bitbucket account:&nbsp;<a =
href=3D"https://bitbucket.org/ronaldoussoren/pyobjc-masshortcut" =
class=3D"">https://bitbucket.org/ronaldoussoren/pyobjc-masshortcut</a>. =
This library can be installed using =E2=80=9Cpip install =
pyobjc-MASShortcut=3D=3D1.0a0=E2=80=9D (and has a wheel if you use a =
64-bit installation of Python 3.7)</div><div><br =
class=3D""></div><div>This =E2=80=9Cworks=E2=80=9D in the sense that I =
ran my unit tests with Python 3.6 (64-bit), but I have done no testing =
beyond that.</div><div><br class=3D""></div><div>Creating the bindings =
was fairly easy, but harder than it should be because the tooling I use =
to create bindings is primarily created for Apple=E2=80=99s system =
frameworks and has some issues with 3th-party frameworks. I do want to =
improve the tooling for this, but don=E2=80=99t know when I=E2=80=99ll =
get around to actually doing this.</div><div><br =
class=3D""></div><div>Ronald</div></div></body></html>=

--Apple-Mail=_EBA0AD6A-C505-4D6E-A4F7-AEE0CECD4CE0--


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


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

--===============6512101562315522018==--