[Pythonmac-SIG] Should Python.app be an LSUIElement = 1 app?

Ronald Oussoren ronaldoussoren at mac.com
Tue Feb 3 19:24:03 CET 2009


On 3 Feb, 2009, at 18:55, Bill Janssen wrote:

> Ronald Oussoren <ronaldoussoren at mac.com> wrote:
>
>>
>> On 3 Feb, 2009, at 17:54, Bill Janssen wrote:
>>>
>>>> I'm seriously wondering if having "Python Launcher.app" is a good
>>>> idea, and if we shouldn't scrap it entirely. If building full app
>>>> bundles using py2app is too much of a burden we could look into
>>>> providing an easier and more lightweight way to build such bundles.
>>>> The fully standalone bundles that py2app creates are very useful,  
>>>> but
>>>> I definitely see the need for very thin .app bundles as well.
>>>
>>> Interesting idea.  What's the lightest thing that's an app, anyway?
>>>
>>
>> AFAIK an executable + Info.plist + icon file (plus the right  
>> directory
>> structure). The executable can be shell-script on Leopard, but a
>> simple executable would IMHO be better.  One way to structure such an
>> executable is to read the name of the actual script to execute from
>> the Info.plist (using a custom key) and then use the standard Python
>> C-
>> API to execute that script.
>
> So you'd have a little custom launcher that would read that key and  
> use
> the Python C API -- sort of the way that Java apps use the
> JavaApplicationStub.  Doesn't actually have to be a C program, you  
> know;
> it could be a shell script:
>
>  #!/usr/bin/python
>  import plistlib, os
>  script = os.path.normpath(plistlib.readPlist('../Info.plist') 
> ['ApplicationPythonScript'])
>  os.execv(['/usr/bin/python', script])
>
> I didn't test that!

Not quite, you must ensure that the C-level argv[0] points to a  
location inside the app bundle, otherwise the system won't know you're  
supposed to be an executable. Getting that right is possible (just  
copy the python executable into the bundle as well), but just writing  
a small stub executable is not too hard and avoids issues like <http://bugs.python.org/issue5143 
 >.

Ronald
>
>
> Bill

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2224 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pythonmac-sig/attachments/20090203/e975574a/attachment.bin>


More information about the Pythonmac-SIG mailing list