[sugar] penguintv development update: bundled .so libraries

Owen Williams owen
Sun Nov 5 10:55:24 EST 2006

Today I got penguintv working with the new bundle spec.  I learned a lot
that isn't on the wiki, so I've updated the wiki with some details about
exact path locations, convenience functions, and unimplemented features.

One of the big hand-waving bits of sugar development has been including
prebuilt c libraries and python libraries in activity bundles.  But the
question is, how to do this?  And moreover, how to do this on a non-FC6

As a developer on Ubuntu, I've had a lot of trouble trying to emulate
the OLPC for testing.  qemu and VMware are both broken for Ubuntu Edgy,
and the livecds don't work.  I ended up using the -tree builds on
http://olpc.download.redhat.com/olpc/streams/development/.  These
contain chroot-friendly trees of the current olpc build that allowed me
to test my bundled libraries against the FC6 tree.

Basically my workflow was this:
1. copy my current activity bundle into the tree in /opt
2. create /opt/my.activity/lib and /opt/my.activity/site-packages
3. export LD_LIBRARY_PATH and PYTHONPATH to include those new folders
4. try to run the software
5. note which module fails to load
6.if I can work around it:
6a. work around it, often with this pattern:

 import SomeModule


It's almost like #ifdef!

7. if I can't work around it: 
7.a find the rpm for FC6 that would satisfy that dependency
7.b extract it in a temp dir with  rpm2cpio file.rpm | cpio -idmv
7.c copy the .so files into my lib/ folder, and any python .so's into my
site-packages folder.
8. Then I rerun the program and see if it works.
9. Repeat until it runs.

So then in my activity file I have to set up the environment so that my
libs and site-packages are included.  Unfortunately I only know how to
tell python where other python objects are:  appending to sys.path.  I
have no idea how to tell ld where the new libs are.  This is a major
sticking point, and I'm hoping someone out there can help.

Since I can't assume the package is installed anywhere in particular, I
have to go by the __file__ property of my activity:

import PenguinTVActivity
activity_root = os.path.split(PenguinTVActivity.__file__)[0]
sys.path.append(os.path.join(activity_root, 'site-packages'))
#sys.magic_command.append_to_ld_library_path_at_runtime(os.path.join(activity_root, 'lib'))

import penguintv
app = penguintv.PenguinTVApp()

So I'm almost there. I just need a solution to runtime linking of the c
shared object files that the python modules need. 

Owen Williams

More information about the Sugar-devel mailing list