[Stackless] Stackless application distribution with OS X

Jeff Senn senn at maya.com
Fri Apr 18 14:44:32 CEST 2008

Good advice!

Also if you *do* happen to want to install over the /Library/ 
version -- and then later "install" that into an app (so you can
give it to your friends w/o also overriding their system framework),
you don't need to build another version.  Just copy the
into your app and use 'otool  and 'install_name_tool' to do some
surgery on the load paths e.g. I use a script like:

import os,popen2
def fixup_framework(fw, old_path_prefix, new_path_prefix):
   f = os.popen('otool -L "%s"'%(fw,))
   x = f.read().split('\n')[1:]
   for l in x:
     if l.startswith('\t' + old_path_prefix):
       ol = l[1:].split(' ')[0]
       nw = new_path_prefix + ol[len(old_path_prefix):]
       print "Changing: '%s' to '%s'" %(ol,nw)
       os.system('install_name_tool -change "%s" "%s" "%s"' %(ol,nw,fw))


You'll of course need to find all the libs that have rooted references
-- that too could be automated (left as an exercise to the reader :-) )

This can work with most any properly constructed Framework so
I suppose this is general purpose OS-X advice rather than
Python or Stackless specific....  ah well... I'm sure that Google
will find this thread to cure someone's problem... :-)


On Apr 18, 2008, at 6:52 AM, Ásgeir Bjarni Ingvarsson wrote:

> Just in case I'm not the only OS X user here that this wasn't obvious
> to, here is a small bash script I used to build a private framework  
> for
> Stackless.
> This means that the Python.framework can reside under
> MyApplication.app/Contents/Frameworks and will not clobber the end
> user's python distribution. Allowing distribution of applications that
> use stackless, along with any extra library modules, as a single .app
> bundle and not as a package with an installer.
> You may need to check if there are extra newlines, created by my e- 
> mail
> program, that change the script.
> #!/bin/bash
> # BEGIN build_stackless_private_framework.sh
> SVNPTH=http://svn.python.org/projects/stackless/branches/release25-maint
> svn co $SVNPTH stackless
> cd stackless
> ./configure --enable-stacklessfewerregisters --enable-universalsdk \
> --enable-framework=@executable_path/../Frameworks
> make -j 2
> make install DESTDIR=`pwd`/staging/
> cd staging/Frameworks
> tar -czf stackless_private_framework.tar.gz Python.framework
> mv stackless_private_framework.tar.gz ../../..
> cd ../../..
> # END build_stackless_private_framework.sh
> Any Cocoa or Carbon application can now be made to use this new
> framework. You will need to create a build phase to copy
> Python.framework into the application bundle under
> YourApp.app/Contents/Frameworks
> I find it convenient to first create a Carbon application that is  
> simply
> a wrapper around the Py_Main function and give it a symlink to the
> framework so I can build any needed binary modules using setuptools.
> // Begin main.c
> #include <Python/Python.h>
> int main(int argc, char *argv[])
> {
>     return Py_Main(argc, argv);
> }
> // End main.c
> xcodebuild
> mkdir -p build/Release/StacklessInterpreter.app/Contents/Frameworks
> ln -s `pwd`/Python.framework \
> build/Release/StacklessInterpreter.app/Contents/Frameworks
> cd somemodule
> ../build/Release/StacklessInterpreter.app/MacOS/StacklessInterpreter \
> setup.py
> _______________________________________________
> Stackless mailing list
> Stackless at stackless.com
> http://www.stackless.com/mailman/listinfo/stackless

More information about the Stackless mailing list