[Numpy-discussion] include file location and .eggs

Pearu Peterson pearu at scipy.org
Mon Jan 23 11:18:02 EST 2006


On Mon, 23 Jan 2006, konrad.hinsen at laposte.net wrote:

> Let's go back to my initial scenario, and let's even forget about multiple 
> versions. I have ScientificPython, which can be compiled for use with either 
> Numeric or numarray, and some day NumPy will be a third choice. Then I 
> install MMTK, which depends on ScientificPython. How is the MMTK installation 
> script supposed to figure out if ScientificPython was compiled with Numeric, 
> numarray, or NumPy?

I don't know about setuptools but distutils cannot solve this problem 
either without some extra code in MMTK setup.py file and a possibility to 
determine which choice was used to build ScientificPython. So, it's not 
really a distutils nor numpy include file location issue.

> And how is it supposed to know where each of these packages stores its header files?

Here's an answer to this question, namely, when numpy is installed, 
then one can use the following code in setup.py to support different array 
backends:

   from numpy.distutils.system_info import get_info
   arr_info = get_info('numpy') or get_info('numarray') or get_info('Numeric')

   # For explanation, arr_info is one of the following dictionaries:
   #  {'define_macros':[('NUMPY',None)], 'include_dirs':['/path/to/numpy/header/dir']}
   #  {'define_macros':[('NUMARRAY',None)], 'include_dirs':['/path/to/numarray/header/dir']}
   #  {'define_macros':[('NUMERIC',None)], 'include_dirs':['/path/to/Numeric/header/dir']}
   #  {} # --- no array backends installed
   # If one has all three array backend packages installed and wishes to
   # use, say, numarray, then to disable detecting numpy, one should
   # define environment variable NUMPY=None.

   ...

   setup(...,
      ext_modules = [Extension(..., **arr_info),..])

Pearu




More information about the NumPy-Discussion mailing list