setup.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 = getenv('CFLAGS', '').split()
  16. # switch off several checks (need to be at the end of cflags list)
  17. cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter' ]
  18. src_perf = getenv('srctree') + '/tools/perf'
  19. build_lib = getenv('PYTHON_EXTBUILD_LIB')
  20. build_tmp = getenv('PYTHON_EXTBUILD_TMP')
  21. libtraceevent = getenv('LIBTRACEEVENT')
  22. libapikfs = getenv('LIBAPI')
  23. ext_sources = [f.strip() for f in file('util/python-ext-sources')
  24. if len(f.strip()) > 0 and f[0] != '#']
  25. # use full paths with source files
  26. ext_sources = map(lambda x: '%s/%s' % (src_perf, x) , ext_sources)
  27. perf = Extension('perf',
  28. sources = ext_sources,
  29. include_dirs = ['util/include'],
  30. extra_compile_args = cflags,
  31. extra_objects = [libtraceevent, libapikfs],
  32. )
  33. setup(name='perf',
  34. version='0.1',
  35. description='Interface with the Linux profiling infrastructure',
  36. author='Arnaldo Carvalho de Melo',
  37. author_email='acme@redhat.com',
  38. license='GPLv2',
  39. url='http://perf.wiki.kernel.org',
  40. ext_modules=[perf],
  41. cmdclass={'build_ext': build_ext, 'install_lib': install_lib})