Packages with both pyx and pyf extension files.

214 views
Skip to first unread message

Dominique

unread,
Jan 19, 2011, 11:01:18 AM1/19/11
to cython-users
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!

Robert Bradshaw

unread,
Jan 20, 2011, 3:53:54 AM1/20/11
to cython...@googlegroups.com

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

Reply all
Reply to author
Forward
0 new messages