|
From: Martin W. <mar...@gm...> - 2006-02-11 18:51:43
|
Hi Travis, thanks for your help! I think there is a small bug with NO_IMPORT_ARRAY / PY_ARRAY_UNIQUE_SYMBOL in numpy-0.9.4. For ease of reference I've pasted part of __multiarray_api.h below. The problem I ran into is, that my "non-importing" source files, the ones defining NO_IMPORT_ARRAY, cannot see PyArray_API, because they obviously cannot know which name I chose in the importing file. E.g. I do #define PY_ARRAY_UNIQUE_SYMBOL my_name in the file which calls import_array (). Then the object generated will not have the symbol PyArray_API, because PyArray_API is replaced with my_name. But the sources with NO_IMPORT_ARRAY look for PyArray_API, because for them it is not replaced. Indeed inserting #define PyArray_API my_name into these files seems to fix the problem for me. Regards, Martin. #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 On Thursday 09 February 2006 16:48, Travis Oliphant wrote: > Martin Wiechert wrote: > >Found it (in the "old" docs). > >Must #define PY_ARRAY_UNIQUE_SYMBOL and call import_array (). > > To be clear, you must call import_array() in the modules init function. > This is the only requirement. > > You only have to define PY_ARRAY_UNIQUE_SYMBOL if your extension module > uses more than one file. In the files without the module initialization > code you also have to define NO_IMPORT_ARRAY. > > -Travis |