#include "Python.h" #include "libnumarray.h"
#include "Python.h" #include "numarray/libnumarray.h"
import_libnumarray();
import_libnumarray() is actually a macro which sets up a pointer to the numarray C-API function pointer table. If you forget to call import_libnumarray(), your extension module will crash as soon as you call a numarray API function, because your application will attempt to dereference a NULL pointer.
Note that for the Numeric compatible API you should substitute arrayobject.h for libnumarray.h and import_array() for import_libnumarray() respectively. Unlike other versions of numarray prior to 1.0, arrayobject.h now includes only the Numeric simulation API. To use the rest of the numarray API, you must include libnumarray.h. To use both, you must include both arrayobject.h and libnumarray.h, and you must both import_array() and import_libnumarray() in your module initialization function.
from distutils.core import setup, Extension from numarray.numarrayext import NumarrayExtension import sys if not hasattr(sys, 'version_info') or sys.version_info < (2,2,0,'alpha',0): raise SystemExit, "Python 2.2 or later required to build this module." setup(name = "buildHistogram", version = "0.1", description = "", packages=[""], package_dir={"":""}, ext_modules=[NumarrayExtension("buildHistogram",['buildHistogram.c'],\ include_dirs=["./"], library_dirs=["./"], libraries=['m'])])
See the Python manuals ``Installing Python Modules'' and ``Distributing Python Modules'' for more information on how to use distutils.
Send comments to the NumArray community.