[Pythonmac-SIG] How to detect in a Cocoa app if Python is available?

Dinu Gherman gherman@darwin.in-berlin.de
Thu, 02 May 2002 10:00:38 +0200 (CEST)


I'm writing some Cocoa front-ends to Python apps and wonder what is 
the best way to detect if Python is available on a target OS X box? 
If not I'm popping up an Alert panel so you can download Python with
one click.

First I tried a popen() on "which python", but that runs into some
shell problems due to environment variables, I assume. So, for now 
I'm expicitly indicating "usr/local/bin/python" and make a C-popen()
on a bundled dummy Python file (using usr/local/bin/python) writing 
just "Hello World" which I compare the output of popen() with.

This is not really satisfactory and I wonder if anybody did better
than this? Note, that I'm using vanilla Python 2.2 built from the
sources with configure/make, so there is no Python.framework stuff
involved. I also wonder if this would this make things easier and 
how, if so?

I can send some C/Objective-C code if anybody is interested.