473,695 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.abspat h(__file__))
mylib_path = os.path.join(my _path, 'subdirOfSitePa ckages')

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_PAT H'] = mylib_path + ":" +
os.environ['LD_LIBRARY_PAT H']
else:
os.environ['LD_LIBRARY_PAT H'] = mylib_path

from myLibFolder._my lib 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.s o
mylibCommon.so
libboost_python .so

Where _mylib.so dynamically links with mylibDBAccess.s o,
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.s o).

Any ideas on how to resolve this?

Regards,
Liam

Apr 10 '06 #1
1 1987
On 10 Apr 2006 12:42:28 -0700, liam_herron <li*********@ho tmail.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.abspat h(__file__))
mylib_path = os.path.join(my _path, 'subdirOfSitePa ckages')

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_PAT H'] = mylib_path + ":" +
os.environ['LD_LIBRARY_PAT H']
else:
os.environ['LD_LIBRARY_PAT H'] = mylib_path

from myLibFolder._my lib 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.s o
mylibCommon.so
libboost_python .so

Where _mylib.so dynamically links with mylibDBAccess.s o,
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.s o).

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
1760
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 build running build
2
1482
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 *foo_bar(PyObject *self, PyObject *args) {
2
1651
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 the point where it imports cherrypy, which eventually causes py2.4's system file, compiler/transformer.py, to import a module by name, symbol. Unable to find it, python quits...
1
2111
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. test/setup.py test/myutils/__init__.py test/myutils/netmodule.c my setup.py file for building / installing looks like this
2
3738
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 that both eventually call the same code that imports xml.parsers.expat. Both give me different results... The code that gets called is (print statements have been added for debugging):
1
1547
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 "Django-0.95-py2.4.egg" provided in site-packages. The problem is that the "django egg" gets preference over the "django svn trunk" module I manually added to PYTHONPATH...
8
2773
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 64-bit. MySQLdb installs with the usual warnings after applying the various patches I found here and there. These patches consist of altering _mysql.c and site.cfg.
0
1138
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, /usr/lib64/python2.5/xml/sax) *** applied <function recipe_doctest at 0xc618c0> recipe_matplotlib: using the backend_qt4agg matplotlib backend *** applied <function recipe_matplotlib at 0xc61d70> *** applied <function recipe_pydoc at 0xc619b0>
4
2819
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. I am on a max os x 10.5.4 running drtgrav% python ActivePython 2.5.2.2 (ActiveState Software Inc.) based on
0
8649
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9004
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8864
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4592
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3025
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2289
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.