Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cython setup.py for several .pyx

Tags:

I would like to cythonize faster. Code for one .pyx is

from distutils.core import setup from Cython.Build import cythonize  setup(     ext_modules = cythonize("MyFile.pyx") ) 

What if i want to cythonize

  • several files with ext .pyx, that i will call by their name

  • all .pyx files in a folder

What would be python code for the setup.py in both cases ?

like image 304
kiriloff Avatar asked Feb 17 '14 10:02

kiriloff


Video Answer


1 Answers

From: https://github.com/cython/cython/wiki/enhancements-distutils_preprocessing

# several files with ext .pyx, that i will call by their name from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext  ext_modules=[     Extension("primes",       ["primes.pyx"]),     Extension("spam",         ["spam.pyx"]),     ... ]  setup(   name = 'MyProject',   cmdclass = {'build_ext': build_ext},   ext_modules = ext_modules, ) 


# all .pyx files in a folder from distutils.core import setup from Cython.Build import cythonize  setup(   name = 'MyProject',   ext_modules = cythonize(["*.pyx"]), ) 
like image 161
iljau Avatar answered Oct 13 '22 00:10

iljau