Automatic Distutils generator

macm moura.mario at gmail.com
Thu Nov 25 13:53:40 EST 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
dir.


-----------------------------
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:
            fileList.append(os.path.join(root,file))

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

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



print 'Files convert: \n'
print fileList

----------------------------

Who can help me fix it?


Best Regards

Mario



More information about the Python-list mailing list