Skip navigation.
 
mlRe: python scripting support
FROM : has
DATE : Sun May 18 11:56:42 2008

John C. Daub wrote:

> 1. Scripting bridge is only available (as an OS built-in) in Mac OS 
> X 10.5 and later. If your need to support prior OS versions, you may 
> need to do some additional work with PyObjC to get things available 
> with Python. I'm not sure what that would entail exactly, just 
> pointing out that Scripting Bridge is 10.5 and later.



While I don't have numbers, my impression is that appscript remains 
pretty much the de-facto standard for scripting applications from 
Python. It supports 10.3.9 and later, is much better designed and more 
reliable than SB, and provides a much nicer native API. Better 
documentation and dev tools too. Requires separate user installation, 
but that's easy to do.


> 2. If you are going to embed Python in your app, you're going to 
> risk issues with the system. For instance, in one of the apps I 
> write I embed Python. We built it back when Tiger was the OS and so 
> we built against Python 2.3.5, since that's what was in the 10.4 OS 
> SDK. We are able to have our app run on Leopard because while Apple 
> did update the built-in Python.framework to use Python 2.5.1, they 
> did ship a minimal runtime of 2.3.



IIRC the problem here is that Python 2.3 isn't officially supported on 
Leopard - it's several years old now and no longer maintained beyond 
critical security fixes. So it goes. I'd suggest updating your app to 
use 2.5.x, or even 2.6 if you wait a few more months.


> Apple's suggestion is basically to make your own Python.framework, 
> embed it within your app, and use that. IMHO that's not ideal but 
> what else can you do?


You can get a prebuilt framework build from python.org, and embedding 
it in your application bundle is trivial. It will add a few MB to your 
application's file size, but unless you're distributing over dialup 
that's really a non-issue. Only significant issue is supporting third-
party modules (how to install them, where to put them), but the 
PythonMac-SIG folks will be the best ones to advise on that.


> I think the advantage of the AppleScript route is that AppleScript 
> is kinda the native scripting language of the OS.



Only inasmuch as AppleScript currently remains the most popular choice 
for application scripting, but that's due more to inertia than merit. 
I think Python, Ruby, bash, etc. will be more popular overall.

For most purposes, I'd be inclined towards going the Cocoa Scripting 
route, despite its faults, but there are some situations where an 
embedded interpreter would be a better choice (e.g. if performance is 
an issue). Again, if the author wants specific recommendations, he'll 
need to provide more information on what the application does and how 
scripters will use it.

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

Related mailsAuthorDate
mlpython scripting support Georg Seifert May 17, 17:16
mlRe: python scripting support has May 17, 23:12
mlRe: python scripting support John C. Daub May 17, 23:47
mlRe: python scripting support has May 18, 11:56
mlRe: python scripting support John C. Daub May 18, 13:06
mlRe: python scripting support Georg Seifert May 18, 13:56
mlRe: python scripting support has May 18, 22:47
mlRe: python scripting support John C. Daub May 19, 00:34