Greenlet-aware Python performance profiler, built on yappi.

setup.py 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import os
  2. import sys
  3. from distutils.ccompiler import new_compiler
  4. from setuptools import Extension
  5. from setuptools import setup
  6. # Hack to silence atexit traceback in newer python versions.
  7. try:
  8. import multiprocessing
  9. except ImportError:
  10. pass
  11. # For now, GreenletProfiler includes a patched version of Sumer Cip's yappi.
  12. # The original yappi source is at https://bitbucket.org/sumerc/yappi, and my
  13. # fork is at https://bitbucket.org/emptysquare/gappi. The patched source is
  14. # included in this project in the _vendorized_yappi directory, and the
  15. # following extension configuration is adapted from yappi's setup.py.
  16. user_macros = []
  17. user_libraries = []
  18. compile_args = []
  19. link_args = []
  20. if os.name == 'posix' and sys.platform != 'darwin':
  21. compiler = new_compiler()
  22. if compiler.has_function('timer_create', libraries=('rt',)):
  23. user_macros.append(('LIB_RT_AVAILABLE', '1'))
  24. user_libraries.append('rt')
  25. yappi_extension = Extension(
  26. '_GreenletProfiler_yappi',
  27. sources=[
  28. '_vendorized_yappi/_yappi.c',
  29. '_vendorized_yappi/callstack.c',
  30. '_vendorized_yappi/hashtab.c',
  31. '_vendorized_yappi/mem.c',
  32. '_vendorized_yappi/freelist.c',
  33. '_vendorized_yappi/timing.c'],
  34. include_dirs=['_vendorized_yappi'],
  35. define_macros=user_macros,
  36. libraries=user_libraries,
  37. extra_compile_args=compile_args,
  38. extra_link_args=link_args)
  39. # End of setup code adapted from yappi.
  40. classifiers = """\
  41. Intended Audience :: Developers
  42. License :: OSI Approved :: MIT License
  43. Development Status :: 1 - Planning
  44. Natural Language :: English
  45. Programming Language :: Python :: 2
  46. Programming Language :: Python :: 2.6
  47. Programming Language :: Python :: 2.7
  48. Programming Language :: Python :: 3
  49. Programming Language :: Python :: 3.2
  50. Programming Language :: Python :: 3.3
  51. Operating System :: MacOS :: MacOS X
  52. Operating System :: Unix
  53. Programming Language :: Python
  54. Programming Language :: Python :: Implementation :: CPython
  55. """
  56. description = 'Greenlet-aware Python performance profiler, built on yappi.'
  57. long_description = open("README.rst").read()
  58. packages = []
  59. if 'nosetests' in sys.argv:
  60. packages.append('test')
  61. setup(
  62. name='GreenletProfiler',
  63. version='0.1',
  64. packages=packages,
  65. # Include Yappi's C extension, _yappi.so, which we've renamed to
  66. # _GreenletProfiler_yappi.so.
  67. ext_modules=[yappi_extension],
  68. # Include yappi.py along with our own GreenletProfiler.py.
  69. py_modules=[
  70. '_vendorized_yappi/yappi',
  71. '_vendorized_yappi/__init__',
  72. 'GreenletProfiler'],
  73. description=description,
  74. long_description=long_description,
  75. author='A. Jesse Jiryu Davis',
  76. author_email='jesse@emptysquare.net',
  77. url='http://github.com/ajdavis/GreenletProfiler/',
  78. license='http://www.apache.org/licenses/LICENSE-2.0',
  79. classifiers=filter(None, classifiers.split('\n')),
  80. keywords='greenlet gevent profiler asynchronous',
  81. install_requires=['greenlet'],
  82. # use python setup.py nosetests to test
  83. setup_requires=['nose'],
  84. test_suite='nose.collector',
  85. zip_safe=False)