setup.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env python
  2. import os
  3. import sys
  4. from distutils.command.build import build as BuildCommand
  5. from setuptools import setup
  6. from setuptools.command.develop import develop as DevelopCommand
  7. from setuptools.command.sdist import sdist as SDistCommand
  8. ROOT = os.path.dirname(os.path.abspath(__file__))
  9. # add sentry to path so we can import sentry.utils.distutils
  10. sys.path.insert(0, os.path.join(ROOT, "src"))
  11. from sentry.utils.distutils.commands.build_assets import BuildAssetsCommand
  12. from sentry.utils.distutils.commands.build_integration_docs import BuildIntegrationDocsCommand
  13. from sentry.utils.distutils.commands.build_js_sdk_registry import BuildJsSdkRegistryCommand
  14. IS_LIGHT_BUILD = os.environ.get("SENTRY_LIGHT_BUILD") == "1"
  15. class SentrySDistCommand(SDistCommand):
  16. # If we are not a light build we want to also execute build_assets as
  17. # part of our source build pipeline.
  18. if not IS_LIGHT_BUILD:
  19. sub_commands = SDistCommand.sub_commands + [
  20. ("build_integration_docs", None),
  21. ("build_assets", None),
  22. ("build_js_sdk_registry", None),
  23. ]
  24. class SentryBuildCommand(BuildCommand):
  25. def run(self):
  26. from distutils import log as distutils_log
  27. distutils_log.set_threshold(distutils_log.WARN)
  28. if not IS_LIGHT_BUILD:
  29. self.run_command("build_integration_docs")
  30. self.run_command("build_assets")
  31. self.run_command("build_js_sdk_registry")
  32. BuildCommand.run(self)
  33. class SentryDevelopCommand(DevelopCommand):
  34. def run(self):
  35. DevelopCommand.run(self)
  36. if not IS_LIGHT_BUILD:
  37. self.run_command("build_integration_docs")
  38. self.run_command("build_assets")
  39. self.run_command("build_js_sdk_registry")
  40. cmdclass = {
  41. "sdist": SentrySDistCommand,
  42. "develop": SentryDevelopCommand,
  43. "build": SentryBuildCommand,
  44. "build_assets": BuildAssetsCommand,
  45. "build_integration_docs": BuildIntegrationDocsCommand,
  46. "build_js_sdk_registry": BuildJsSdkRegistryCommand,
  47. }
  48. setup(cmdclass=cmdclass)