setup.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/python2
  2. from distutils.core import setup, Extension
  3. from os import getenv
  4. from distutils.command.build_ext import build_ext as _build_ext
  5. from distutils.command.install_lib import install_lib as _install_lib
  6. class build_ext(_build_ext):
  7. def finalize_options(self):
  8. _build_ext.finalize_options(self)
  9. self.build_lib = build_lib
  10. self.build_temp = build_tmp
  11. class install_lib(_install_lib):
  12. def finalize_options(self):
  13. _install_lib.finalize_options(self)
  14. self.build_dir = build_lib
  15. cflags = ['-fno-strict-aliasing', '-Wno-write-strings']
  16. cflags += getenv('CFLAGS', '').split()
  17. build_lib = getenv('PYTHON_EXTBUILD_LIB')
  18. build_tmp = getenv('PYTHON_EXTBUILD_TMP')
  19. libtraceevent = getenv('LIBTRACEEVENT')
  20. ext_sources = [f.strip() for f in file('util/python-ext-sources')
  21. if len(f.strip()) > 0 and f[0] != '#']
  22. perf = Extension('perf',
  23. sources = ext_sources,
  24. include_dirs = ['util/include'],
  25. extra_compile_args = cflags,
  26. extra_objects = [libtraceevent],
  27. )
  28. setup(name='perf',
  29. version='0.1',
  30. description='Interface with the Linux profiling infrastructure',
  31. author='Arnaldo Carvalho de Melo',
  32. author_email='acme@redhat.com',
  33. license='GPLv2',
  34. url='http://perf.wiki.kernel.org',
  35. ext_modules=[perf],
  36. cmdclass={'build_ext': build_ext, 'install_lib': install_lib})