Automatic Distutils generator

macm moura.mario at
Thu Nov 25 19:53:40 CET 2010

Hi Folks

I am trying run Distutils setup inside a script.

The Docs dont tell me much and I cant find any examples.

This script will generate shared libraries recursive to all files in a

import os
import sys
from distutils.core import setup as d
from distutils.extension import Extension
from Cython.Distutils import build_ext

fileList = []
rootdir = sys.argv[1]
fileType = '.pyx'

for root, subFolders, files in os.walk(rootdir):
    for file in files:
        if file[-4:] == fileType:

            # But Here I want automatic Distutils generator
            # I want replace manual entry like this:
            # python build_ext --inplace

            d.setup(name = str(file) + '_Cython',
                Extension(file[:-4], [file])
              cmdclass = {'build_ext': build_ext})

print 'Files convert: \n'
print fileList


Who can help me fix it?

Best Regards


More information about the Python-list mailing list