473,327 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Problem Dynamic Loading Linux C++ .so module using python2.4

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

Apr 10 '06 #1
1 1963
On 10 Apr 2006 12:42:28 -0700, liam_herron <li*********@hotmail.com> wrote:
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?
I think you can not. I can not find the article, but I read that changes of
LD_LIBRARY_PATH after program start, does not have any effects, because this
variable is read only once - at program launching.

I think small shell script will help you.
Regards,
Liam

--
http://mail.python.org/mailman/listinfo/python-list

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
Apr 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jose Vicente Nunez Z | last post by:
Greetings, I wrote a couple of custom dummy extensions in Python (one a pure Python and the other a C) and i managed to compile and install them without a problem: $ make python2 setup.py...
2
by: baileyxia | last post by:
Hi, all I am learning how to import c code in python. Here is my simple code foo.c: ===================== #include <Python.h> void bar() { printf("Hello! C wrap!"); } static PyObject...
2
by: venkatbo | last post by:
Hi all, I have python2.4 running on ppc-linux 2.6.17. I'm attempting to get a TurboGears 0.9a9 (using CherryPy 2.2.1) based app running on it. During the TG-app startup sequence, it reaches...
1
by: tyler | last post by:
I've written a small python extension but I'm having difficulty loading it at runtime. The source for my extension is a module which is a member of a package is organized as follows. ...
2
by: dwelch91 | last post by:
Hi, c.l.p.'ers- I am having a problem with the import of xml.parsers.expat that has gotten me completely stumped. I have two programs, one a PyQt program and one a command line (text) program...
1
by: aznach | last post by:
Hello! I have a shared hosting account at GrokThis.net and have a problem with the module order of the Python search path. I'd like to use django's svn trunk instead of the...
8
by: geert | last post by:
Hi all, I have a mac mini running maocosx 10.5 leopard I want to deploy a django project on. My backend is MySQL, and I have it running as a 64- bit app. Of course, apache2 is also running as...
0
by: Neal Becker | last post by:
Any ideas on this? bb-freeze test5-coded-pre.py WARNING: found xml.sax in multiple directories. Assuming it's a namespace package. (found in /usr/lib64/python2.5/site-packages/_xmlplus/sax,...
4
by: Tommy Grav | last post by:
I am trying to learn how to use cython, and while I am following the cython-dev mailing list I didn't feel like this question was totally appropriate for its audience so I am trying here first. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.