progress with bundled C libraries

Owen Williams owen at ywwg.com
Sun Nov 5 20:15:21 EST 2006


I think I've solved the problem of bundled libraries on OLPC.

Summary of problem:
Activities are expected to bundle their own libraries, but activities
can't know where they will be installed.  Also, activities never have a
chance to set LD_LIBRARY_PATH, so how can they link to their libraries?

Solution:
Set up a relative RPATH inside the python modules that link to the C
libraries.


For instance, I use the pycurl library which is a python module that
links to the C library libcurl.  I can append to sys.path to tell python
where pycurl is, but I can't do something similar with libcurl.

However, If I compile pycurl and set runtime_library_dirs=['./lib'], and
then os.chdir to my activity directory on load, the libraries link up
and everyone's happy.  I don't have a complete working bundle, but
initial tests are promising.

In my PenguinTVActivity module, I do this:
try:
 #try the import because hey, it might work
 import pycurl 
except:
 #yeah, well, what did we expect
 logging.warning("Trying to load bundled pycurl libraries")
	
 #import ourselves
 import PenguinTVActivity
 
 #where the hell are we? 
 activity_root = os.path.split(PenguinTVActivity.__file__)[0] 
 
 #change to that folder, so that RPATH="./lib" will work
 os.chdir(activity_root)
 
 #also append to sys.path so modules load
 sys.path.append(os.path.join(activity_root, 'site-packages'))
 
 #try again.  if it fails this time, it fails.
 import pycurl 

I'm downloading FC6 now to install in a vmware image, so tomorrow I
should be able to build my own modules and test this for sure.

Owen




More information about the Devel mailing list