def install(): ext = [] kwargs = { "name": "sizer", "version": "0.1.1", "description": "Memory profiler", "author": "Nick Smallbone", "author_email": "nick.smallbone@gmail.com", "url": "http://pysizer.8325.org", "packages": ["sizer", "sizer.cpython"], "package_dir": {"sizer": "src"}, "ext_modules": ext } from distutils.core import setup, Extension try: from Pyrex.Distutils import build_ext # Hack for Pyrex versions which define swig_sources # to only take two parameters. class my_build_ext(build_ext): def swig_sources(self, sources, ext = None): return build_ext.swig_sources(self, sources) kwargs["cmdclass"] = {"build_ext": my_build_ext} ext.append( Extension("sizer.cpython.crules", ["src/cpython/crules.pyx"])) except ImportError: import warnings print "Can't find Pyrex, so some types won't be counted accurately" ext.append( Extension("sizer.cpython.utils", ["src/cpython/utils.c"])) setup(**kwargs) if __name__ == "__main__": install()