setup.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/python
  2. from os import getenv
  3. cc = getenv("CC")
  4. if cc == "clang":
  5. from _sysconfigdata import build_time_vars
  6. from re import sub
  7. build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", build_time_vars["CFLAGS"])
  8. from distutils.core import setup, Extension
  9. from distutils.command.build_ext import build_ext as _build_ext
  10. from distutils.command.install_lib import install_lib as _install_lib
  11. class build_ext(_build_ext):
  12. def finalize_options(self):
  13. _build_ext.finalize_options(self)
  14. self.build_lib = build_lib
  15. self.build_temp = build_tmp
  16. class install_lib(_install_lib):
  17. def finalize_options(self):
  18. _install_lib.finalize_options(self)
  19. self.build_dir = build_lib
  20. cflags = getenv('CFLAGS', '').split()
  21. # switch off several checks (need to be at the end of cflags list)
  22. cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter' ]
  23. src_perf = getenv('srctree') + '/tools/perf'
  24. build_lib = getenv('PYTHON_EXTBUILD_LIB')
  25. build_tmp = getenv('PYTHON_EXTBUILD_TMP')
  26. libtraceevent = getenv('LIBTRACEEVENT')
  27. libapikfs = getenv('LIBAPI')
  28. ext_sources = [f.strip() for f in open('util/python-ext-sources')
  29. if len(f.strip()) > 0 and f[0] != '#']
  30. # use full paths with source files
  31. ext_sources = list(map(lambda x: '%s/%s' % (src_perf, x) , ext_sources))
  32. perf = Extension('perf',
  33. sources = ext_sources,
  34. include_dirs = ['util/include'],
  35. extra_compile_args = cflags,
  36. extra_objects = [libtraceevent, libapikfs],
  37. )
  38. setup(name='perf',
  39. version='0.1',
  40. description='Interface with the Linux profiling infrastructure',
  41. author='Arnaldo Carvalho de Melo',
  42. author_email='acme@redhat.com',
  43. license='GPLv2',
  44. url='http://perf.wiki.kernel.org',
  45. ext_modules=[perf],
  46. cmdclass={'build_ext': build_ext, 'install_lib': install_lib})