[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to package a Python module with shared libraries ?



Hi

On Sun, Apr 25, 2010 at 02:10:12PM +0200, Sylvestre Ledru wrote:
> * All Scilab libraries are stored in /usr/lib/scilab/
> 
> * cdll.LoadLibrary("/usr/lib/scilab/libscilab.so") will fails
> since /usr/lib/scilab is not in the search path for libraries
> 
> * setting thhe LD_LIBRARY_PATH into Python does not fix things since it
> seems it is only used on startup
> os.environ["LD_LIBRARY_PATH"]="/usr/lib/scilab/" 

No, that won't work.  As you noted below you need this set in the
environment which the dynamic linker will see, which is the one you
give when you start python in this case.

> * I don't want load explicitly all Scilab libraries (there are a few)
> 
> * Calling python the following way make things work:
> LD_LIBRARY_PATH=/usr/lib/scilab python 
> but I want to avoid the user to have to do manipulations

You could try setting RUNPATH/RPATH into the extension module.  If
it's using distutils you can use --rpath to setup.py build_ext, see
the --help of the build_ext sub-command.

Do note that using RUNPATH/RPATH is normally a bad idea, but given how
scilab is packaged that seems to be the only way to do this (this may
or may not be a bug in the scilab packaging).  Note that
/usr/bin/scilab itself is a shell script which will add set
LD_LIBRARY_PATH to /usr/lib/scilab before calling the real scilab
binary, so it would at least be no worse then the scilab package does.

In any case, do a search for "RPATH considered harmful" or
"LD_LIBRARY_PATH considered harmful" so that you get an idea of the
implications and troubles.  The library packaging guide
(http://www.netfort.gr.jp/~dancer/column/libpkg-guide/libpkg-guide.txt)
contains a short section on it too.


Regards
Floris

-- 
Debian GNU/Linux -- The Power of Freedom
www.debian.org | www.gnu.org | www.kernel.org


Reply to: