[Numpy-discussion] PY_ARRAY_UNIQUE_SYMBOL

Robert Kern robert.kern@gmail....
Wed May 21 18:15:45 CDT 2008


On Wed, May 21, 2008 at 3:34 PM, Bill Spotz <wfspotz@sandia.gov> wrote:
> I am running into a problem with a numpy-compatible extension module
> that I develop, and I believe it has to do with PY_ARRAY_UNIQUE_SYMBOL.
>
> I set PY_ARRAY_UNIQUE_SYMBOL to "PyTrilinos".

Why? My understanding is also limited, but it does not appear to me to
be something one should change.

> On my machine (Mac OS
> X), the module loads and works properly.  Another user, however (on
> Ubuntu), gets the following:
>
>     ImportError: Failure linking new module: /usr/local/lib/python2.4/
> site-
>     packages/PyTrilinos/_Epetra.so: Symbol not found: _PyTrilinos
>     Referenced from: /usr/local/lib/libpytrilinos.dylib
>     Expected in: dynamic lookup

??? How did an Ubuntu user get a hold of a .dylib?

> On my machine, I see:
>
>     $ nm libpytrilinos.dylib | grep PyTrilinos
>          U _PyTrilinos
>          ...
>
> and I'm not sure where the symbol actually IS defined.

It gets generated into __multiarray_api.h:

#if defined(PY_ARRAY_UNIQUE_SYMBOL)
#define PyArray_API PY_ARRAY_UNIQUE_SYMBOL
#endif

#if defined(NO_IMPORT) || defined(NO_IMPORT_ARRAY)
extern void **PyArray_API;
#else
#if defined(PY_ARRAY_UNIQUE_SYMBOL)
void **PyArray_API;
#else
static void **PyArray_API=NULL;
#endif
#endif


How did this symbol end up in a .dylib rather than a Python extension
module? I think it might be difficult to arrange for a non-extension
dynamic library to call into numpy.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the Numpy-discussion mailing list