[Pythonmac-SIG] Re: MacPython 2.3a2 on OSX 10.1

Just van Rossum just@letterror.com
Fri, 28 Feb 2003 16:48:58 +0100


John Ehresman wrote:

> It would be nice to support 10.1, particularly since 10.2 is not a
> free upgrade and some people never upgrade the OS after they buy
> their computer. 

If we were talking about a commercial application, then yes, it's a
sensible thing to do. So indeed it may make more sense to you than to me
and Jack...

> I wonder if the applets would work with a simple C
> program that ran argv[0].py. 

Should be possible, using execve(). Bill Bumgarner has written a small
ObjC program that does this, although it does a bit much to my taste:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/pyobjc/pyobjc/
Project%20Templates/Cocoa-Python%20Application/bin-python-main.m?rev=1.7

I'm not sure this program has ever been tested on 10.1 but it "should
work".

Or you can translate the Python bootstrap snippet to C:

BOOTSTRAP_SCRIPT = """\
#!%(hashbang)s

import sys, os
execdir = os.path.dirname(sys.argv[0])
executable = os.path.join(execdir, "%(executable)s")
resdir = os.path.join(os.path.dirname(execdir), "Resources")
mainprogram = os.path.join(resdir, "%(mainprogram)s")

sys.argv.insert(1, mainprogram)
os.environ["PYTHONPATH"] = resdir
os.environ["PYTHONEXECUTABLE"] = executable
os.execve(executable, sys.argv, os.environ)
"""

Note that it's parametrized (sp?), which would be a little harder to do
with a C program...

> If someone can point me to an applet
> example, I'd be willing to try this out.

Check out bundlebuilder.py; with it you can build an applet from
anything. Or BuildApplet.py, which uses buildtools.py which uses
bundlebuilder.py.

Just