I have compiled my boost-enabled C++ module and have it working when I
explicity set my LD_LIBRARY_PATH before invoking the python2.4
interpreter. Now I don't want everyone to have to set this environment
variable so I would like to devise a way that the module can load
itself. My attempt was to create a module folder with the following
__init__.py:
-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
import os
import sys
my_path = os.path.dirname(os.path.abspath(__file__))
mylib_path = os.path.join(my_path, 'subdirOfSitePackages')
if sys.platform == 'win32':
# Windows needs DLLs on the %PATH%.
os.environ['PATH'] = os.environ['PATH'] + ";" + my_path
else:
# LINUX
if os.environ.has_key('LD_LIBRARY_PATH'):
os.environ['LD_LIBRARY_PATH'] = mylib_path + ":" +
os.environ['LD_LIBRARY_PATH']
else:
os.environ['LD_LIBRARY_PATH'] = mylib_path
from myLibFolder._mylib import *
-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
On my filesystem I have the following folder:
/usr/lib/python2.4/site-packages/myLibFolder
With the following files:
__init__.py
_mylib.so
mylibDBAccess.so
mylibCommon.so
libboost_python.so
Where _mylib.so dynamically links with mylibDBAccess.so,
mylibCommon.so, libboost_python.so.
When I try to import this Folder in python2.4, it actually complains
about the subsequent dynamic linking of the .so files (ie
mylibDBAccess.so).
Any ideas on how to resolve this?
Regards,
Liam
--
http://mail.python.org/mailman/listinfo/python-list