Extension module with meschach library and numpy.i (SWIG)
Hi everybody,
I'm working on some functions to calculate the response of some physics models. Initially, I coded with C, nevertheless, I had to connect the physics toolbox to some graphics tools; for that reason, I decided to use python; actually python is controlling the high level interface but I decided to keep the physics core with C(performance); I'm using SWIG to connect my python high level interface with the C physics. I use numpy on python to the define the inputs and outputs for my physics toolbox. To improve the calculation time I use the meschach vectors and matrices library.
This is my setup.py
from distutils.core import setup, Extension
import numpy
try: numpy_include = numpy.get_include() except AttributeError: numpy_include = numpy.get_numpy_include()
_cmd_wrapper = Extension("_cmd_wrapper", ["cmd_source1.c","cmd_source2.c",...], include_dirs = [numpy_include,'../mesch12b'], extra_objects=['../mesch12b/meschach.a'], libraries=['m'], )
setup (name = "cmd_wrapper", description = "CMD wrapper", version = "0.1", author = "juandhv", py_modules = ["cmd_wrapper"], ext_modules = [_cmd_wrapper] )
When I try to import the result module, import cmd_wrapper, I got this error:
import _cmd_wrapper ImportError: /ModCMD/_cmd_wrapper.so: failed to map segment from shared object: Cannot allocate memory
There are 3 things that I'd like to know:
- Is this the correct way to include the meschach library ? extra_objects=['../mesch12b/meschach.a']
- Is there any problem if Meschach use malloc, calloc and realloc?
- Is there any problem if I declare some variables as static? e.g. static MAT *M1;
I'm running this on a virtual machine over ubuntu with 512MB of RAM, I know that's not too much, but I think is enough for a module (My module is not bigger than numpy!!). I can import my module on MAC OS X with more RAM (even on linux with 1GB) but when I tried to import the module with the complete sotware (others high level tools like graphics and GUI) I get the same problem
Any help I'll be thankful (sorry for any english mistake)
Juan David
On 2008-08-06 21:17, Juan David Hernandez wrote:
There are 3 things that I'd like to know:
- Is this the correct way to include the meschach library ? extra_objects=['../mesch12b/meschach.a']
- Is there any problem if Meschach use malloc, calloc and realloc?
- Is there any problem if I declare some variables as static? e.g. static MAT *M1;
Hard to say... could you explain what "Meschach" is and does ?
I'm running this on a virtual machine over ubuntu with 512MB of RAM, I know that's not too much, but I think is enough for a module (My module is not bigger than numpy!!). I can import my module on MAC OS X with more RAM (even on linux with 1GB) but when I tried to import the module with the complete sotware (others high level tools like graphics and GUI) I get the same problem
The error message you are getting is generated by the dynamic linker and doesn't really have anything to do with Python.
You'll likely need more RAM to your app (Linux overcommits RAM and then fails with errors such as the above if it tries to actually use the allocated RAM).
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, Aug 07 2008)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
participants (2)
-
Juan David Hernandez
-
M.-A. Lemburg