[Numpy-discussion] need help building a numpy extension that uses fftpack on windows

Ralf Gommers ralf.gommers@googlemail....
Thu Jun 2 14:07:26 CDT 2011


On Wed, Jun 1, 2011 at 5:45 PM, martin smith <gmane@blindgoat.org> wrote:

> I have a bit of code that performs multi-taper power spectra using numpy
> and a C extension module.  The C portion consists of an interface file
> and a python-unaware computational file.  The latter invokes fftpack.
>
> The straightforward setup.py appended below works fine on Linux.  On
> Windows using MinGW it's not so good. I first created a libpython27.a
> file following instructions on the web.  The C code now compiles but
> fails to link since there is no fftpack_lite.so on Windows.  I can't
> find an fftpack_lite.dll (or even the source for fftpack_lite) and don't
> know where to turn.
>

Python dll's on Windows have a .pyd extension, there should be a
fftpack_lite.pyd file. But you should be able to just leave off the
extension, so it does the right thing on any platform.

Also, the way you specified library_dirs doesn't work if numpy is not in
site-packages, better to use something like:
     library_dirs = [os.path.join(numpy.__path__[0], 'fft')]


> Trying to sort these problems out in Windows is (to me) difficult and
> bewildering.  I'd much appreciate any advice.
>
> - martin smith
>
> (BTW: the code is unencumbered and available for the asking.)
>
> After search for multi-taper I found
http://projects.scipy.org/scipy/ticket/608. Too bad no one has gotten around
to review your contribution before, it sounds like a good addition for the
scipy.signal module.

Cheers,
Ralf

>
> ----------------------------------------------------------------------
> from numpy.distutils.core import setup
> from numpy.distutils.extension import Extension
> import os.path
> import distutils.sysconfig as sf
>
> use_fftpack = 1
>
> if use_fftpack:
>
>    pymutt_module = Extension(
>        'pymutt',
>        ['pymutt.c'],
>        library_dirs = [os.path.join(sf.get_python_lib(), 'numpy', 'fft')],
>        define_macros = [('USE_FFTPACK', None)],
>        libraries = [':fftpack_lite.so'],
>        )
>
> else:
>
>    pymutt_module = Extension(
>        'pymutt',
>        ['pymutt.c'],
>        libraries = ['fftw3'],
>        )
>
> setup(name='pymutt',
>      version='1.0',
>      description = "numpy support for multi-taper fourier transforms",
>      author = "Martin L. Smith",
>      long_description =
> '''
> Implements a numpy interface to an implementation of Thomson's
> multi-taper fourier transform algorithms.  The key C module (mtbase.c)
> is derived from code written and made freely available by J. M. Lees and
> Jeff Park.
> ''',
>      ext_modules=[pymutt_module],
>    )
>
> ----------------------------------------------------------------------------------------
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110602/1eedac3e/attachment-0001.html 


More information about the NumPy-Discussion mailing list