setup.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #!/usr/bin/env python
  2. """
  3. Sentry
  4. ======
  5. Sentry is a realtime event logging and aggregation platform. It specializes
  6. in monitoring errors and extracting all the information needed to do a proper
  7. post-mortem without any of the hassle of the standard user feedback loop.
  8. Sentry is a Server
  9. ------------------
  10. The Sentry package, at its core, is just a simple server and web UI. It will
  11. handle authentication clients (such as `the Python one
  12. <https://github.com/getsentry/sentry-python>`_)
  13. and all of the logic behind storage and aggregation.
  14. That said, Sentry is not limited to Python. The primary implementation is in
  15. Python, but it contains a full API for sending events from any language, in
  16. any application.
  17. :copyright: (c) 2011-2014 by the Sentry Team, see AUTHORS for more details.
  18. :license: BSD, see LICENSE for more details.
  19. """
  20. from __future__ import absolute_import
  21. # if sys.version_info[:2] != (2, 7):
  22. # print 'Error: Sentry requires Python 2.7'
  23. # sys.exit(1)
  24. import os
  25. import os.path
  26. import sys
  27. from distutils.command.build import build as BuildCommand
  28. from setuptools import setup, find_packages
  29. from setuptools.command.sdist import sdist as SDistCommand
  30. from setuptools.command.develop import develop as DevelopCommand
  31. ROOT = os.path.realpath(os.path.join(os.path.dirname(sys.modules["__main__"].__file__)))
  32. # Add Sentry to path so we can import distutils
  33. sys.path.insert(0, os.path.join(ROOT, "src"))
  34. from sentry.utils.distutils import (
  35. BuildAssetsCommand,
  36. BuildIntegrationDocsCommand,
  37. BuildJsSdkRegistryCommand,
  38. )
  39. # The version of sentry
  40. VERSION = "10.0.0.dev0"
  41. # Hack to prevent stupid "TypeError: 'NoneType' object is not callable" error
  42. # in multiprocessing/util.py _exit_function when running `python
  43. # setup.py test` (see
  44. # http://www.eby-sarna.com/pipermail/peak/2010-May/003357.html)
  45. for m in ("multiprocessing", "billiard"):
  46. try:
  47. __import__(m)
  48. except ImportError:
  49. pass
  50. IS_LIGHT_BUILD = os.environ.get("SENTRY_LIGHT_BUILD") == "1"
  51. # we use pip requirements files to improve Docker layer caching
  52. def get_requirements(env):
  53. with open(u"requirements-{}.txt".format(env)) as fp:
  54. return [x.strip() for x in fp.read().split("\n") if not x.startswith("#")]
  55. install_requires = get_requirements("base")
  56. dev_requires = get_requirements("dev")
  57. tests_require = get_requirements("test")
  58. optional_requires = get_requirements("optional")
  59. # override django version in requirements file if DJANGO_VERSION is set
  60. DJANGO_VERSION = os.environ.get("DJANGO_VERSION")
  61. if DJANGO_VERSION:
  62. install_requires = [
  63. u"Django{}".format(DJANGO_VERSION) if r.startswith("Django>=") else r
  64. for r in install_requires
  65. ]
  66. class SentrySDistCommand(SDistCommand):
  67. # If we are not a light build we want to also execute build_assets as
  68. # part of our source build pipeline.
  69. if not IS_LIGHT_BUILD:
  70. sub_commands = SDistCommand.sub_commands + [
  71. ("build_integration_docs", None),
  72. ("build_assets", None),
  73. ("build_js_sdk_registry", None),
  74. ]
  75. class SentryBuildCommand(BuildCommand):
  76. def run(self):
  77. if not IS_LIGHT_BUILD:
  78. self.run_command("build_integration_docs")
  79. self.run_command("build_assets")
  80. self.run_command("build_js_sdk_registry")
  81. BuildCommand.run(self)
  82. class SentryDevelopCommand(DevelopCommand):
  83. def run(self):
  84. DevelopCommand.run(self)
  85. if not IS_LIGHT_BUILD:
  86. self.run_command("build_integration_docs")
  87. self.run_command("build_assets")
  88. self.run_command("build_js_sdk_registry")
  89. cmdclass = {
  90. "sdist": SentrySDistCommand,
  91. "develop": SentryDevelopCommand,
  92. "build": SentryBuildCommand,
  93. "build_assets": BuildAssetsCommand,
  94. "build_integration_docs": BuildIntegrationDocsCommand,
  95. "build_js_sdk_registry": BuildJsSdkRegistryCommand,
  96. }
  97. setup(
  98. name="sentry",
  99. version=VERSION,
  100. author="Sentry",
  101. author_email="hello@sentry.io",
  102. url="https://sentry.io",
  103. description="A realtime logging and aggregation server.",
  104. long_description=open(os.path.join(ROOT, "README.rst")).read(),
  105. package_dir={"": "src"},
  106. packages=find_packages("src"),
  107. zip_safe=False,
  108. install_requires=install_requires,
  109. extras_require={
  110. "dev": dev_requires,
  111. "postgres": [],
  112. "tests": tests_require,
  113. "optional": optional_requires,
  114. },
  115. cmdclass=cmdclass,
  116. license="BSD",
  117. include_package_data=True,
  118. entry_points={"console_scripts": ["sentry = sentry.runner:main"]},
  119. classifiers=[
  120. "Framework :: Django",
  121. "Intended Audience :: Developers",
  122. "Intended Audience :: System Administrators",
  123. "Operating System :: POSIX :: Linux",
  124. "Programming Language :: Python :: 2",
  125. "Programming Language :: Python :: 2.7",
  126. "Programming Language :: Python :: 2 :: Only",
  127. "Topic :: Software Development",
  128. ],
  129. )