[Numpy-discussion] distutils for a Pyrex module

Robert Kern robert.kern at gmail.com
Tue Mar 20 18:13:09 EDT 2007


Pierre GM wrote:
> On Tuesday 20 March 2007 17:46:28 Robert Kern wrote:
> 
>> The first file in the sources list should be the one that actually
>> implements the module, i.e. the C file generated by Pyrex. FORTRAN files
>> specified after the first one won't be processed by f2py.
> 
> Mmh. I had to get rid of the '*.pyx' and '*.pxd' lines as numpy.distutils 
> complained of a multiple definition of initcloess.
> However, that still doesn't work: I switched the order of f_sources and 
> c_sources to
>>>> sources=[join('src', x) for x in (c_sources+f_sources)],
> where c_sources now have 'cloess.c' as first element (that's the output of 
> pyrex), and f2py still processes the fortran sources. At the end, the module 
> contains only the f2py-processed fortran subroutines, which are useless on 
> their own.

Hmm. Okay, put the FORTRAN files into a library instead.

  config.add_library('floess',
    sources=f_sources,
  )
  dict_append(build_info, libraries=['floess'])

  config.add_extension('cloess',
    sources=c_sources,
    depends=...,
    **build_info,
  )

-- 
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