[Numpy-discussion] Detecting Numeric.
pearu at cens.ioc.ee
Wed Dec 11 02:49:02 EST 2002
On Wed, 11 Dec 2002, Andrea Riciputi wrote:
> Hi there,
> I'm playing with Numeric and even if I've not so much experience with
> it I'm trying to write a C extention to Python that can use Numeric
> arrays. The basic idea consists in handling C (dynamically allocated)
> array as Numeric array (if Numeric is installed) or as simple Python
> lists if not.
> How can I detect at compile time if Numeric is installed or not?? I've
> thought something like:
> #ifdef NUMERIC_IS_HERE
> #include "Numeric/arrayobject.h"
> But I've not found any hints in Numeric manual. Can anyone suggest a
> solution to me?
If you are using distutils for building extension modules then you can
test if Numeric is available in setup.py file and define, say, HAVE_NUMPY
macro, if Numeric is available. For example,
have_numpy = 0
have_numpy = 1
define_macros = 
if __name__ == "__main__":
from distutils.core import setup
setup(name = ...,
ext_modules = [...],
define_macros = define_macros
and in extension source files use
More information about the NumPy-Discussion