Packages with both pyx and pyf extension files.

Showing 1-2 of 2 messages
Packages with both pyx and pyf extension files. Dominique 1/19/11 8:01 AM
Hi all,

I'm writing a multi-directory Python package with a numpy-distutils-
style setup.py: one setup.py per submodule, one submodule per
directory, and options delegated to submodules. Thus, only the topmost
setup.py calls setup(). All the others do is perform actions of the
form config.add_extension() and config.add_library().

One of my submodules has a Cython interface to a C library. For this
extension, I'd like to only distribute a pyx file.

Another submodule has a f2py interface to a Fortran library. For this
extension, I only distribute the pyf file.

Now the problem is that if the topmost setup.py does

    from Cython.Distutils import build_ext

and passes cmdclass={'build_ext': build_ext} to setup(), compilation
of the pyf interface fails with:

    error: unknown file type '.pyf'

Since the config.add_extension() commands actually use Numpy's
subclass of Distutil's Extension, I was expecting the compilation of
pyf files to go through.

How can I fix this? Is it possible to use a different build_ext for
different extensions?

Thanks in advance!
Re: [cython-users] Packages with both pyx and pyf extension files. Robert Bradshaw 1/20/11 12:53 AM

No, unfortunately, this is one of the warts of distutils. You could
write your own that does dispatching, but that's kind of hackish.

I'd recommend using
http://wiki.cython.org/enhancements/distutils_preprocessing -- run
your extension list through that first, which translates .pyx to .c
files, and then you can use Numpy's Distutils (or any other that is
completely Cython-unaware).

- Robert