[Cython] setup.py and cmdclass
Stefan Behnel
stefan_ml at behnel.de
Tue Sep 2 12:21:46 CEST 2008
T J wrote:
> [Sorry for all the posts...but hopefully, it gives the devs a sense of
> the varied user backgrounds]
>
> I've figured out how to get my cython extensions to compile via
> distutils. This site:
>
> http://wiki.cython.org/WrappingCPlusPlus
>
> says that I can pass the cmdclass keyword to the Extension() object.
> However, when I do this, I get (for example):
>
> error: unknown file type '.pyx' (from 'primes.pyx')
>
> Only if I move the cmdclass declaration to the setup() will it compile
> properly. That is fine, but now I wonder how I can handle extensions
> if they are not Cython extensions. That is, suppose I have:
>
> from Cython.Distutils import build_ext
> setup(....
> ext_modules=[Extension('primes', 'primes.pyx'),
> Extension('noncython', 'noncython.c')]
> cmdclass={'build_ext': build_ext}
> )
>
> Would this work? My first reaction is that I don't want the cython
> build_ext for a non-cython extension. Or is the Cython build_ext a
> superset of distutils.command.build_ext?
Apparently, you forgot to try it before posting. Reading the source would
also have answered your question.
Cython's own build_ext only special-cases .pyx files and passes on their
.c/.cpp result, so replacing it once and for all shouldn't hurt.
Stefan
More information about the Cython-dev
mailing list