setup.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. if cc != "clang":
  24. cflags += ['-Wno-cast-function-type' ]
  25. src_perf = getenv('srctree') + '/tools/perf'
  26. build_lib = getenv('PYTHON_EXTBUILD_LIB')
  27. build_tmp = getenv('PYTHON_EXTBUILD_TMP')
  28. libtraceevent = getenv('LIBTRACEEVENT')
  29. libapikfs = getenv('LIBAPI')
  30. ext_sources = [f.strip() for f in open('util/python-ext-sources')
  31. if len(f.strip()) > 0 and f[0] != '#']
  32. # use full paths with source files
  33. ext_sources = list(map(lambda x: '%s/%s' % (src_perf, x) , ext_sources))
  34. perf = Extension('perf',
  35. sources = ext_sources,
  36. include_dirs = ['util/include'],
  37. extra_compile_args = cflags,
  38. extra_objects = [libtraceevent, libapikfs],
  39. )
  40. setup(name='perf',
  41. version='0.1',
  42. description='Interface with the Linux profiling infrastructure',
  43. author='Arnaldo Carvalho de Melo',
  44. author_email='acme@redhat.com',
  45. license='GPLv2',
  46. url='http://perf.wiki.kernel.org',
  47. ext_modules=[perf],
  48. cmdclass={'build_ext': build_ext, 'install_lib': install_lib})