setup.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. liblk = getenv('LIBLK')
  21. ext_sources = [f.strip() for f in file('util/python-ext-sources')
  22. if len(f.strip()) > 0 and f[0] != '#']
  23. perf = Extension('perf',
  24. sources = ext_sources,
  25. include_dirs = ['util/include'],
  26. extra_compile_args = cflags,
  27. extra_objects = [libtraceevent, liblk],
  28. )
  29. setup(name='perf',
  30. version='0.1',
  31. description='Interface with the Linux profiling infrastructure',
  32. author='Arnaldo Carvalho de Melo',
  33. author_email='acme@redhat.com',
  34. license='GPLv2',
  35. url='http://perf.wiki.kernel.org',
  36. ext_modules=[perf],
  37. cmdclass={'build_ext': build_ext, 'install_lib': install_lib})