[Numpy-discussion] distutils for a Pyrex module

Robert Kern robert.kern@gmail....
Tue Mar 20 17:57:18 CDT 2007


Pierre GM wrote:
> On Tuesday 20 March 2007 18:13:09 Robert Kern wrote:
>> Pierre GM wrote:
>> Hmm. Okay, put the FORTRAN files into a library instead.
> 
> Robert, Pearu, great ! Creating a library did the trick. I eventually come 
> with that:
> ########################
> def configuration(parent_package='',top_path=None):
>     from numpy.distutils.misc_util import Configuration, get_mathlibs
>     config = Configuration('cloess',parent_package,top_path)
>     from numpy.distutils.system_info import get_info, dict_append
>     #
>     f_sources = ('loessf.f', 'linpack_lite.f')
>     config.add_library('floess', 
>                        sources = [join('src',x) for x in f_sources])
>     #
>     blas_info = get_info('blas_opt')
>     lapack_info = get_info('lapack_opt')
>     #    
>     c_sources = ['cloess.c', 'loess.c', 'loessc.c', 'misc.c', 'predict.c',]
>     #
>     build_info = {}
>     dict_append(build_info, **blas_info)
>     dict_append(build_info, **lapack_info)    
>     dict_append(build_info, libraries=['floess'])
>     #  
>     config.add_extension('_loess',
>                          sources=[join('src', x) for x in c_sources],
>                          **build_info
>                         )
>     config.add_data_dir(join('.','examples'))
>     config.add_data_files('pyloess.py')
>     return config
> #########################
> However, I still don't get a usable module: I have:
> ImportError: dynamic module does not define init function (init_loess). It 
> looks like src/loess.c gets compiled before /src/cloess.c... 

Is there an init_loess function in cloess.c? If cloess.c was created by Pyrex
from cloess.pyx, then Pyrex will make an initcloess function. The module name
needs to be consistent throughout.

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