Adding new source types to distutils?

Devin Jeanpierre jeanpierreda at gmail.com
Sun Apr 28 14:42:47 EDT 2013


On Sun, Apr 28, 2013 at 2:24 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> That approach is discouraged for Cython. The compiler comes with a
> cythonize() function these days, which users can simply call from their
> setup.py scripts. It spits out a list of Extensions that you can pass into
> setup(). So, for example, you can say
>
>     extensions = cythonize('mypackage/*.pyx')
>
> and it would do the right thing. You can also pass configuration options
> into cythonize() to influence the way Cython translates your code.
> Alternatively, you can pass in a list of Extensions and cythonize() will
> process that and replace .pyx files by the compiled .c files. That also
> makes it easier to build without having Cython installed, by simply
> replacing the .pyx files by .c yourself and passing the Extensions directly
> into setup(). And it allows for more complex Extension configurations that
> Cython doesn't have to care about.
>
> You might want to do something similar in your case. It gives users much
> more flexibility when using source code preprocessors and also avoids
> conflicts between packages like the one you describe above, or problems
> with future versions of distutils due to fragile build setups.

I'm looking at the cythonize source code now.

Isn't it weird to compile Cython source files if setup.py is executed
for any reason, even if not to build the program? That doesn't seem
like the Right Thing either. In fact, it was the first option I
discarded. :/

-- Devin



More information about the Python-list mailing list