[Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Robin
Hi, 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. I am making some progress - but get a reliable

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Robin
I forgot to add it doesn't happen if Py_Finalize isn't called - if I take that out and just let the OS/matlab unload the mex function then I can run it many times without the error, but it does leak a bit of memory each time. Cheers Robin On Fri, Nov 13, 2009 at 5:23 PM, Robin robi...@gmail.com

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Robin
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. I get a similar but different error trying to do

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Travis Oliphant
On Nov 13, 2009, at 11:23 AM, Robin wrote: Hi, 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

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Robert Kern
On Fri, Nov 13, 2009 at 12:05, Travis Oliphant oliph...@enthought.com wrote: On Nov 13, 2009, at 11:23 AM, Robin wrote: Hi, 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

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Robin
On Fri, Nov 13, 2009 at 6:13 PM, Robert Kern robert.k...@gmail.com wrote: On Fri, Nov 13, 2009 at 12:05, Travis Oliphant oliph...@enthought.com wrote: I wonder if this is related to the fact that you can't unload a dynamically linked module (like NumPy has).   So, when you call Py_Finalize you

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Pauli Virtanen
Fri, 13 Nov 2009 17:23:19 +, 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.

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Robin
On Fri, Nov 13, 2009 at 6:50 PM, Pauli Virtanen pav...@iki.fi wrote: Fri, 13 Nov 2009 17:23:19 +, 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

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Pauli Virtanen
Fri, 13 Nov 2009 19:12:26 +, Robin wrote: [clip] 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]); PyRun_SimpleString(cmd); but I haven't noticed anything not working - I can run numpy

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Sturla Molden
Robin skrev: I had assumed when matlab unloads the mex function it would also unload python - but it looks like other dynamic libs pulled in from the mex function (in this case python and in turn numpy) aren't unloaded... Matlab MEX functions are DLLs, Python interpreter is a DLL, NumPy

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Sturla Molden
Robin skrev: 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. Be careful when you are using file handles. You have to be sure that Matlab, Python and NumPy are all linked against the

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Robin
On Fri, Nov 13, 2009 at 7:48 PM, Sturla Molden stu...@molden.no wrote: Robin skrev: I had assumed when matlab unloads the mex function it would also unload python - but it looks like other dynamic libs pulled in from the mex function (in this case python and in turn numpy) aren't unloaded...

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Sturla Molden
Robin skrev: Ah, I hadn't realised it was an OS constraint - I thought it was possible to unload dlls - and that was why matlab provides the clear function. mex automatically clears a function when you rebuild it - I thought that was how you can rebuild and reload mex functions without

Re: [Numpy-discussion] bus error in embedded numpy

2009-11-13 Thread Pauli Virtanen
pe, 2009-11-13 kello 22:36 +0100, Sturla Molden kirjoitti: [clip] I was aware of this - I thought I would be OK on the mac - at least Python and Numpy and my mex function are built with apple gcc although I'm not sure about Matlab. I guess Windows will be more difficult... But in any case