[Numpy-discussion] bus error in embedded numpy

Robin robince at gmail.com
Fri Nov 13 14:12:26 EST 2009

On Fri, Nov 13, 2009 at 6:50 PM, Pauli Virtanen <pav+sp at iki.fi> wrote:
> Fri, 13 Nov 2009 17:23:19 +0000, Robin wrote:
>> I'm trying to embed Python in a MATLAB mex file. I've been coming under
>> some pressure to make my Python code available to my MATLAB colleagues
>> so I am trying to come up with a relatively general way of calling
>> numerical python code from Matlab.
> Out of curiosity, how are you handling the Matlab RTLD_GLOBAL issue. Last
> time [1] I did something similar, I had to hack around it in an ugly way.
> .. [1] http://www.iki.fi/pav/software/pythoncall/index.html

Actually I was completely unaware of it (the RTLD_GLOBAL thing). I had
googled for a while trying to find a similar project (I had assumed
someone must have done it) but somehow didn't find your pythoncall
project. It's great - the interface is very close to what I had in
mind, but it's much more comprehensive then anything I thought of (I
was hoping to handle just contiguous numpy arrays).

How does the RTLD_GLOBAL thing manifest itself? So far I have only a
very basic start which basically consists of:
    cmd = mxArrayToString(prhs[0]);
but I haven't noticed anything not working - I can run numpy
testsuite, and do simple commands as expected (initiliase arrays in
the interpreter, run numpy functions on them). Perhaps recent versions
of Matlab behave differently (I am using R2009a on a mac).

So far the only remotely tricky thing I did was redirect sys.stdout
and sys.stderr to a wrapper that uses mexPrintf so output goes to the
matlab console.



More information about the NumPy-Discussion mailing list