Bundling Python extensions that depend on C libraries

Bert Freudenberg bert at freudenbergs.de
Sat Dec 8 03:59:54 EST 2007


On Dec 8, 2007, at 1:15 , Asheesh Laroia wrote:

> I'd like to bundle a Python C extension and use it from my  
> activity.  This
> requires Python to dlopen() a shared library whose path can change
> depending on where the activity is installed, but also whose path is
> different than on my desktop where I built the .xo.
>
> Initially I tried to set os['LD_LIBRARY_PATH'] from within Python,  
> but I
> learned this would not affect the running application
> <http://hathawaymix.org/Weblog/2004-12-30>.
>
> In the Log Viewer, I read:
>
> <type 'exceptions.ImportError'>: liblicense.so.0: cannot open shared
> object file: No such file or directory
>
> I tried changing my activity.info to read, in part (all on one line):
>
> exec = LD_LIBRARY_PATH=/home/olpc/Activities/License.activity/built/ 
> lib
> sugar-activity ccactivity.LicensingActivity -s
>
> but the error persisted.
>
> I know this is a sort of strange thing to do, but what's a  
> reasonable way
> to do it?  Thanks, as always!

Not strange at all. I argued before that Sugar should in fact set  
LD_LIBRARY_PATH before executing an activity:

http://lists.laptop.org/pipermail/sugar/2007-November/003883.html

But that would not help you for already shipped versions of Sugar.

What should work is that you run a simple script in the exec line.  
Put that in bin/ of your bundle:

#!/bin/sh
export LD_LIBRARY_PATH="$SUGAR_BUNDLE_PATH/lib"
exec sugar-activity ...

- Bert -





More information about the Devel mailing list