setup.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. optional_requires = get_requirements("optional")
  58. # override django version in requirements file if DJANGO_VERSION is set
  59. DJANGO_VERSION = os.environ.get("DJANGO_VERSION")
  60. if DJANGO_VERSION:
  61. install_requires = [
  62. u"Django{}".format(DJANGO_VERSION) if r.startswith("Django>=") else r
  63. for r in install_requires
  64. ]
  65. class SentrySDistCommand(SDistCommand):
  66. # If we are not a light build we want to also execute build_assets as
  67. # part of our source build pipeline.
  68. if not IS_LIGHT_BUILD:
  69. sub_commands = SDistCommand.sub_commands + [
  70. ("build_integration_docs", None),
  71. ("build_assets", None),
  72. ("build_js_sdk_registry", None),
  73. ]
  74. class SentryBuildCommand(BuildCommand):
  75. def run(self):
  76. if not IS_LIGHT_BUILD:
  77. self.run_command("build_integration_docs")
  78. self.run_command("build_assets")
  79. self.run_command("build_js_sdk_registry")
  80. BuildCommand.run(self)
  81. class SentryDevelopCommand(DevelopCommand):
  82. def run(self):
  83. DevelopCommand.run(self)
  84. if not IS_LIGHT_BUILD:
  85. self.run_command("build_integration_docs")
  86. self.run_command("build_assets")
  87. self.run_command("build_js_sdk_registry")
  88. cmdclass = {
  89. "sdist": SentrySDistCommand,
  90. "develop": SentryDevelopCommand,
  91. "build": SentryBuildCommand,
  92. "build_assets": BuildAssetsCommand,
  93. "build_integration_docs": BuildIntegrationDocsCommand,
  94. "build_js_sdk_registry": BuildJsSdkRegistryCommand,
  95. }
  96. setup(
  97. name="sentry",
  98. version=VERSION,
  99. author="Sentry",
  100. author_email="hello@sentry.io",
  101. url="https://sentry.io",
  102. description="A realtime logging and aggregation server.",
  103. long_description=open(os.path.join(ROOT, "README.rst")).read(),
  104. package_dir={"": "src"},
  105. packages=find_packages("src"),
  106. zip_safe=False,
  107. install_requires=install_requires,
  108. extras_require={
  109. "dev": dev_requires,
  110. "postgres": [],
  111. "optional": optional_requires,
  112. },
  113. cmdclass=cmdclass,
  114. license="BSD",
  115. include_package_data=True,
  116. entry_points={"console_scripts": ["sentry = sentry.runner:main"]},
  117. classifiers=[
  118. "Framework :: Django",
  119. "Intended Audience :: Developers",
  120. "Intended Audience :: System Administrators",
  121. "Operating System :: POSIX :: Linux",
  122. "Programming Language :: Python :: 2",
  123. "Programming Language :: Python :: 2.7",
  124. "Programming Language :: Python :: 2 :: Only",
  125. "Topic :: Software Development",
  126. ],
  127. )