[Numpy-discussion] distutils for a Pyrex module

Pierre GM pgmdevlist@gmail....
Tue Mar 20 16:06:08 CDT 2007


All,
I'm trying to write a numpy.distutils setup.py for a pyrex module that 
involves both external C and fortran sources, and where the fortran sources 
need to be linked w/ blas and lapack. Here's what I have so far:

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

    libs = []
    generate_libraries = []
    f_sources = ['loessf.f', 'linpack_lite.f']
    c_sources = ['loess.c', 'loessc.c', 'misc.c', 'predict.c',]
    #
    blas_info = get_info('blas_opt')
    lapack_info = get_info('lapack_opt')
    build_info = {}
    dict_append(build_info, **blas_info)
    dict_append(build_info, **lapack_info)    
    #
    config.add_extension('cloess',
                         sources=[join('src', x) for x in 
(f_sources+c_sources)],
                         depends = [join('src','*.h'),
                                    join('src','*.pyx'),
                                    join('src','*.pxd')
                                    ],
                         **build_info
                        )
    config.add_data_dir(join('.','examples'))
    config.add_data_files('pyloess.py')
    return config
############################

But that doesn't do what I want: during the setup, the .f files are processed 
by f2py. I don't need that, I just want to have the Fortran files compiled 
along the C sources. What's the M.O., then ?

FYI, here are the commands I'm using to build the library w/o distutils:
pyrexc cloess.pyx || exit
gcc -g -c -fPIC loess.c loessc.c misc.c predict.c loessf.f linpack_lite.f
gcc -g -c -fPIC cloess.c -I/usr/include/python2.4 \
	-I/usr/lib64/python2.4/site-packages/numpy/core/include
gcc -g -shared loessf.o linpack_lite.o loess.o loessc.o misc.o predict.o 
cloess.o -llapack -lblas -o cloess.so


Any help will be welcome.
Thanks a lot in advance

(PS: initially posted on the pyrex mailing list and moved here on Robert 
Kern's request).


More information about the Numpy-discussion mailing list